1. Name two functional languages that support object-oriented programming.
C++ and Objective-c
2. What are the problems associated with programming using abstract data types?
-In nearly all cases, the features and capabilities of the existing type are not quite right for the
-The type definitions are all independent and are at the same level.
3. What is the advantage of inheritance ?
It can be reuse and modified
4. What is message protocol?
Message protocol is the entire collection of methods of an object.
5. What is an overriding method?
Overriding method is method that overrides the inherited method.
7. What is dynamic dispatch?
Dynamic dispatch is the third characteristic (after abstract data types and inheritance) of object-oriented programming language which is a kind of polymorhphism provided by the dynamic binding of messages to method definitions.
10. What is an inner class?
An inner class is a nonstatic class that is nested directly in another class.
12. From where are Smalltalk objects allocated?
Smalltalk objects are allocated from the heap and are referenced through reference variables,
which are implicitly dereferenced.
19. How are C++ heap-allocated objects deallocated?
C++ heap-allocated objects are deallocated using destructor.
29. Does Objective-C support multiple inheritances?
No Objective-C doesn’t support it. (It supports only single inheritance).
38. What is boxing?
Boxing is primitive values in Java 5.0+ which is implicitly coerced when they are put in object context. This coercion converts the primitive value to an object of the wrapper class of the primitive value’s type.
52. Does Ruby support multiple inheritance?
No. it does not
2. In what ways can “compatible “ be defined for the relationship between an overridden method and the overriding method?
Every overriding method must have the same number of parameters as the overridden method and the types of the parameters and the return type must be compatible with those of the parent class.
3. Compare the inheritance of C++ and Java.
◦ Forest of classes; when we create a class that doesn’t inherit from anything, we create a
new tree in forest.
◦ Private members of base class are not accessible in derived class.
◦ Provides inheritance specifier (public, protected, private).
◦ Interfaces and abstract classes are declared without using keywords.
◦ Virtual keyword are used explicitly.
◦ Default constructor of parent class is automatically called, but if we want to call
parametrized constructor of a parent class, we must use Initializer list.
◦ Support multiple inheritance.
◦ All classes inherit from the Object class directly or indirectly. If we create a class that
doesn’t inherit from any class then it automatically inherits from Object Class (root of the
◦ Members of the grandparent class are not directly accessible.
◦ Protected members of a class ‘A’ are accessible in other class ‘B’ of same package, even if
‘A’ doesn’t inherit from ‘B’ (they both have to be in the same package).
◦ Doesn’t provide inheritance specifier. Instead, extends keyword used for inheritance.
Therefore, we cannot change the protection level of members of base class in Java.
◦ Use a separate keyword interface for interfaces, and abstract keyword for abstract classes
and abstract functions.
◦ Methods are virtual by default.
◦ Default constructor of the parent class is automatically called, but if we want to call
parametrized constructor then we must use super to call the parent constructor.
◦ Doesn’t support multiple inheritance.
7. What is one programming situation where multiple inheritance has a significant disadvantage over interfaces?
A situation when there are two classes derived from a common parent and those two derived
class has one child.
10. Explain one advantage of inheritance.
• Inheritance offers a solution to both the modification problem posed by abstract data type
reuse and the program organization problem. If a new abstract data type can inherit the data
and functionality of some existing type, and is also allowed to modify some of those entities
and add new entities, reuse and is also allowed to modify some of those entities and add new
entities, reuse is greatly facilitated without requiring change to the reused abstract data type.
17. What are the different options for object destruction in Java?
There is no explicit deallocation operator. A finalize method is implicitly called when the garbage collector is about to reclaim the storage occupied by the object.