Thursday, November 7, 2013

Interview Questions in OOP's

Basic Interview Questions in OOP's

Define OOP's Programming?

Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.

The programming challenge was seen as how to write the logic, not how to define the data. Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).

Define object based language?

The term "object-based language" may be used in a technical sense to describe any programming language that uses the idea of encapsulating state and operations inside "objects". Object-based languages need not support inheritance or subtyping, but those that do are also said to be "object-oriented". Object-based languages that do not support inheritance or subtyping are usually not considered to be true object-oriented languages.

Few examples of object-oriented languages are Smalltalk, C++, Python, Ruby, Java, C#. An example of a language that is object-based but not object-oriented is Visual Basic (VB). VB supports both objects and classes, but not inheritance, so it does not qualify as object-oriented.

Define procedure oriented language?

The procedure oriented programming (POP) approach focuses on creating and ordering procedures or a block of code keeping in mind to accomplish a specific job. The key features of this kind of approach are: use of procedures, sequencing of procedures and sharing global data.
characteristics of Procedure Oriented Language are:
IT uses Top Down Programming approach in program design. The main task is divided into sub task and functions.

All function share the data through global variable.

Data is less secure as it is available to all functions.

Procedural Language gives more importance to instruction and less importance to data.

List the disadvantage of Procedure oriented programming?

No security for data. If we declare a variable before main function then it can be accessed freely from any function present in the program.

No better memory management.

Difficult to implement today's client requirements.

No structure or code reusability. Hence time of development, testing and length of program increases.

As length of application increases it causes slow performance.

Code maintenance and enhancements are difficult.

No proper way method for Exception handling.

What are the advantages of a object oriented language over the procedural language?
In object oriented language everything is object and dynamic where as in procedural you have to follow sequence for programs and implementation.

Procedural language does not have extra packaging like object oriented.

If you wish to save a lot of code through reusable components and frameworks and designs, it's best to use an object oriented paradigm in your solution.
List the Advantages of an object-oriented language in organization?
These are some of the major advantages of OOP.
Simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear.

Modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system.

Modifiability: it is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods.

Extensibility: adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones.

Maintainability: objects can be maintained separately, making locating and fixing problems easier.

Re-usability: objects can be reused in different programs.
State the important object oriented features
Some of the important object oriented features are namely:
Objects

Classes

Inheritance

Data Abstraction

Data Encapsulation

Polymorphism

Overloading

Reusability

What is inheritance?

Inheritance is the process of forming a new class from an existing class or base class. The base class is also known as parent class or super class, The new class that is formed is called derived class. Derived class is also known as a child class or sub class. Inheritance helps in reducing the overall code size of the program,by reusing the parent class members. 

Whats is data abstraction?
Data Abstraction increases the power of programming language by creating user defined data types. Data Abstraction also represents the needed information in the program without presenting the details. Class is a construct for abstract data types (ADT).

What is Data Encapsulation?

Data Encapsulation combines data and functions into a single unit called Class. When using Data Encapsulation, data is not accessed directly; it is only accessible through the functions present inside the class. Data Encapsulation enables the important concept of data hiding possible. 

Whats is Polymorphism?

Polymorphism allows routines to use variables of different types at different times. An operator or function can be given different meanings or functions. Polymorphism refers to a single function or multi-functioning operator performing in different ways. 

Whats is Reusability?

This term refers to the ability for multiple programmers to use the same written and debugged existing class of data. This is a time saving device and adds code efficiency to the language. Additionally, the programmer can incorporate new features to the existing class, further developing the application and allowing users to achieve increased performance. This time saving feature optimizes code, helps in gaining secured applications and facilitates easier maintenance on the application.

What is overloading?

In programming languages, a feature that allows an object to have different meanings depending on its context. The term is used most often in reference to operators that can behave differently depending on the data type, or class, of the operands. For example, x+y can mean different things depending on whether x and y are simple integers or complex data structures.

Not all programming languages support overloading but it is a feature of most object-oriented languages, including C++ and Java. Overloading is one type of polymorphism.

What is Method overriding?

Method overriding, in object oriented programming , is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes. The implementation in the subclass overrides (replaces) the implementation in the superclass by providing a method that has same name, same parameters or signature, and same return type as the method in the parent class.[1] The version of a method that is executed will be determined by the object that is used to invoke it. If an object of a parent class is used to invoke the method, then the version in the parent class will be executed, but if an object of the subclass is used to invoke the method, then the version in the child class will be executed

No comments: