• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Declaration and Access control question

 
Matt Ghiold
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question ID :952739447900
[TRIAL]
Given the following program, which statment is true?
class SomeClass
{
public static void main( String args[ ] )
{
if (args.length == 0 )
{
System.out.println("no arguments") ;
}
else
{
System.out.println( args.length + " arguments.") ;
}
}
}
Ok, the answer according to J+ is that this
program will throw a null pointer exception at
runtime, but when I compile and run this class
exactly as is, I get no arguments printed.
Can someone please confirm if I am correct or not?
Thanks,
Matt
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt, if you can compile and run a java program then you already have your answer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic