• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best answer to pick ?

 
Ram Han
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across this question in one of the mock exams

I was really surprised about the answer they have given

Is this the way , questions will be in SCJP1.4?


class TestLevel{
public static void main(String a[]){
int i=0;
int y=i;
}
}

Choices ( choose any 1 )

1. Compile time error
2. Runtime Error
3. Compiles with warnings.
4. Compiles without warnings.
5. None of these

I choosed answer 4

But on final result it said the answer is 5 ...

I agree answer 5 is also right.
But why not 4 ?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could just be a mistake on the listing of the answer. It seems like compiles with warnings and compiles without warnings are two statements that can never both be true or false at the same time.
 
Ram Han
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
" Compiles with warnings "

" Compiles without warnings"

Is possible in any code, if we have any deprecated methods used we would have " Compiles with warnings "
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I mean is if 5 is true, that none of 1, 2, 3, and 4 happen, this couldn't happen since, assuming the code compiles, you couldn't have "compiles with warnings" and "compilers without warning" both being false at the same time.
 
vipul patel
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I belive answer 4 should be the right choice. i tried it and compiled. it just compiles fine. no errors & warnings.

answer 5 does not make any sense at all since option 4 is the best given answer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic