Java OCA OCP Practice Question 1534

Question

Given:

public class Main{
    public int base;
    public int height;
    private static double c;

    public static double getAngle ();

    public static void Main (String [] args)  {
        System.out.println (getAngle ());
     }//from w  w w .  j  av a 2  s .  c o  m
}

Identify the correct statements:

Select 1 option

  • A. It will not compile because it does not implement setAngle() method.
  • B. It will not compile because c cannot be private.
  • C. It will not compile because getAngle() has no body.
  • D. It will not compile because c field is not initialized.
  • E. It will not compile because of the name of the method Main instead of main.


Correct Option is  : C

Note

For A.

There is no requirement that a class has to have a setter as well as a getter.

For B.

Any field can be made private.

For D.

Since it is a static field, it will get a default value of 0.0.

For E.

A class can have a method named Main.




PreviousNext

Related