Another blog:

It is easier to write an incorrect program than understand a correct one.

Monday, February 14, 2011

Object Oriented Programming Questions

==== GOOD SOURCES ====
This is a very nice post on the OOP style by using python.

[Ref] A simple but clear illustration

[Ref] a good source and good examples of OO design
Suggestions from: stackoverflow
A) Ward Cuningham's wiki (he invented wikis -- the c2.com one was the first one and is still active) has a lot of discussion, especially but not exclusively about patterns (Ward was very involved in the start of the whole idea of design patterns, as well as agile programming and quite a few more things;-). You can start here for example. It's not as coordinated and structured as you desire (actually pretty chaotic at times;-) but it can be really instructive to follow all the back-and-forth debates.
B) ObjectMentor is indeed the best resource you can find on the Internet about OOAD: objectmentor.com/resources/publishedArticles.html
C) Object Oriented Software Construction - Betrand Mayer

D) Some books that have not been mentioned:

# For OOP questions:
1) www.geekinterview.com/articles/resource/103.html
2) www.allinterview.com/Interview-Questions/OOPS.html
3) www.dotnetfunda.com/interview/ShowCatQuestion.aspx?category=42
4) www.jguide.org/oops_interview_questions_1.html
5) forums.sureshkumar.net/blogs/hero/21-oops-interview-questions-part-1.html


====== QUESTIONS =====
# Design the elevator system for a building
or Another more complicated one: Design an elevator system, improvise it to multiple elevators with single button on each floor.
[Ref] http://www.elevatorchallenge.com/

Classes : Elevator
Elevator -> Go up, Go down, serviceUser, stopElevator.
ElevatorManager has a boolean array of floors, and by walking through the array, elevator can decide whether to go up or down.
The elevator will save the floor information and current floor number. Then judge the current floor number and the number which it will go (from the user operation), and choose to go up or go down. very simple
This way we can extend the elevator system by adding new buttons very easily and each button can test individually.

First there is an elevator class. It has a direction (up, down, stand, maintenance), a current floor and a list of floor requests sorted in the direction. It receives request from this elevator.
Then there is a bank. It contains the elevators and receives the requests from the floors. These are scheduled to all active elevators (not in maintenance).
The scheduling will be like:
  • if available pick a standing elevator for this floor.
  • else pick an elevator moving to this floor.
  • else pick a standing elevator on an other floor.
  • else pick the elevator with the lowest load.
Each elevator has a set of states.
  • Maintenance: the elevator does not react to external signals (only to its own signals).
  • Stand: the elevator is fixed on a floor. If it receives a call. And the elevator is on that floor, the doors open. If it is on another floor, it moves in that direction.
  • Up: the elevator moves up. Each time it reaches a floor, it checks if it needs to stop. If so it stops and opens the doors. It waits for a certain amount of time and closes the door (unless someting is moving through them. Then it removes the floor from the request list and checks if there is another request. If so the elevator starts moving again. If not it enters the state stand.
  • Down: like up but in reverse direction.
There are additional signals:
  • alarm. The elevator stops. And if it is on a floor, the doors open, the request list is cleared.
  • door open. Opens the doors if an elevator is on a floor and not moving.
  • door closes. Closed the door if they are open.

# Design a Parking Garage

Here is a quick start to get the gears turning...
ParkingLot is a class.

ParkingSpace is a class.
ParkingSpace has an Entrance.
Entrance has a location or more specifically, distance from Entrance.

ParkingLotSign is a class.
ParkingLot has a ParkingLotSign.
ParkingLot has a finite number of ParkingSpaces.
HandicappedParkingSpace is a subclass of ParkingSpace.
RegularParkingSpace is a subclass of ParkingSpace.
CompactParkingSpace is a subclass of ParkingSpace.
ParkingLot keeps array of ParkingSpaces, and a separate array of vacant ParkingSpaces in order of distance from its Entrance.
ParkingLotSign can be told to display "full", or "empty", or "blank/normal/partially occupied" by calling .Full(), .Empty() or .Normal()

Parker is a class.
Parker can Park().
Parker can Unpark().
Valet is a subclass of Parker that can call ParkingLot.FindVacantSpaceNearestEntrance(), which returns a ParkingSpace.
Parker has a ParkingSpace.
Parker can call ParkingSpace.Take() and ParkingSpace.Vacate().
Parker calls Entrance.Entering() and Entrance.Exiting() and ParkingSpace notifies ParkingLot when it is taken or vacated so that ParkingLot can determine if it is full or not. If it is newly full or newly empty or newly not full or empty, it should change the ParkingLotSign.Full() or ParkingLotSign.Empty() or ParkingLotSign.Normal().
HandicappedParker could be a subclass of Parker and CompactParker a subclass of Parker and RegularParker a subclass of Parker. (might be overkill, actually.)
In this solution, it is possible that Parker should be renamed to be Car.

# Design a door; furniture;

# Design a client/server messaging protocol to facilitate a web-based spreadsheet program. What would the object model look like on the client side? ( regarding client/server communication)

# Design a video library

# Design a transportation system (warehouses, routes, trucks, fuel, MPG, etc)

# Design a "Subscriber - Broker - Publisher" architecture (a) running on a machine; (b) running on a cluster)
Write the code for the 3 classes.
Details: there are Events, specified by an "event type" and a blob of detailed info. Each subscriber subscribes with a Broker for a certain event type that it wants to get. Subscribers send events to the broker, and the relevant subscribers need to be notified.

Design a deck of cards, a game of chess
How might you design a program that lets people play Monopoly with each other over the internet?
Check:: http://23.latest.careercup.appspot.com/question?id=1812674

A good approach would be using class diagrams. Lets analyze the problem.
A deck is a collection of cards; it has behaviors as shuffle, pop, push, sort etc....
All the behaviors can be implemented by differently in various ways and they can change later, so we want the interface to deck of cards to be separated from implementation. A handle-body idiom!

 //NOTE: this is NOT a good diagram for understanding class diagrams.

    |                        |
Deck                  DeckData

----------                 -----------
DeckData          friend Deck

shuffle()             DeckData();
pop()               ~DeckData();


// separating the way a deck data is implemented gives an advantage of changing it without affecting interface
class DeckData{
friend class Deck;
//other data members
class Deck{
//define copy constr. and assignment oper
DeckData *d;



class Card {
Card(Suit suit, Face face) : suit(suit), face(face) {}
Card(const Card& orig) : suit(orig.suit), face(orig.face) {}
Suit getSuit() const { return suit; }
Face getFace() const { return face; }
Card() {}
Suit suit;
Face face;
friend class Deck;

class Deck {
Deck() {
int index = 0;
for (int i = 0; i < SUITS_PER_DECK; ++i) {
for (int j = 0; j < CARDS_PER_SUIT; ++j) {
index = i * CARDS_PER_SUIT + j;
cards[index].suit = (Suit) i;
cards[index].face = (Face) j;

Deck(const Deck& orig) {
for (int i = 0; i < SUITS_PER_DECK * CARDS_PER_SUIT; ++i) {
cards[i] = orig.cards[i];

void Shuffle() {
int index = 0;
while (bagSize) {
index = rand() % bagSize;
swap(cards[--bagSize], cards[index]);

static const int SUITS_PER_DECK = 4;
static const int CARDS_PER_SUIT = 13;
friend ostream & operator<<(ostream&, const Deck&);

Notes that just to make it really doing the random, note that this is also linear::
for (int i = 52; i > 1; --i) swap(deck[i - 1], deck[rand() % i]);
Ref--- http://latentcontent.net/entries/1548/anatomy-of-an-interview-question-design-a-deck-of-cards

# Design ATM machine.



- Core Classes: Financial Transaction,Account, BalanceInquiry, Withdrawal Deposit, AuthorizeSystemInteraction, BankCard
- Undecided Classes: BankCustomer (ghost - integrated with AuthorizeSystemInteraction) PIN (attribute) SavingsAccount (attribute of Account) CheckingAccount (attribute of Account) ATM (ghost -- system name) FundsAvailable (attribute) Balance (attribute) AccountHolder (synonym)
- Irrelevant Items:  These are outside the scope of the system. Many are candidates for classes in the user interface system.Transfer (not handled in first version) Receipt ReceiptPrinter Keypad Screen CashDispenser ScreenMessage Display DepositEnvelopeFailure TimeOutKey TransactionLog Printer ScreenSaver Prompt Numeric Key Key


class ATM; class ReceiptInfo;
class ATMImpl{
friend class ATM;
float getBalanceInfo(){/*
ReceiptInfo getReceiptInfo(){/*
bool deposit(float val){/*implementation*/}
bool withdraw(float val){/*implementation*/}
bool verifyPIN(int pinVal){/*implementation*/}
class ATM{
ATMImpl *d; //pointer to ATM implementation
inline float getBalance(){return d->getBalance();}
inline ReceiptInfo getReceiptInfo(){return d->getReceiptInfo();}
inline bool deposit(float val){return d->deposit(val);}
inline bool withdraw(float val){return d->withdraw(val);}
inline bool verifyPIN(int pinVal){return d->verifyPIN(pinVal);}

class ATM_GUI{
ATM atmObj;
ATM_GUI(){/*initialize GUI*/}
void printReceipt(){atmObj.
getReceiptInfo();/*more implementation*/}
void printBalance(){atmObj.
getBalance();/*more implementation*/}
inline bool verifyPIN(int pinVal){atmObj.verifyPIN(
inline bool withdraw(float amount){atmObj.withdraw(
amount);}//Atomic operation
inline bool deposit(float amount){atmObj.deposit(amount)
;}//Atomic operation
//more methods (operations)

# Data structure for a photo editor?

# Design a DVD rental store / Car Rental. Class diagram.. issues around scalability.

# Design a coffee make, class diagram

#  Given 5 classess Person, Head, Body, Arm, Leg, how will you relate all the 4 classes in a object oriented way?
From :: http://www.careercup.com/question?id=3089709

class Person
string FirstName;
string LastName;
Body bd ();

abstract class BodyPart
int length;
int getLength ()
return length;

class Arm extends BodyPart {}
class Hand extends BodyPart {}
class Leg extends BodyPart {}
class Head extends BodyPart {}

class Body
Arm left();
Arm right();
Leg left();
Leg right();
Head head();

# When an employee joins amazon , he has to go through various departments. like the admin department, finance etc. you have to create a design for this
From: http://www.careercup.com/question?id=3218685

Would be great if we have more information on the problem domain, like:

1) For what purpose does the person "go through" the various departments
2) what departments?
3) Does he have go through the departments only once?
4) What does each of those departments do with the person's data ?
5) Who will be using this design that we have been asked to create?

From the above questions we can get a general overview of how the common and uncommon functions that departments have, in addition so the peripheral (not core) functions, P1...Pn.
abstract class Department{/* Will hold the core functions or data*/}
interface P1 {}
interface Pn {}

class Dept1 extends Department implements P1, P3 {}
class Finance extends Department implements Insurable, ClaimRefunds {}
class Admin extends Department implements

Further, we need to see how might these various objects need to communicate between each other. So for the use case where a new employee joins Amazon,
HumanResources --informs --> Admin --informs--> finance
all of these "informs" can be implemented using, Publisher-Subscriber model. For other use cases, we might want the Admin or the HR dept to also act as the "Driver" class.
Also, we might want to choose to make each of these departments to be implemented as a Singleton (security and better maintainability)
This is an open ended question, we need more information for a "working" design/code.
# Design a game called "Checkers"

Discussion of this at the forum link = http://www.daniweb.com/forums/thread135355.html
Also refer to design of chess game (since its a board game too). Can broadly design Checkers taking hints from Chess game design.


# Expending the class/system, what changes to class lead to recompile?You have a class that many libraries depend on. Now you need to modify the class for one application. Which of the following changes require recompiling all libraries before it is safe to build the application?
a. add a constructor
b. add a data member
c. change destructor into virtual
d. add an argument with default value to an existing member function

A good answer/discussion can be found here( http://www.codeguru.com/ ):

Some other answer from careercup (http://www.careercup.com/question?id=3372686), not for sue correct:
a) It is safe, because nothing will be changed in the object structure. The libraries will not be aware that new constructor is available.
b) This will change the structure of the object. So, it will be problem if the size of this class used anywhere in the library. Or if the member added before any other member.
c) If the previous version of the class was not polymorphic, this will change the structure (vptr), so it is not safe, otherwise you will decrease the number of possible bugs in libraries :)
d) It is safe if this argument appended at the end of the argument list.

# what's the difference between interface and abstract class?
A good article on this can be found : http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx
While the purpose of Interface and Abstract Class are same, Abstract Class can have implementation of the method and also fields. An Interface cannot have implementations of the method or any fields. And a class can extend only one Abstract Class, but can implement multiple interfaces.
Introduction -In this article along with the demo project I will discuss Interfaces versus Abstract classes. The concept of Abstract classes and Interfaces is a bit confusing for beginners of Object Oriented programming. Therefore, I am trying to discuss the theoretical aspects of both the concepts and compare their usage. And finally I will demonstrate how to use them with C#.
Background -An Abstract class without any implementation just looks like an Interface; however there are lot of differences than similarities between an Abstract class and an Interface. Let's explain both concepts and compare their similarities and differences.
What is an Abstract Class?An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.
What is an Interface? An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn't support multiple inheritance, interfaces are used to implement multiple inheritance.
Both Together -- When we create an interface, we are basically creating a set of methods without any implementation that must be overridden by the implemented classes. The advantage is that it provides a way for a class to be a part of two classes: one from inheritance hierarchy and one from the interface.When we create an abstract class, we are creating a base class that might have one or more completed methods but at least one or more methods are left uncompleted and declared abstract. If all the methods of an abstract class are uncompleted then it is same as an interface. The purpose of an abstract class is to provide a base class definition for how a set of derived classes will work and then allow the programmers to fill the implementation in the derived classes.

====== Assigning Responsibilities

Focus on the what, not the how.
Grady Booch: "When considering the semantics of classes and objects, there is the tendency to explain how things work; the proper response is 'I don't care.'"
False semantic distinction among responsibilities may rob us of the ability to use inheritance and polymorphism to advantage.
Think simple. Factor out complexity.
If most the responsibilities fall to one or two classes, then the system is probably biased toward a procedural perspective -- does not take advantage of polymorphism and encapsulation. Many of the classes are reduced to "records" -- simply knowing about the information they hold.
Give each class a distinct role in the system. Strive to make each class a well-defined, complete, cohesive abstraction. Such a class has higher probability of being reused.
Use abstraction to advantage.
Build hierarchies of classes. Abstract the essence of related classes by identifying where they have common responsibilities -- where they do the same thing, but do it differently -- same "what", different "how".
That is, look for opportunities for the classes to use polymorphism to implement the same responsibility differently.
The new parent classes may be abstract classes. That is, no actual objects may ever exist of that type. The abstract class exists to link together similar concrete types of objects.

=== Below are some questions, briefly but sumarizing ===
1. List few features of object oriented programming.Object oriented programming features:
Follows bottom up approach.
Emphasis is on data.
Programs are divided into objects.
Functions and data are bound together.
Communication is done through objects.
Data is hidden.

2. List features of procedure oriented programming.Procedure oriented programming features:
Follows top down approach.
Emphasis is on procedure.
Programs are divided into functions.
Data moves around freely.

3. What are the basic concepts of OOPs?The following are the basic concepts of OOPs:
Classes, Objects, Data abstraction and encapsulation, Polymorphism, Inheritance, Message Passing, and Dynamic Binding.

4. What is a class?
Class is an entity which consists of member data and member functions which operate on the member data bound together.

5. What is an object?
Objects are instances of classes. Class is a collection of similar kind of objects. When a class is created it doesn’t occupy any memory, but when instances of class is created i.e., when objects are created they occupy memory space.

6. What is data encapsulation?
Wrapping up of member data and member functions together in a class is called data encapsulation.

7. What is data abstraction?
Data abstraction refers to the act of providing only required features and hiding all the non-essential details for usage.

8. What are ADTs?
ADTs stand for abstract data types. Classes which provide data abstraction are referred to as ADTs.

9. What is inheritance?
The process of inheriting the properties of one object by another object is called inheritance.

10. What is polymorphism?
The feature of exhibiting many forms is called polymorphism.

11. What are the steps involved in message passing?The following are the steps involved in message passing:
Creating classes, creating objects, and creating communication between objects.

12. What is dynamic binding?
The feature that the associated code of a given function is not known till run time is called dynamic binding.

13. What are the advantages of OOP?Data hiding helps create secure programs.
Redundant code can be avoided by using inheritance.
Multiple instances of objects can be created.
Work can be divided easily based on objects.
Inheritance helps to save time and cost.
Easy upgrading of systems is possible using object oriented systems.

14. Give an example for object based programming language.
Ada is an example for object based programming language.

15. Write the features of object based programming language.
Data hiding, data encapsulation, operator overloading and automatic initialization and clear up of objects are the important features exhibited by object based programming languages.

1. Give some examples of pure object oriented languages.
Eiffel, Java, Simula, Smalltalk are some pure object oriented languages.

2. List the areas of applications of object oriented programming?The following are few areas of applications of object oriented programming:
CAD/CAM systems
Office automation and decision support systems
Object oriented databases
Real time systems
Simulation and modelling.

3. What is the difference between structure in C and class in C++?
In C structure, by default the members are public. Whereas in C++ class, by default the members are private.

4. What are the sections in class specification?
There are basically two sections in class specification: Class declaration and class function definition.

5. Write the syntax for class declaration.

6. What are class members?
The variables and functions used in a class are called class members.

7. What are the visibility labels?
Private, public and protected are the visibility labels.
8. Give an example for class declaration.
class area
int r;
void get(int r);
void area(int r);

9. How does a class provide data hiding?
Data hiding is provided by a class by the use of visibility label private which allows only the member functions to access the data declared as private.

10. What are the ways of defining member functions?
Member functions can be defined in two ways, one inside the class definition and the other outside the class definition.

11. Write the syntax for defining member functions inside the class.Syntax:
return type

12. Write the syntax for defining member functions outside the class.Syntax:
return type :: (arguments)

13. What does member functions represent?
Member functions of a class represent the behaviour of a class.

14. Write the syntax for making an outside function inline?Member functions can be made inline even though we define them outside the class by using the keyword inline.
return type (arguments);
inline return type :: (arguments)

15. What is an object?

RE: Explain the different forms of Polymorphism.
Uses of Inheritance

The classic examples of an inheritance hierarchy are borrowed from animal and plant taxonomies. For example, there could a class corresponding to the Pinaceae (pine) family of trees. Its subclasses could be Fir, Spruce, Pine, Hemlock, Tamarack, DouglasFir, and TrueCedar, corresponding to the various genera that make up the family.

The Pine class might have SoftPine and HardPine subclasses, with WhitePine, SugarPine, and BristleconePine as subclasses of SoftPine, and PonderosaPine, JackPine, MontereyPine, and RedPine as subclasses of HardPine.
There's rarely a reason to program a taxonomy like this, but the analogy is a good one. Subclasses tend to specialize a superclass or adapt it to a special purpose, much as a species specializes a genus.

Here are some typical uses of inheritance:

Reusing code. If two or more classes have some things in common but also differ in some ways, the common elements can be put in an a single class definition that the other classes inherit. The common code is shared and need only be implemented once.

For example, Faucet, Valve, and WaterPipe objects, defined for the program that models water use, all need a connection to a water source and they all should be able to record the rate of flow. These commonalities can be encoded once, in a class that the Faucet, Valve, and WaterPipe classes inherit from. A Faucet can be said to be a kind of Valve, so perhaps the Faucet class would inherit most of what it is from Valve, and add very little of its own.

Setting up a protocol. A class can declare a number of methods that its subclasses are expected to implement. The class might have empty versions of the methods, or it might implement partial versions that are to be incorporated into the subclass methods. In either case, its declarations establish a protocol that all its subclasses must follow.

When different classes implement similarly named methods, a program is better able to make use of polymorphism in its design. Setting up a protocol that subclasses must implement helps enforce these naming conventions.

Delivering generic functionality. One implementor can define a class that contains a lot of basic, general code to solve a problem, but doesn't fill in all the details. Other implementors can then create subclasses to adapt the generic class to their specific needs. For example, the Appliance class in the program that models water use might define a generic water-using device that subclasses would turn into specific kinds of appliances.

Inheritance is thus both a way to make someone else's programming task easier and a way to separate levels of implementation.

Making slight modifications. When inheritance is used to deliver generic functionality, set up a protocol, or reuse code, a class is devised that other classes are expected to inherit from. But you can also use inheritance to modify classes that aren't intended as superclasses. Suppose, for example, that there's an object that would work well in your program, but you'd like to change one or two things that it does. You can make the changes in a subclass.

Previewing possibilities. Subclasses can also be used to factor out alternatives for testing purposes. For example, if a class is to be encoded with a particular user interface, alternative interfaces can be factored into subclasses during the design phase of the project. Each alternative can then be demonstrated to potential users to see which they prefer. When the choice is made, the selected subclass can be reintegrated into its superclass.

===== OOPS Interview Questions= = = =
From :http://www.coders2020.com/interview/oops_interview_questions
1) Explain the rationale behind Object Oriented concepts?
Object oriented concepts form the base of all modern programming languages. Understanding the basic concepts of object-orientation helps a developer to use various modern day programming languages, more effectively.
2) Explain about Object oriented programming?
Object oriented programming is one of the most popular methodologies in software development. It offers a powerful model for creating computer programs. It speeds the program development process, improves maintenance and enhances reusability of programs.
3) Explain what is an object?
An object is a combination of messages and data. Objects can receive and send messages and use messages to interact with each other. The messages contain information that is to be passed to the recipient object.
4) Explain the implementation phase with respect to OOP?
The design phase is followed by OOP, which is the implementation phase. OOP provides specifications for writing programs in a programming language. During the implementation phase, programming is done as per the requirements gathered during the analysis and design phases.
5) Explain about the Design Phase?
In the design phase, the developers of the system document their understanding of the system. Design generates the blue print of the system that is to be implemented. The first step in creating an object oriented design is the identification of classes and their relationships.
6) Explain about a class?
Class describes the nature of a particular thing. Structure and modularity is provided by a Class in object oriented programming environment. Characteristics of the class should be understandable by an ordinary non programmer and it should also convey the meaning of the problem statement to him. Class acts like a blue print.

7) Explain about instance in object oriented programming?
Every class and an object have an instance. Instance of a particular object is created at runtime. Values defined for a particular object define its State. Instance of an object explains the relation ship between different elements.
8) Explain about inheritance?
Inheritance revolves around the concept of inheriting knowledge and class attributes from the parent class. In general sense a sub class tries to acquire characteristics from a parent class and they can also have their own characteristics. Inheritance forms an important concept in object oriented programming.
9) Explain about multiple inheritance?
Inheritance involves inheriting characteristics from its parents also they can have their own characteristics. In multiple inheritance a class can have characteristics from multiple parents or classes. A sub class can have characteristics from multiple parents and still can have its own characteristics.
10) Explain about encapsulation?
Encapsulation passes the message without revealing the exact functional details of the class. It allows only the relevant information to the user without revealing the functional mechanism through which a particular class had functioned.
11) Explain about abstraction?
Abstraction simplifies a complex problem to a simpler problem by specifying and modeling the class to the relevant problem scenario. It simplifies the problem by giving the class its specific class of inheritance. Composition also helps in solving the problem to an extent.
12) Explain the mechanism of composition?
Composition helps to simplify a complex problem into an easier problem. It makes different classes and objects to interact with each other thus making the problem to be solved automatically. It interacts with the problem by making different classes and objects to send a message to each other.
13) Explain about polymorphism?
Polymorphism helps a sub class to behave like a parent class. When an object belonging to different data types respond to methods which have a same name, the only condition being that those methods should perform different function.
14) Explain about overriding polymorphism?
Overriding polymorphism is known to occur when a data type can perform different functions. For example an addition operator can perform different functions such as addition, float addition etc. Overriding polymorphism is generally used in complex projects where the use of a parameter is more.
15) Explain about object oriented databases?
Object oriented databases are very popular such as relational database management systems. Object oriented databases systems use specific structure through which they extract data and they combine the data for a specific output. These DBMS use object oriented languages to make the process easier.
16) Explain about parametric polymorphism?
Parametric polymorphism is supported by many object oriented languages and they are very important for object oriented techniques. In parametric polymorphism code is written without any specification for the type of data present. Hence it can be used any number of times.
17) What are all the languages which support OOP?
There are several programming languages which are implementing OOP because of its close proximity to solve real life problems. Languages such as Python, Ruby, Ruby on rails, Perl, PHP, Coldfusion, etc use OOP. Still many languages prefer to use DOM based languages due to the ease in coding.


1) Explain what is object oriented programming language?
Object oriented programming language allows concepts such as modularity, encapsulation, polymorphism and inheritance. Simula is credited to be the first object oriented language. Objects are said to be the most important part of object oriented language. Concept revolves around making simulation programs around an object.
2) Name some languages which have object oriented language and characteristics?
Some of the languages which have object oriented languages present in them are ABAP, ECMA Script, C++, Perl, LISP, C#, Tcl, VB, Ruby, Python, PHP, etc. Popularity of these languages has increased considerably as they can solve complex problems with ease.
3) Explain about UML?
UML or unified modeling language is regarded to implement complete specifications and features of object oriented language. Abstract design can be implemented in object oriented programming languages. It lacks implementation of polymorphism on message arguments which is a OOPs feature.
4) Explain the meaning of object in object oriented programming?
Languages which are called as object oriented almost implement everything in them as objects such as punctuations, characters, prototypes, classes, modules, blocks, etc. They were designed to facilitate and implement object oriented methods.
5) Explain about message passing in object oriented programming?
Message passing is a method by which an object sends data to another object or requests other object to invoke method. This is also known as interfacing. It acts like a messenger from one object to other object to convey specific instructions.
6) State about Java and its relation to Object oriented programming?
Java is widely used and its share is increasing considerably which is partly due to its close resemblance to object oriented languages such as C and C++. Code written in Java can be transported to many different platforms without changing it. It implements virtual machine.
7) What are the problems faced by the developer using object oriented programming language?
These are some of the problems faced by the developer using object oriented language they are: -
1) Object oriented uses design patterns which can be referred to as anything in general.
2) Repeatable solution to a problem can cause concern and disagreements and it is one of the major problems in software design.
8) State some of the advantages of object oriented programming?
Some of the advantages of object oriented programming are as follows: -
1) A clear modular structure can be obtained which can be used as a prototype and it will not reveal the mechanism behind the design. It does have a clear interface.
2) Ease of maintenance and modification to the existing objects can be done with ease.
3) A good framework is provided which facilitates in creating rich GUI applications.
9) Explain about inheritance in OOPS?
Objects in one class can acquire properties of the objects in other classes by way of inheritance. Reusability which is a major factor is provided in object oriented programming which adds features to a class without modifying it. New class can be obtained from a class which is already present.
10) Explain about the relationship between object oriented programming and databases?
Object oriented programming and relational database programming are almost similar in software engineering. RDBMS will not store objects directly and that’s where object oriented programming comes into play. Object relational mapping is one such solution.
11) Explain about a class in OOP?
In Object oriented programming usage of class often occurs. A class defines the characteristics of an object and its behaviors. This defines the nature and functioning of a specified object to which it is assigned. Code for a class should be encapsulated.

12) Explain the usage of encapsulation?
Encapsulation specifies the different classes which can use the members of an object. The main goal of encapsulation is to provide an interface to clients which decrease the dependency on those features and parts which are likely to change in future. This facilitates easy changes to the code and features.
13) Explain about abstraction?
Abstraction can also be achieved through composition. It solves a complex problem by defining only those classes which are relevant to the problem and not involving the whole complex code into play.
14) Explain what a method is?
A method will affect only a particular object to which it is specified. Methods are verbs meaning they define actions which a particular object will perform. It also defines various other characteristics of a particular object.
15) Name the different Creational patterns in OO design?
There are three patterns of design out of which Creational patterns play an important role the various patterns described underneath this are: -
1) Factory pattern
2) Single ton pattern
3) Prototype pattern
4) Abstract factory pattern
5) Builder pattern
16) Explain about realistic modeling?
As we live in a world of objects, it logically follows that the object oriented approach models the real world accurately. The object oriented approach allows you to identify entities as objects having attributes and behavior.
17) Explain about the analysis phase?
The anlaysis or the object oriented analysis phase considers the system as a solution to a problem in its environment or domain. Developer concentrates on obtaining as much information as possible about the problem. Critical requirements needs to be identified.
♥ ¸¸.•*¨*•♫♪♪♫•*¨*•.¸¸♥

1 comment: