Java OCA OCP Practice Question 1378

Question

Which of these are not legal declarations within a class?

Select 1 option

A. static volatile int sa ; 
B.  final Object [] objArr =  { null  } ; 
C. abstract int t ; 
D. native void format ( ) ; 
E.  final transient static private double PI = 3.14159265358979323846; 


Correct Option is  : C

Note

static and final are valid modifiers for both member field and method declarations within a class.

transient and volatile modifiers are only valid for member field declarations.

abstract and native are only valid for member methods.

A class declaration can have only have final, abstract and public as modifiers, unless it is a nested class.

For a nested class, it can be declared private or protected as well.

Within a method, a local variable may be declared as final.




PreviousNext

Related