Home

Java Programming MCQ - Multiple Choice Question and Answer

Java Programming MCQ with detailed explanation for interview, entrance and competitive exams. Explanation are given for understanding.

Download Objective type questions of Java Programming PDF

Visit our PDF store

Question No : 8
What is error in the following class definitions? 

abstract class xy { 
abstract sum(int x, int y) {
}
}

class header is not define properly
constructor is no defined
method is not defined properly
no error

Question No : 9
Consider the following class definitions:

 class maths { 
student student1;
}
class student {
String name;
}

This code represents:

an 'is a' relationship
a 'has a' relationship
both
neither

Question No : 10
Which key word can protect a class in package from accessibility by the classes outside the package?

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

Question No : 11
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
protected
public
private protected

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

Visibility only in the class and its subclasses in the same package.
Visibility only inside the same package.
Visibility in all classes in the same package and subclasses in other packages.
Visibility only in the class where it is declared.

Question No : 13
Which of the following are not keywords?

NULL
Implements
Protected
None of the above

Question No : 14
Which of the following are keywords?

integer
default
Boolean
Object