Java OCA OCP Practice Question 74

Question

Given the following class definition, which is the only line that does not contain a compilation error?

1: public ThisClassDoesNotCompile { 
2:    double int count; 
3:    void errors() {} 
4:    static void private limit; } 
  • A. Line 1
  • B. Line 2
  • C. Line 3
  • D. Line 4


C.

Note

Line 1 is missing the class keyword.

Line 2 contains two types for the same variable.

Line 3 is a valid definition for a method, making C the correct answer.

Line 4 contains an access modifier, private, after the return type, which is not allowed.

In addition, void is an invalid type for variables.




PreviousNext

Related