Java OCA OCP Practice Question 1384

Question

Given the following class,

which statements can be inserted at line 1 without causing the code to fail compilation?

public class Main{ 
   int a; //from w  w  w. j a v  a  2 s . c o m
   int b = 0; 
   static int c; 
   public void m (){ 
      int d; 
      int e = 0; 
      // Line 1 
    } 
} 

Select 4 options

  • A. a++;
  • B. b++;
  • C. c++;
  • D. d++;
  • E. e++;


Correct Options are  : A B C E

Note

All the instance or static variables are given a default values if they are not explicitly initialized.

All numeric variable are given a value of zero or equivalent to zero (i.e. 0 for integral types and 0.0 for double/float).

Booleans are initialized to false and objects are initialized to null.




PreviousNext

Related