Syvum Home Page

Home > Quiz Games > Java Programming >

Java Programming : Classes and Keywords: Multiple Choice


Answer the following questions about classes and reserved keywords as used in the Java programming language.

Formats Info Page Worksheet / Test Paper Quiz Review
Multiple choice

Your Performance  

1.

Which keyword can protect a class in a package from accessibility by the classes outside the package?

  private

  final

  protected

  don't use any keyword at all (make it default)

  Half-n-half Clue
 

2.

Which of the following are keywords?
(A) switch
(B) integer
(C) default
(D) boolean
(E) object

  (E)

  (D)

  (A) & (C)

  (B) & (C)

  Half-n-half Clue
 

3.

Which of the following statements are true?
(A) An abstract class may not have any final methods.
(B) A final class may not have any abstract methods.
(C) An inner class may be declared with any accessibility keyword.
(D) Transient variables must be static
.

  (B) & (C)

  (A)

  (D)

  (A) & (C)

  Half-n-half Clue
 

4.

The use of protected keyword to a member in a class will restrict its visibility as follows:

  Visible only inside the package.

  Visible only in the class and its subclass in the same package.

  Visible only in the class where it is declared.

  Visible in all classes in the same package and subclasses in other packages.

  Half-n-half Clue
 

5.

Which of the following defines a legal abstract class?

  abstract class Vehicle {<br>
              abstract void display(); {<br>
                System.out.println("Car"); }}

  abstract Vehicle {<br>
              abstract void display(); }

  class abstract Vehicle {<br>
              abstract void display(); }

  abstract class Vehicle {<br>
              abstract void display(); }

  class Vehicle {<br>
              abstract void display(); }

  Half-n-half Clue
 

6.

Which of the following statements about abstract methods/classes in Java are true?
1. An abstract class cannot be instantiated.
2. Constructors cannot be abstract.
3. A subclass of an abstract class must defined the abstract methods.
4. Static methods may be declared abstract.

  Line 1, line 2 and line 3 only

  Line 1 only

  Line 1 and line 2 only

  Line 2 only

  All are true

  Half-n-half Clue
 

7.

Consider the following code:
class ClassA

  Error. ClassB does not define a no-argument constructor

  Error. There is no code in the class ClassB

  Error. There is no code in the constructor ClassA(int x)

  Will compile and run successfully

  Error. ClassA does not define a no-argument constructor

  Half-n-half Clue
 


 
12 more pages in Java Programming


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