Syvum Home Page

Home > Quiz Games > Java Programming >

Java Programming : Compilation and Execution: Multiple Choice


Answer the following questions about Java syntax and mistakes which can cause compilation errors, as well as the output generated by sample programs.

Formats Info Page Worksheet / Test Paper Quiz Review
Multiple choice

Your Performance  

1.

What will be the output of the following program?
class Main1

  XXX followed by YYY

  Error. Won't compile

  YYY

  XXX

  Half-n-half Clue
 

2.

What will be the output of the following program?
class Main2

  XXX followed by YYY

  Error. Won't compile

  YYY

  XXX

  Half-n-half Clue
 

3.

Are there any errors in the following class definition?
abstract class Class1

  Class header definition is wrong

  Method definition is wrong

  Constructor needs to be defined

  No errors

  Half-n-half Clue
 

4.

To print the value of a variable "x" of type int, which of the following expressions can be used:
(A) System.out.println("x = " + x);
(B) System.out.println("x = " + String.valueOf(x));
(C) System.out.println("x = " + Integer.toString(x));
(D) System.out.println("x = " + (new Integer(x)).toString());

  (B) and (D)

  (C) and (D)

  (B), (C) and (D)

  (A), (B), (C) and (D)

  Half-n-half Clue
 

5.

What is java_g used for?

  None of these

  To provide information about deprecated methods

  Using the jdb tool

  Executing a class with optimization turned off

  Half-n-half Clue
 

6.

For the following class definition, which is a legal statement to construct an object of type Class1:
class Class1 extends Class2

  (A)

  (C) & (E)

  (A) & (B)

  (C) & (D)

  None of the above

  Half-n-half Clue
 

7.

Consider the following code:
int i = 1;
switch(c)

  output will be One

  code is illegal and therefore will not compile

  output will be One, followed by Two, and then followed by Three

  output will be One followed by Two

  Half-n-half Clue
 


 
12 more pages in Java Programming


Contact Info © 1999-2025 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright
Previous
-
Next
-