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  


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


  (C) & (E)

  (A) & (B)

  (C) & (D)

  None of the above

  Half-n-half Clue


Which error does the following code contain: class Class1

  Method func1() must be declared as static

  There is no error

  Class Class1 has not been declared public

  Class1 should be declared as abstract

  Half-n-half Clue


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 3 only

  Line 1 only

  Line 1 and Line 4

  Line 3 and Line 4

  Line 4 only

  Half-n-half Clue


Examine the following class definitions to detect errors, if any.
abstract class MyPanel

  1 Error. Method show() should have a return type

  1 Error. Method show() is not implemented in MyDisplay

  1 Error. MyDisplay does not contain any members

  No errors

  Half-n-half Clue


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


  XXX followed by YYY


  Error. Won't compile

  Half-n-half Clue


Consider the following code:
int i = 1;

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

  output will be One followed by Two

  output will be One

  code is illegal and therefore will not compile

  Half-n-half Clue


Examine the following code snippets to identify the legal loop constructs:
(A) for (int i = 22, int j = 0; i + j > 11; i = i-3, j++)



  (A) & (C)

  (A) & (D)

  Half-n-half Clue

12 more pages in Java Programming

Contact Info © 1999-2020 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright