Answers
Answers
A. int
B. byte
C. short
D. long
View Answer
Ans : B
1. Method overloading
2. Constructor overloading
3. Method overriding
4. All the above
Answer: 4
c) Encapsulation
d) Inheritance
View Answer
Answer: d
Explanation: Inheritance indicates the code reusability. Encapsulation and abstraction are meant to
hide/group data into one element. Polymorphism is to indicate different tasks performed by a single
entity.
b) 3
c) 2
d) 1
View Answer
Answer: b
Explanation: Only 3 types of access specifiers are available. Namely, private, protected and public. All
these three can be used according to the need of security of members
b) It is a way of combining various data members and member functions into a single unit which can
operate on any data
c) It is a way of combining various data members into a single unit
View Answer
Answer: a
Explanation: It is a way of combining both data members and member functions, which operate on
those data members, into a single unit. We call it a class in OOP generally. This feature have helped us
modify the structures used in C language to be upgraded into class in C++ and other languages.
6. Which of the following data types comes under floating data types ?
A. int
B. double
C. long
D. byte
View Answer
Ans : B
b) Protected
c) Private
d) Public
View Answer
Answer: c
Explanation: The private members can be accessed only inside the base class. If the class is derived by
other classes. Those members will not be accessible. This concept of OOP is made to make the
members more secure.
b) Encapsulation
c) Abstraction
d) Inheritance
View Answer
Answer: a
1. Inheritance
2. Multiple inheritance for classes
3. multiple inheritance of interfaces
4. compile time polymorphism
Answer: 2
Java does not support multiple inheritance for classes but in java multiple inheritance behavior is
implemented using interfaces.
Answer: 1
Since in method overriding both the classes(base class and child class) have same method, compile
doesn’t figure out which method to call at compile-time. In this case JVM(java virtual machine) decides
which method to call at runtime that’s why it is known as runtime or dynamic polymorphism.
1. Inheritance
2. Encapsulation
3. Composition
4. None
Answer: 1
b) Modularity
c) Duplicate/Redundant data
d) Efficient Code
View Answer
Answer: c
Explanation: Duplicate/Redundant data is dependent on programmer and hence can’t be guaranteed
by OOP. Code reusability is done using inheritance. Modularity is supported by using different code
files and classes. Codes are more efficient because of features of OOP
};
d) It is correct
View Answer
Answer: a
Explanation: Same variable can’t be defined twice in same scope. Even if the data types are different,
variable name must be different. There is no rule like Public member should come first or last.
b) student class{ };
View Answer
Answer: b
Explanation: Keyword class should come first. Class name should come after keyword class.
Parameterized constructor definition depends on programmer so it can be left empty also.
15. f a function can perform more than 1 type of tasks, where the function name remains same, which
feature of OOP is used here?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction
View Answer
Answer: c
Explanation: For the feature given above, the OOP feature used is Polymorphism. Example of
polymorphism in real life is a kid, who can be a student, a son, a brother depending on where he is.
b) Instance of an object
c) Blueprint of an object
d) Scope of an object
View Answer
Answer: c
Explanation: A class is Blueprint of an object which describes/ shows all the functions and data that
are provided by an object of a specific class. It can’t be called as parent or instance of an object. Class
in general describes all the properties of an object.
View Answer
Answer: a
Explanation: As Java supports usual declaration of data variables, it is partial implementation of OOP.
Because according to rules of OOP, object constructors must be used, even for declaration of
variables.
b) Logical
c) Real
d) Hypothetical
View Answer
Answer: b
Explanation: Class is logical abstraction because it provides a logical structure for all of its objects. It
gives an overview of the features of an object.
19. Object is ________ abstraction.
a) Object
b) Logical
c) Real
d) Hypothetical
View Answer
Answer: c
Explanation: Object is real abstraction because it actually contains those features of class. It is the
implementation of overview given by class. Hence the class is logical abstraction and its object is real.
b) Instance of itself
c) Child of a class
d) Overview of a class
View Answer
Answer: a
Explanation: An object is instance of its class. It can be declared in the same way that a variable is
declared, only thing is you have to use class name as the data type.