Encapsulation Worksheet
Encapsulation Worksheet
1. Which access specifier allows accessibility of a member only within the same class where it is
declared?
a. public b. private
c. protected d. default
3. An OOP feature that allows all members of a class to be the members of another class.
a. Encapsulation b. Abstraction
c. Inheritance d. Polymorphism
5. Which access specifier allows accessibility by all classes in the same package, but only by
subclasses in a different package?
a. public b. private
c. protected d. default
6. A static member a is declared in a class named ‘Myclass’, write the statement to initialise it with
5, from a function in another class.
a. a=5; b. a of Myclass=5;
c. Myclass.a=5; d. a.Myclass=5;
8. If data members are private, what can we do to access them from the class object?
a. Create public member functions to access those data members
b. Create private member functions to access those data members
c. Create protected member functions to access those data members
d. Private data members can never be accessed from outside the class
7. What package is a part of the wrapper class which is imported by default into all Java programs?
a. java.util b. java.lang
c. java.awt d. None of these
9. What is, converting a primitive value into an object of the corresponding wrapper class called?
a. Autoboxing b. Unboxing
c. Type Casting d. All of these
10. Which among the following function is used to check whether a given character is a tab space or not?
a. isTab() b. isTabSpace()
c. isSpace() d. isWhitespace()