Given the content of three files:
Which statement is true?
Which statement is true?
A. Only the A.Java file compiles successfully.
B. Only the B.java file compiles successfully.
C. Only the C.java file compiles successfully.
D. The A.Java and B.java files compile successfully.
E. The B.java and C.java files compile successfully.
F. The A.Java and C.java files compile successfully.
A
public class Q88 {
private int doStuff(){
private int x =100;// private here not allowed already x is local variable
return x++;
}
}
Correct answer is A.
B.java does not work because we can’t have private or protected variables in a block.
C.java can’t be compiled because of many errors (i.e. filename, package declaration …)
Answer D:
Class “C” will not compile because the file name is not matching the class name.
A