1.9. Sample exam questions

Q1-1.

Given:

class EJava {
    //..code
}

Which of the following options will compile?

  1. package java.oca.associate;
    class Guru {
        EJava eJava = new EJava();
    }
  2. package java.oca;
    import EJava;
    class Guru {
        EJava eJava;
    }
  3. package java.oca.*;
    import java.default.*;
    class Guru {
        EJava eJava;
    }
  4. package java.oca.associate;
    import default.*;
    class Guru {
        default.EJava eJava;
    }
  5. None of the above

Q1-2.

The following numbered list of Java class components is not in any particular order. Select the acceptable order of their occurrence in any Java class (choose all that apply):

  1. comments
  2. import statement
  3. package statement
  4. methods
  5. class declaration
  6. variables
  1. 1, 3, 2, 5, 6, 4
  2. 3, 1, 2, 5, 4, 6
  3. 3, 2, 1, 4, ...

Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.