Sunday, March 29, 2009

OOPS - Part 1

1) What is meant by Object Oriented Programming?
OOP is a method of programming in which programs are organized as cooperative collections of objects. Each object is an instance of a class and each class belong to a hierarchy.

2) What is a Class?
Class is a template for a set of objects that share a common structure and a common behaviour.

It’s a comprehensive data type which represents a blue print
of objects. It’s a template of object.

3) What is an Object?
Object is an instance of a class. It has state,behaviour and identity. It is also called as an instance of a class.

It is a basic unit of a system. An object is an entity that has attributes, behavior, and
identity. Objects are members of a class. Attributes and behavior of an object are defined
by the class definition.

4) What is an Instance?
An instance has state, behaviour and identity. The structure and behaviour of similar classes are defined in their common class. An instance is also called as an object.

5) What are the core OOP’s concepts?
Abstraction, Encapsulation,Inheritance and Polymorphism are the core OOP’s concepts.

6) What is meant by abstraction?
Abstraction defines the essential characteristics of an object that distinguish it from all other kinds of objects. Abstraction provides crisply-defined conceptual boundaries relative to the perspective of the viewer. Its the process of focussing on the essential characteristics of an object. Abstraction is one of the fundamental elements of the object model.

7) What is meant by Encapsulation?
It is a process of hiding all the internal details of an object from the outside world.

Encapsulation is the process of compartmentalising the elements of an abtraction that defines the structure and behaviour. Encapsulation helps to separate the contractual interface of an abstraction and implementation.

8) What is meant by Inheritance?
Inheritance is a relationship among classes, wherein one class shares the structure or behaviour defined in another class. This is called Single Inheritance. If a class shares the structure or behaviour from multiple classes, then it is called Multiple Inheritance. Inheritance defines “is-a” hierarchy among classes in which one subclass inherits from one or more generalised superclasses.

Hierarchy is used to define more specialized classes based on a preexisting generalized
class which will add new attributes and use some existing qualities
of the parent class. Its shows more of a parent-child relationship. This kind of hierarchy
is called inheritance.

9) What is meant by Polymorphism?
Polymorphism literally means taking more than one form. Polymorphism is a characteristic of being able to assign a different behavior or value in a subclass, to something that was declared in a parent class.

10) What is an Abstract Class?
Abstract class is a class that has no instances. An abstract class is written with the expectation that its concrete subclasses will add to its structure and behaviour, typically by implementing its abstract operations.

11) What is an Interface?
Interface is an outside view of a class or object which emphaizes its abstraction while hiding its structure and secrets of its behaviour.

12) What is the difference between abstract class and interface?
i)Abstract classes can have concrete methods while interfaces have no methods
ii) Interfaces do not come in inheriting chain, while abstract classes come in

We use abstract class and interface where two or more entities do same type of work but in different ways. Means the way of functioning is not clear while defining abstract class or interface. When functionality of each task is not clear then we define interface. If functionality of some task is clear to us but there exist some functions whose functionality differs object by object then we declare abstract class.

13) What is a base class?
Base class is the most generalised class in a class structure. Most applications have such root classes. In Java, Object is the base class for all classes.

14) What is a subclass?
Subclass is a class that inherits from one or more classes

15) What is a superclass?
superclass is a class from which another class inherits.

16) What is a constructor?
Constructor is an operation that creates an object and/or initialises its state.

17) What is a destructor?
Destructor is an operation that frees the state of an object and/or destroys the object itself. In Java, there is no concept of destructors. Its taken care by the JVM.

18) What is meant by static binding?
Static binding is a binding in which the class association is made during compile time. This is also called as Early binding.

19) What is meant by Dynamic binding?
Dynamic binding is a binding in which the class association is not made until the object is created at execution time. It is also called as Late binding.

20) What does virtual keyword mean ?
They signify that method and property can be overridden.

21) what is Method Overloading?
Method Overloading means to have two or more methods in the same class with different signature. The benefit of method overloading is that it allows you to implement methods that supports the same semantic operation but differ by argument number or type.

22) What is Method Overriding?
Method Overriding changing the behavior of a method in a base class. Use keyword Overrides.

23) What is meant by Binding?
Binding denotes association of a name with a class.

24) What is a delegate ?
Delegate is a class that can hold a reference to a method or a function. Delegate class has
a signature and it can only reference those methods whose signature is compliant with the
class. Delegates are type-safe functions pointers or callbacks.

25) Do interface have accessibility modifier?
All elements in Interface should be public. So by default all interface elements are public
by default.

26) What is meant by Persistence?
Persistence is the property of an object by which its existence transcends space and time.

27) What is colloboration?
Colloboration is a process whereby several objects cooperate to provide some higher level behaviour.

No comments:

Post a Comment