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.

Consider the following code:
interface Area

  All of these

  Method compute() in class Room should be declared public

  Method compute() in interface Area should be declared public

  Interface definition is incomplete

  Half-n-half Clue
 

2.

Consider the following code:
class ClassA

  Error. ClassB does not define a no-argument constructor

  Error. There is no code in the class ClassB

  Will compile and run successfully

  Error. ClassA does not define a no-argument constructor

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

  Half-n-half Clue
 

3.

Package p1 contains the following code:
package p1;
public class Student

  Test class is not available.

  Class result should be declared public.

  Student class is not available.

  Result body is not fully defined.

  Half-n-half Clue
 

4.

We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would achieve this?

  private OR protected

  protected

  public

  private

  Half-n-half Clue
 

5.

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

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

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

  Visible only inside the package.

  Visible only in the class where it is declared.

  Half-n-half Clue
 

6.

Which of the following defines a legal abstract class?

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

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

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

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

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

  Half-n-half Clue
 

7.

Which of the following keywords are used to control access to a class member?
(A) default
(B) abstract
(C) protected
(D) interface
(E) public

  (C) & (E)

  All of these.

  (B), (C) & (E)

  (A), (C) & (E)

  Half-n-half Clue
 


 
12 more pages in Java Programming


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