Java OCA OCP Practice Question 1540

Question

What, if anything, is wrong with the following code?

abstract class Main{
   transient int j;
   synchronized int k;
   final void Main (){}
   static void f (){}
}

Select 1 option

  • A. The class Main cannot be declared abstract.
  • B. The variable j cannot be declared transient.
  • C. The variable k cannot be declared synchronized.
  • D. The constructor Main ( ) cannot be declared final.
  • E. The method f ( ) cannot be declared static.
  • F. This code has no errors.


Correct Option is  : C

Note

For A.

Any class can be declared abstract.

For C.

Variables cannot be declared synchronized. Only methods can be declared synchronized.

For D.

It is not a constructor, it is a simple method. Notice void return type.




PreviousNext

Related