Jacobvu84 / selenium-vietnam-training-course

Questions Tracking
7 stars 5 forks source link

Core Java 01: Total 10 Questions #28

Open Jacobvu84 opened 6 years ago

Jacobvu84 commented 6 years ago
  1. Which one of the following is NOT a reserved word in Java?

    a. final
    b. virtual
    c. private
    d. public
  2. Which of the following is used to see the details of compilation

    a. None of these
    b. javac -debug TestExample.java
    c. javac -detail TestExample.java
    d. javac -verbose TestExample.java
  3. Keyword used to access members or methods of superclass?

    a. extends
    b. super
    c. this
    d. native
  4. In Java inheritance

    a. a new class is derived from an existing class
    b. all fields of a class are protected
    c. all fields of a class are private
    d. none of these above
  5. What is the output?

    int[] xxx = {10, 20};
    List<String> list = new ArrayList<String>(10);
    list.add("01");
    list.add("02");
    System.out.println(xxx.length + ", " +list.size());
    a. Compile error
    b. 1, 2
    c. 2, 10
    d. 2, 2
    e. 10, 2
  6. Which statement is true? enum Example { ONE, TWO, THREE }

    a. The expression (ONE < TWO) is guaranteed to be true and ONE.compareTo(TWO) is guaranteed to be less than one.
    b. The Example values cannot be used in a raw java.util.HashMap; instead, the programmer must use a java.util.EnumMap.
    c. The Example values can be used in a java.util.SortedSet, but the set will NOT be sorted because enumerated types do NOT implement java.lang.Comparable.
    d. The expressions (ONE == ONE) and ONE.equals(ONE) are both guaranteed to be true
  7. A method without an access modifier (i.e. public, private, protected) is...

    public
    package-private
    static
    private
    protected
  8. What is the output of the following program?

    
    import java.lang.reflect.Method;

class TestImpl { public void method() {}

public static void main(String[] args) { Method method = TestImpl.class.getMethod("method", null); System.out.println(method.getName()); } }

    a. Compilation Error
    b. public void test.TestImpl.method()
    c. None of the Above

09. After the following code fragment, what is the value in a?

String s; int a; s = "Foolish boy."; a = s.indexOf("fool");


        -1
        0
        1
        4

10. What is Annotation in Java?

        a. An annotation, in the java programming language is a special form of syntactic metadata that can be added to Java Source Code.
        b. Classes, methods, variables, parameters and packages may be annotated.
        c. Unlike Java doc tags, Java annotation are reflective, in that they are embedded in class files generated by the compiler and may be retained by the java VM to make retrievable at run-time.
        d. Annotation is basically to attach metadata to method, class or package. Metadata is used by the compiler to perform some basic compile-time checking.
        e. Software tools can process annotation information to generate code, XML files, and so forth.
        f. All of these above