Multiple Choice Questions 1

  1. Which of the following statements is false?

  2. Java is object-oriented.
    Java source code is compiled into the bytecode and the bytecode is executed by a Java interpreter.
    Java programs runs faster than C++ programs.
    Java is distributed.

  3. Which of the following statements is true?

  4. A Java source program can contain only one class.
    A class name in the program must match the file name that contains the program.
    Each class in the source code is compiled into a bytecode file.
    The source file and the bytecode must be stored in the same directory.

  5. Which of the following lines is not a Java comment line?

  6. /** comments */
    // comments
    -- comments
    /* comments */

  7. The extension name of a Java bytecode file is

  8. .java
    .obj
    .class
    .exe

  9. The extension name of a Java source code file is

  10. .java
    .obj
    .class
    .exe

  11. To import all the classes in the package java.awt, you write


  12. import java.awt;
    import java.*;
    import java.awt.*;
    You don't need to import the package; it is implicitly imported by the Java runtime system.

  13. Which of the following is a correct signature for the main() method?

  14. static void main(String[] args[])
    public static void main(String[] args)
    public void main(String[] args)
    public static void main(strings[] args)

  15. Which of the following is a correct signature for the paint() method?

  16. static void paint(Graphics[] g)
    public paint(Graphics g)
    public void paint(Graphics g)
    public static void paint(Graphics g)

  17. Which of the following statements is correct?

  18. System.out.println('Welcome to Java')
    System.out.println("Welcome to Java")
    System.println('Welcome to Java');
    System.out.print('Welcome to Java');

  19. Which of the following statements is correct to draw a string at location (10,10)?

  20. g.drawString("Welcome to Java"; 10; 10)
    g.drawString(10, 10, "Welcome to Java")
    g.drawString("Welcome to Java", 10, 10)
    g.drawString("Welcome to Java": 10:10)

Visited times since 25 Jan 1999.