Multiple Choice Questions 1
Which of the following statements is false?
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.
Which of the following statements is true?
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.
Which of the following lines is not a Java comment line?
/** comments */
// comments
-- comments
/* comments */
The extension name of a Java bytecode file is
.java
.obj
.class
.exe
The extension name of a Java source code file is
.java
.obj
.class
.exe
To import all the classes in the package java.awt, you write
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.
Which of the following is a correct signature for the main() method?
static void main(String[] args[])
public static void main(String[] args)
public void main(String[] args)
public static void main(strings[] args)
Which of the following is a correct signature for the paint() method?
static void paint(Graphics[] g)
public paint(Graphics g)
public void paint(Graphics g)
public static void paint(Graphics g)
Which of the following statements is correct?
System.out.println('Welcome to Java')
System.out.println("Welcome to Java")
System.println('Welcome to Java');
System.out.print('Welcome to Java');
Which of the following statements is correct to draw a string at location (10,10)?
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.