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.

Which lines of the following will produce an error?
1. byte a1 = 2, a2 = 4, a3;
2. short s = 16;
3. a2 = s;
4. a3 = a1 * a2;
(The lines are numbered only for illustration in this question.)

  Line 1 and Line 4

  Line 3 only

  Line 1 only

  Line 3 and Line 4

  Line 4 only

  Half-n-half Clue
 

2.

Determine the output when the value of x is zero:
if(x >= 0)
if(x > 0)
System.out.println("x is positive");
else
System.out.println("x is negative");

  None of these

  "x is negative"

  "x is positive" and "x is negative"

  "x is positive"

  Half-n-half Clue
 

3.

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

  XXX

  XXX followed by YYY

  YYY

  Error. Won't compile

  Half-n-half Clue
 

4.

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
 

5.

The method int func(int i, int j)

  (B) & (C)

  (C) & (D)

  (A), (B), (C) & (E)

  (A), (B) & (E)

  None of these

  Half-n-half Clue
 

6.

With javadoc, which of the following denotes a javadoc comment?

  //**

  /*

  //#

  /**

  Half-n-half Clue
 

7.

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
 


 
12 more pages in Java Programming


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