J2EEOnline J2EE   





Java Certification  «Prev Next »
Java Language Fundamentals - Quiz
Each question is worth one point. Select the best answer or answers for each question.
 
1. What is the output of the following program?

public class Question {
 public static void main(String args[])
 {
  String[] s = new String[2];
  boolean[] b = new boolean[2];
  for(int i=0;i<2;++i)
   System.out.print(s[i]+b[i]);
 }
}

Please select the best answer.
  A. falsefalse
  B . truetrue
  C. nullfalsenullfalse
  D. There is no output. The program ends with the throwing of a NullPointerException.

2. Which of the following is a double literal?
Please select the best answer.
  A. 1.2e3
  B. 017
  C. e7
  D. 10L

3. How is the decimal value 15 represented as an octal value?
Please select the best answer.
  A. 015
  B. 0x15
  C. 017
  D. 0x17


4. Which of the following must be true for a public class named MyClass to be compiled and run as a Java program?
Please select all the correct answers.
  A. It must be declared in the file MyClass.java.
  B. It must contain a valid main() method.
  C. It must use an import statement to import java.lang.
  D. It must contain a package statement as its first non-blank, non-comment line.

5. What is the output of the following program when it is invoked with the command java Question one two three?
public class Question {
  static int i;
  public static void main(String args[]){
    System.out.print(args[i]);
  }
}

Please select the best answer.
  A. Question
  B. one
  C. null
  D. 0

6. What is the output of the following program?


class Question{
  static String ThisIsATest;
    public static void main(String[] args){
      String s = "\"" + 
      ThisIsATest + "\"";  
      System.out.println(s);  
    }  
}

Please select all the correct answers.
  A. ThisIsATest
  B. "ThisIsATest"
  C. "null"
  D. \"ThisIsATest\"

7. Which of the following are Java keywords?
Please select all the correct answers.
  A. true
  B. long
  C. static
  D. end