Monday, October 6, 2008

OOPS Questions And Answers


1.) Why JAVA is known as securable language? 

There are two reasons behind this. The first one is, as JAVA runs in JVM, which is a virtual machine, and it converts source code to byte code, which is not understandable for humans, so its safe. The second reason is JAVA does not support the Pointer concept, hence we can say that JAVA is a securable language.


2.) What is the necessity of Interface? 

As java is a Partially Object Oriented language, and it does not support the multiple inheritance concepts, it creates problem for the developers. To over come this situation JAVA provides Interface concept for multiple inheritance.


3.) What is Abstraction? 

An essential element of object-oriented programming is abstraction. Abstraction is the process to hide the complexity. A powerful way to manage abstraction is through the use of hierarchical classifications. This allows programmer to understand the semantics of complex system.


4.) What is Polymorphism? 

The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as “one interface, multiple methods”.


5.) What is Inheritance? 

Inheritance is the process of basing one class on another. In this process, a base class provides methods, properties, and other members to a derived class. The advantage of inheritance is that you can write and maintain code once it is in the base class and reuse it over and over in the derived classes. But the main draw back of Java is it doesn’t support multiple Inheritances; hence to over come this draw back Java provides us the Interface concept.


6.) What is Object Oriented Programming Language ? 

The language, which obeys all the basic principles of Object Oriented Programming, which are Encapsulation, Inheritance and Polymorphism, is generally known as Object Oriented Programming Language. Languages like c++ and java are some well-known Object Oriented Programming Languages.


7.) What is Encapsulation?

Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse.


8.) What is Class and Object? 

A class defines the abstract characteristics of a thing (object), including the thing’s characteristics, like its attributes or properties and the things it can do .The code for a class should be relatively self-contained. Collectively, the properties and methods defined by a class are called members. Object a particular instance of a class. Object holds the characteristics of the Class. The set of values of the attributes of a particular object is called its state.


9.) Is JAVA a completely Object Oriented Programming Language?

The answer to this question is certainly no. The reason behind this is JAVA does not obey the OOPs concept purely. Certain concepts like Operator over loading and Multiple Inheritance are not supported by JAVA. Hence JAVA is known as Partially Object Oriented Programming Language.


10) Does a class inherit the constructors of its superclass?

A class does not inherit constructors from any of its super classes.

11) If a class is declared without any access modifiers, where may the class be accessed?

A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.


12) What is the difference between shadow and override?

Overriding is used to redefines only the methods, but shadowing redefines the entire element.

13) What is multithreading?

Multithreading is the mechanism in which more than one thread run independent of each other within the process.

14) What are inner class and anonymous class?

Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors.

15) What is the difference between superclass and subclass?

A super class is a class that is inherited whereas sub class is a class that does the inheriting.

16) What is difference between overloading and overriding?

a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method.

b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass.

c) In overloading, separate methods share the same name whereas in overriding, subclass method replaces the superclass.

d) Overloading must have different method signatures whereas overriding must have same signature.

17) How many ways can an argument be passed to a subroutine?

An argument can be passed in two ways. They are Pass by Value and Passing by Reference.

Passing by value: This method copies the value of an argument into the formal parameter of the subroutine.

Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter.

18) What is the difference between procedural and object-oriented programs?

1. In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code.
2. In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code.

19) What are the advantages of OOPL?

Object oriented programming languages directly represent the real life objects. The features of OOPL as inheritance, polymorphism, encapsulation makes it powerful.

20) Can a method be overloaded based on different return type but same argument type ?

No, because the methods can be called without using their return type in which case there is ambiguity for the compiler.

21) What is Downcasting ?

Downcasting is the casting from a general to a more specific type, i.e. casting down the hierarchy.

22) Who were the three famous amigos and what was their contribution to the object community?

The Three amigos namely,
James Rumbaugh (OMT): A veteran in analysis who came up with an idea about the objects and their Relationships (in particular Associations).
Grady Booch: A veteran in design who came up with an idea about partitioning of systems into subsystems.
Ivar Jacobson (Objectory): The father of USECASES, who described about the user and system interaction.

23)What is meant by ?method-wars??

Before 1994 there were different methodologies like Rumbaugh, Booch, Jacobson, Meyer etc who followed their own notations to model the systems. The developers were in a dilemma to choose the method which best accomplishes their needs. This particular span was called as ?method-wars?

24) Differentiate Aggregation and containment?

Aggregation is the relationship between the whole and a part. We can add/subtract some properties in the part (slave) side. It won?t affect the whole part.
Best example is Car, which contains the wheels and some extra parts. Even though the parts are not there we can call it as car.
But, in the case of containment the whole part is affected when the part within that got affected. The human body is an apt example for this relationship. When the whole body dies the parts (heart etc) are died.

25) Differentiate persistent & non-persistent objects?

Persistent refers to an object?s ability to transcend time or space. A persistent object stores/saves its state in a permanent storage system with out losing the information represented by the object.
A non-persistent object is said to be transient or ephemeral. By default objects are considered as non-persistent.

26) List out some of the object-oriented methodologies.

Object Oriented Development (OOD) (Booch 1991,1994).
Object Oriented Analysis and Design (OOA/D) (Coad and Yourdon 1991).
Object Modeling Techniques (OMT) (Rumbaugh 1991).
Object Oriented Software Engineering (Objectory) (Jacobson 1992).
Object Oriented Analysis (OOA) (Shlaer and Mellor 1992).
The Fusion Method (Coleman 1991).







No comments: