IT Developer

Encapsulation and Inheritance in Java

Chapter 13

Encapsulation and Inheritance in Java

Class 10 - Logix Kips ICSE Computer Applications with BlueJ


Share with a Friend

Multiple Choice Questions


Question 1

............... is the technique of binding both data and methods together to keep them safe from unauthorised access and misuse.

  1. Abstraction
  2. Inheritance
  3. Encapsulation
  4. Polymorphism

Answer

Encapsulation

Reason — Encapsulation is the technique of binding both data and methods together to keep them safe from unauthorised access and misuse.

Question 2

Which of the following is an access specifier?

  1. public
  2. protected
  3. private
  4. All of these

Answer

All of these

Reason — Public, private and protected are access specifiers.

Question 3

A member variable declared with a public access specifier has visibility in ............... .

  1. Class
  2. Package
  3. Subclass
  4. All of these

Answer

All of these

Reason — A member variable declared with a public access specifier has visibility in the class, its sub classes and the package as well.

Question 4

A member variable declared with a private access specifier has visibility only in the ............... .

  1. Class
  2. Package
  3. Subclass
  4. All of these

Answer

Class

Reason — A member variable declared with a private access specifier has visibility only in the class in which it is declared.

Question 5

A member variable declared with no access specifier has visibility in ............... .

  1. Class and package only
  2. Class, package and subclass only
  3. Class and subclass only
  4. Class only

Answer

Class and package only

Reason — A member variable declared with no access specifier has visibility in the same class and other classes of the same package only.

Question 6

An instance variable ............... .

  1. needs an instance to access it
  2. does not need an instance to access it
  3. can be accessed using the class name
  4. is declared with the static keyword

Answer

needs an instance to access it

Reason — An instance variable needs an instance (object) to access it as each instance of the class has a separate copy of the instance variable.

Question 7

A static variable ............... .

  1. is preceded by static keyword in the declaration
  2. is accessed via the class name
  3. is also known as a class variable
  4. All of the above

Answer

All of the above

Reason — A static variable is preceded by static keyword in the declaration. It belongs to the class and hence, it is called a class variable and is accessed via the class name.

Question 8

............... is the feature by means of which one class acquires the properties of another class.

  1. Abstraction
  2. Inheritance
  3. Encapsulation
  4. Polymorphism

Answer

Inheritance

Reason — Inheritance is the feature by means of which one class acquires the properties of another class.

Question 9

The class that gets inherited is known as ............... .

  1. Parent class
  2. Base class
  3. Super class
  4. All of these

Answer

All of these

Reason — The class that gets inherited is known as a parent class, base class and super class as well.

Question 10

When many sub classes are inherited from a single base class, it is known as ............... .

  1. Hierarchical inheritance
  2. Multiple inheritance
  3. Single inheritance
  4. Multilevel inheritance

Answer

Hierarchical inheritance

Reason — When many sub classes are inherited from a single base class, it is known as Hierarchical inheritance.