Professional Documents
Culture Documents
1. What are the advantages of object oriented programming over procedure oriented programming?
1) OOPs makes development and maintenance easier where as in Procedure-oriented programming language
it is not easy to manage if code grows as project size grows.
2) OOPs provides data hiding whereas in Procedure-oriented programming language a global data can be accessed
from anywhere.
3) OOPs provides ability to simulate real-world event much more effectively. We can provide the solution of real
word problem if we are using the Object-Oriented programming language.
2. Define abstraction?
Abstraction is the process used to hide certain details and only show the essential features
of the object. It deals with the outside view of an object (interface)
4. Define class?
A class is a user defined blueprint or prototype from which objects are created. It
represents the set of properties or methods that are common to all objects of one type. In
general, class declarations can include these components, in order:
1. Modifiers : A class can be public or has default access
2. Class name: The name should begin with a initial letter (capitalized by convention).
3. Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the keyword extends.
A class can only extend (subclass) one parent.
4. Interfaces(if any): A comma-separated list of interfaces implemented by the class, if any, preceded
by the keyword implements. A class can implement more than one interface.
5. Body: The class body surrounded by braces, { }.
5. Define object?
It is a basic unit of Object Oriented Programming and represents the real life entities. A
typical Java program creates many objects, interact by invoking methods. An object
consists of :
1. State : It is represented by attributes of an object. It also reflects the properties of an object.
2. Behavior : It is represented by methods of an object. It also reflects the response of an object with other
objects.
3. Identity : It gives a unique name to an object and enables one object to interact with other objects.
4) Object is created through new keyword Class is declared using class keyword e.g.
class Student{}
6) Object allocates memory when it is created. Class doesn't allocated memory when it is
created.
7) There are many ways to create object in There is only one way to define class in java
java such as new keyword, newInstance() using class keyword.
method, clone() method, factory method and
deserialization.
7.Define Inheritance?
An important feature of object-oriented programs is inheritance - the ability to create
classes that share the attributes and methods of existing classes, but with more specific
features. Inheritance is mainly used for code reusability.
Constructor must have the same name as the class within which it defined while it is not necessary for
the method in java.
Constructor does not any return type while method(s) have the return type or void if does not return any value
Constructor is called only once at the time of Object creation while method(s) can be called any numbers
of time.
2. Define SuperClass?
In the terminology of Java, a class that is inherited is called a superclass
3. Define Subclass?
The class that does the inheriting is called a subclass. Therefore, a subclass is a specialized version of a superclass.
It inherits all of the members defined by the superclass and adds its own, unique elements.