SlideShare a Scribd company logo
1 of 9
Download to read offline
1
Object-oriented programming (OOP) is a computer science term used to characterize a programming
language that began development in the 1960’s. The term ‘object-oriented programming’ was originally
coined by Xerox PARC to designate a computer application that describes the methodology of using
objects as the foundation for computation. By the 1980’s, OOP rose to prominence as the programming
language of choice, exemplified by the success of C++. Currently, OOPs such as Java, J2EE, C++, C#,
Visual Basic.NET, Python and JavaScript are popular OOP programming languages that any career-
oriented Software Engineer or developer should be familiar with.
OOP is widely accepted as being far more flexible than other computer programming languages. OOPs
use three basic concepts as the fundamentals for the programming language: classes, objects and
methods. Additionally, Inheritance, Abstraction, Polymorphism, Event Handling and Encapsulation.
Common Questions & Answers
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 behavior.
3) What is an Object?
Object is an instance of a class. It has state, behavior and identity. It is also called as an instance of a
class.
4) What is an Instance?
An instance has state, behavior and identity. The structure and behavior 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 focusing on the essential characteristics of an object. Abstraction is one of the
fundamental elements of the object model.
7) What is meant by Encapsulation?
Encapsulation is the process of compartmentalizing the elements of an abstraction that defines the
structure and behavior. 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 behavior defined
in another class. This is called Single Inheritance. If a class shares the structure or behavior 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 generalized superclasses.
Object Oriented Programming (Interview Questions & Answers)
Collected from different websites. Use for non-commercial purpose.
Sohail Basheer
Lecturer- Computer Science (visiting)
Department of Computer Science & IT (Evening Program)
Federal Urdu University Arts, Science & Technology
Gulshan Campus Karachi
2
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 behavior, typically by implementing its abstract
operations.
11) What is an Interface?
Interface is an outside view of a class or object which emphasizes its abstraction while hiding its
structure and secrets of its behavior.
12) What is a base class?
Base class is the most generalized class in a class structure. Most applications have such root
classes. In Java, Object is the base class for all classes.
13) What is a subclass?
Subclass is a class that inherits from one or more classes
14) What is a superclass?
superclass is a class from which another class inherits.
15) What is a constructor?
Constructor is an operation that creates an object and/or initializes its state.
16) 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.
17) What is meant by Binding?
Binding denotes association of a name with a class.
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) Define Modularity?
Modularity is the property of a system that has been decomposed into a set of cohesive and loosely
coupled modules.
21) What is meant by Persistence?
Persistence is the property of an object by which its existence transcends space and time.
22) What is collaboration?
Collaboration is a process whereby several objects cooperate to provide some higher level behavior.
3
23) In Java, How to make an object completely encapsulated?
All the instance variables should be declared as private and public getter and setter methods should
be provided for accessing the instance variables.
24) How is polymorphism achieved in java?
Inheritance, Overloading and Overriding are used to achieve Polymorphism in java
What is a class?
Class is concrete representation of an entity. It represents a group of objects, which hold similar attributes
and behavior. It provides Abstraction and Encapsulations.
What is an Object? What is Object Oriented Programming?
Object represents/resembles a Physical/real entity. An object is simply something you can give a name.
Object Oriented Programming is a Style of programming that represents a program as a system of
objects and enables code-reuse.
What is Encapsulation?
Encapsulation is binding of attributes and behaviors. Hiding the actual implementation and exposing the
functionality of any object. Encapsulation is the first step towards OOPS, is the procedure of covering up
of data and functions into a single unit (called class). Its main aim is to protect the data from out side
world
What is Abstraction?
Hiding the complexity. It is a process of defining communication interface for the functionality and hiding
rest of the things.
What is Overloading?
Adding a new method with the same name in same/derived class but with different number/types of
parameters. It implements Polymorphism.
What is Overriding
A process of creating different implementation of a method having a same name as base class, in a
derived class. It implements Inheritance.
What is Shadowing?
When the method is defined as Final/sealed in base class and not override able and we need to provide
different implementation for the same. This process is known as shadowing, uses shadows/new keyword.
What is Inheritance?
It is a process of acquiring attributes and behaviors from another object (normally a class or interface).
What is an Abstract class?
An abstract class is a special kind of class that cannot be instantiated. It normally contains one or more
abstract methods or abstract properties. It provides body to a class.
4
What is an Interface?
An interface has no implementation; it only has the signature or in other words, just the definition of the
methods without the body.
What is Polymorphism?
Mean by more than one form. Ability to provide different implementation based on different number/type
of parameters.
What is Pure-Polymorphism?
When a method is declared as abstract/virtual method in a base class and which is overridden in a base
class. If we create a variable of a type of a base class and assign an object of a derived class to it, it will
be decided at a run time, which implementation of a method is to be called. This is known as Pure-
Polymorphism or Late-Binding.
What is a Constructor?
A special function Always called whenever an instance of the class is created.
• Same name as class name
• No return type
• Automatically call when object of class is created
• Used to initialize the members of class
class Test
{
int a,b;
Test()
{
a=9;
b=8;
}
};
Here Test() is the constructor of Class Test.
What is copy constructor?
Constructor which initializes it's object member variables ( by shallow copying) with
another object of the same class. If you don't implement one in your class then compiler
implements one for you.
for example:
Test t1(10); // calling Test constructor
5
Test t2(t1); // calling Test copy constructor
Test t2 = t1;// calling Test copy constructor
Copy constructors are called in following cases:
• when a function returns an object of that class by value
• when the object of that class is passed by value as an argument to a function
• when you construct an object based on another object of the same class
• When compiler generates a temporary object
What is default Constructor?
Constructor with no arguments or all the arguments has default values. In Above Question Test() is a
default constructor
What is a Destructor?
A special method called by GC. just before object is being reclaimed by GC.
How a base class method is hidden?
Hiding a base class method by declaring a method in derived class with keyword new. This will override
the base class method and old method will be suppressed.
What Command is used to implement properties in C#?
get & set access modifiers are used to implement properties in c#.
What is method overloading?
Method overloading is having methods with same name but carrying different signature, this is useful
when you want a method to behave differently depending upon a data passed to it.
Can constructors have parameters?
Yes, constructors can have parameters. so we can overload it.
What are Static Assembly and Dynamic Assembly?
Static assemblies can include .NET Framework types (interfaces and classes) as well as resources for
the assembly (bitmaps, JPEG files, resource files, and so forth). Static assemblies are stored on disk.
Dynamic assemblies run directly from memory and are not saved to disk before execution.
Describe the functionality of an assembly.
It is the smallest unit that has version control. All types and resources in the same assembly are
versioned as a unit and support side by side execution. Assemblies contain the metadata and other
identities which allow the common language runtime to execute. They are the boundaries providing the
type check. They the unit where security permissions are requested and granted.
What is serialization?
Serialization is the process of converting an object into a stream of bytes. De-serialization is the opposite
process of creating an object from a stream of bytes. Serialization/De-serialization is mostly used to
transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database). There are two
separate mechanisms provided by the .NET class library for serialization - XmlSerializer and
6
SoapFormatter and BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses
SoapFormatter/BinaryFormatter for remoting.
What are C++ storage classes?
auto:the default. Variables are automatically created and initialized when they are defined
and are destroyed at the end of the block containing their definition(when they are out of scope). They are
not visible outside that block
auto int x;
int y; Both are same statement. auto is defalt
register:a type of auto variable. a suggestion to the compiler to use a CPU register for
performance(Generally Used in loops)
static:a variable that is known only within the function that contains its definition but is never destroyed
and retains its value between calls to that function. It exists from the time the program begins execution
void example()
{
static int x = 0; // static variable
x++;
cout << x <<endl;
}
If this function is called 10 times, the output will be 1,2,3,4..etc., The value of the variable x is preserved
through function calls. If this static variable is declared as a member of a class, then it will preserve the
value for all the objects of the class.i.e, one copy of this data variable will be shared by all objects of the
class
Note: if we will declare variable like this int x=0; in the above example. then it will print 1 every it will be
called extern:a static variable whose definition and placement is determined when all object and librar
modules are combined (linked) to form the executable code file. It can be visible
outside the file where it is defined.
What is RTTI?
Runtime type identification (RTTI) lets you find the dynamic type of an object when you have only a
pointer or a reference to the base type. RTTI is the official way in standard C++ to discover the type of an
object and to convert the type of a pointer or reference (that is, dynamic typing). The need came from
practical experience with C++. RTTI replaces many homegrown versions with a solid, consistent
approach.
What is friend function?
As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its
private and protected members. A friend function is not a member of the class. But it must be listed in the
class definition.
7
What is a scope resolution operator?
A scope resolution operator (::), can be used to define the member functions of a class outside the class.
What do you mean by pure virtual functions?
A pure virtual member function is a member function that the base class forces derived classes to
provide. Normally these member functions have no implementation. Pure virtual functions are equated to
zero. class Shape
{
public: virtual void draw() = 0;
};
What is the difference between declaration and definition?
The declaration tells the compiler that at some later point we plan to present the definition of this
declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.:
void stars ()
{
for(int j=10; j > =0; j--) //function body
cout << *; cout << endl;
}
What are the advantages of inheritance?
It permits code reusability. Reusability saves time in program development. It encourages the reuse of
proven and debugged high-quality software, thus reducing problem after a system becomes functional.
Association
Association is a relationship where all object have their own lifecycle and there is no owner. Let’s take an
example of Teacher and Student. Multiple students can associate with single teacher and single student
can associate with multiple teachers but there is no ownership between the objects and both have their
own lifecycle. Both can create and delete independently.
Aggregation
Aggregation is a specialize form of Association where all object have their own lifecycle but there is
ownership and child object can not belongs to another parent object. Let’s take an example of
Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the
department teacher object will not destroy. We can think about “has-a” relationship.
8
Composition
Composition is again specialize form of Aggregation and we can call this as a “death” relationship. It is a
strong type of Aggregation. Child object dose not have their lifecycle and if parent object deletes all child
object will also be deleted. Let’s take again an example of relationship between House and rooms. House
can contain multiple rooms there is no independent life of room and any room can not belongs to two
different house if we delete the house room will automatically delete. Let’s take another example
relationship between Questions and options. Single questions can have multiple options and option can
not belong to multiple questions. If we delete questions options will automatically delete.
How to Implement (Code Example)
Class Circle
{
Point point;
};
Class Point
{
int x;
int y; };
Here Circle is composed of Point.... you can't make a circle without point (Strong dependency)
Distinguish between the terms fatal error and non–fatal error. Why might you prefer to experience
a fatal error rather than a non–fatal error?
A fatal error causes a program to terminate prematurely. A nonfatal error occurs when the logic of the
program is incorrect, and the program does not work properly. A fatal error is preferred for debugging
purposes. A fatal error immediately lets you know there is a problem with the program, whereas a
nonfatal error can be subtle and possibly go undetected.
What are virtual functions? Describe a circumstance in which virtual functions would be
appropriate
Virtual functions are functions with the same function prototype that are defined throughout a class
hierarchy. At least the base class occurrence of the function is preceded by the keyword virtual. Virtual
functions are used to enable generic processing of an entire class hierarchy of objects through a base
class pointer. For example, in a shape hierarchy, all shapes can be drawn. If all shapes are derived from
a base class Shape which contains a virtual draw function, then generic processing of the hierarchy can
be performed by calling every shape’s draw generically through a base class Shape pointer.
Given that constructors cannot be virtual, describe a scheme for how you might achieve a similar
effect
Create a virtual function called initialize that the constructor invokes.
9
How is it that polymorphism enables you to program “in the general” rather than “in the specific.”
Discuss the key advantages of programming “in the general.”
Polymorphism enables the programmer to concentrate on the processing of common operations that are
applied to all data types in the system without going into the individual details of each data type. The
general processing capabilities are separated from the internal details of each type.
Discuss the problems of programming with switch logic. Explain why polymorphism is an
effective alternative to using switch logic.
The main problem with programming using the switch structure is extensibility and maintainability of the
program. A program containing many switch structures is difficult to modify. Many, but not necessarily all,
switch structures will need to add or remove cases for a specified type. Note: switch logic includes if/else
structures which are more flexible than the switch structure.
Distinguish between static binding and dynamic binding. Explain the use of virtual functions and
the vtable in dynamic binding.
Static binding is performed at compile-time when a function is called via a specific object or via a pointer
to an object. Dynamic binding is performed at run-time when a virtual function is called via a base class
pointer to a derived class object (the object can be of any derived class). The virtual functions table
(vtable) is used at run-time to enable the proper function to be called for the object to which the base
class pointer "points". Each class containing virtual functions has its own vtable that specifies where the
virtual functions for that class are located. Every object of a class with virtual functions contains a hidden
pointer to the class’s vtable. When a virtual function is called via a base class pointer, the hidden pointer
is dereferenced to locate the vtable, then the vtable is searched for the proper function call.
Distinguish between inheriting interface and inheriting implementation. How do inheritance
hierarchies designed for inheriting interface differ from those designed for inheriting
implementation?
When a class inherits implementation, it inherits previously defined functionality from another class. When
a class inherits interface, it inherits the definition of what the interface to the new class type should be.
The implementation is then provided by the programmer defining the new class type. Inheritance
hierarchies designed for inheriting implementation are used to reduce the amount of new code that is
being written. Such hierarchies are used to facilitate software reusability. Inheritance hierarchies designed
for inheriting interface are used to write programs that perform generic processing of many class types.
Such hierarchies are commonly used to facilitate software extensibility (i.e., new types can be added to
the hierarchy without changing the generic processing capabilities of the program.)
Distinguish between virtual functions and pure virtual functions
A virtual function must have a definition in the class in which it is declared. A pure virtual function does
not provide a definition. Classes derived directly from the abstract class must provide definitions for the
inherited pure virtual functions in order to avoid becoming an abstract base class

More Related Content

What's hot

Introduction to oop using java
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java omeed
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented ProgrammingAida Ramlan II
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-pptMayank Kumar
 
Lecture01 object oriented-programming
Lecture01 object oriented-programmingLecture01 object oriented-programming
Lecture01 object oriented-programmingHariz Mustafa
 
Interview Questions and Answers for Java
Interview Questions and Answers for JavaInterview Questions and Answers for Java
Interview Questions and Answers for JavaGaruda Trainings
 
Java object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - BrainsmartlabsJava object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - Brainsmartlabsbrainsmartlabsedu
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyaySaurabh Upadhyay
 
Most Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerMost Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerTOPS Technologies
 
Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objectsrahulsahay19
 
Object-oriented Programming in Python
Object-oriented Programming in PythonObject-oriented Programming in Python
Object-oriented Programming in PythonJuan-Manuel Gimeno
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascriptUsman Mehmood
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Javawiradikusuma
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Uzair Salman
 
How would you implement multiple inheritance in java
How would you implement multiple inheritance in javaHow would you implement multiple inheritance in java
How would you implement multiple inheritance in javaTyagi2636
 
OOP programming
OOP programmingOOP programming
OOP programminganhdbh
 

What's hot (20)

Introduction to oop using java
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java
 
OOPS in Java
OOPS in JavaOOPS in Java
OOPS in Java
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented Programming
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-ppt
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Lecture01 object oriented-programming
Lecture01 object oriented-programmingLecture01 object oriented-programming
Lecture01 object oriented-programming
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Interview Questions and Answers for Java
Interview Questions and Answers for JavaInterview Questions and Answers for Java
Interview Questions and Answers for Java
 
Java object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - BrainsmartlabsJava object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - Brainsmartlabs
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh Upadhyay
 
Most Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerMost Asked Java Interview Question and Answer
Most Asked Java Interview Question and Answer
 
Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objects
 
OOP
OOPOOP
OOP
 
Java basics
Java basicsJava basics
Java basics
 
Object-oriented Programming in Python
Object-oriented Programming in PythonObject-oriented Programming in Python
Object-oriented Programming in Python
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascript
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
 
How would you implement multiple inheritance in java
How would you implement multiple inheritance in javaHow would you implement multiple inheritance in java
How would you implement multiple inheritance in java
 
OOP programming
OOP programmingOOP programming
OOP programming
 

Similar to Object oriented programming

Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview QuestionsKuntal Bhowmick
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfArpitaJana28
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.Questpond
 
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...AnanthReddy38
 
Java OOPs Concepts.docx
Java OOPs Concepts.docxJava OOPs Concepts.docx
Java OOPs Concepts.docxFredWauyo
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and oodthan sare
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerJeba Moses
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented PrinciplesEmprovise
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingAmit Soni (CTFL)
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionPritom Chaki
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming conceptPina Parmar
 

Similar to Object oriented programming (20)

Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
 
01. design pattern
01. design pattern01. design pattern
01. design pattern
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Ooad 2
Ooad 2Ooad 2
Ooad 2
 
Ooad
OoadOoad
Ooad
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
Top 20 Core Java Interview Questions & Answers for Selenium Automation Testin...
 
2.oop concept
2.oop concept2.oop concept
2.oop concept
 
Oops
OopsOops
Oops
 
Java OOPs Concepts.docx
Java OOPs Concepts.docxJava OOPs Concepts.docx
Java OOPs Concepts.docx
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and ood
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
 
OOPS ABAP.docx
OOPS ABAP.docxOOPS ABAP.docx
OOPS ABAP.docx
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 
Core_Java_Interview.pdf
Core_Java_Interview.pdfCore_Java_Interview.pdf
Core_Java_Interview.pdf
 
Intervies
InterviesIntervies
Intervies
 

More from mustafa sarac

Uluslararasilasma son
Uluslararasilasma sonUluslararasilasma son
Uluslararasilasma sonmustafa sarac
 
Real time machine learning proposers day v3
Real time machine learning proposers day v3Real time machine learning proposers day v3
Real time machine learning proposers day v3mustafa sarac
 
Latka december digital
Latka december digitalLatka december digital
Latka december digitalmustafa sarac
 
Axial RC SCX10 AE2 ESC user manual
Axial RC SCX10 AE2 ESC user manualAxial RC SCX10 AE2 ESC user manual
Axial RC SCX10 AE2 ESC user manualmustafa sarac
 
Array programming with Numpy
Array programming with NumpyArray programming with Numpy
Array programming with Numpymustafa sarac
 
Math for programmers
Math for programmersMath for programmers
Math for programmersmustafa sarac
 
TEGV 2020 Bireysel bagiscilarimiz
TEGV 2020 Bireysel bagiscilarimizTEGV 2020 Bireysel bagiscilarimiz
TEGV 2020 Bireysel bagiscilarimizmustafa sarac
 
How to make and manage a bee hotel?
How to make and manage a bee hotel?How to make and manage a bee hotel?
How to make and manage a bee hotel?mustafa sarac
 
Cahit arf makineler dusunebilir mi
Cahit arf makineler dusunebilir miCahit arf makineler dusunebilir mi
Cahit arf makineler dusunebilir mimustafa sarac
 
How did Software Got So Reliable Without Proof?
How did Software Got So Reliable Without Proof?How did Software Got So Reliable Without Proof?
How did Software Got So Reliable Without Proof?mustafa sarac
 
Staff Report on Algorithmic Trading in US Capital Markets
Staff Report on Algorithmic Trading in US Capital MarketsStaff Report on Algorithmic Trading in US Capital Markets
Staff Report on Algorithmic Trading in US Capital Marketsmustafa sarac
 
Yetiskinler icin okuma yazma egitimi
Yetiskinler icin okuma yazma egitimiYetiskinler icin okuma yazma egitimi
Yetiskinler icin okuma yazma egitimimustafa sarac
 
Consumer centric api design v0.4.0
Consumer centric api design v0.4.0Consumer centric api design v0.4.0
Consumer centric api design v0.4.0mustafa sarac
 
State of microservices 2020 by tsh
State of microservices 2020 by tshState of microservices 2020 by tsh
State of microservices 2020 by tshmustafa sarac
 
Uber pitch deck 2008
Uber pitch deck 2008Uber pitch deck 2008
Uber pitch deck 2008mustafa sarac
 
Wireless solar keyboard k760 quickstart guide
Wireless solar keyboard k760 quickstart guideWireless solar keyboard k760 quickstart guide
Wireless solar keyboard k760 quickstart guidemustafa sarac
 
State of Serverless Report 2020
State of Serverless Report 2020State of Serverless Report 2020
State of Serverless Report 2020mustafa sarac
 
Dont just roll the dice
Dont just roll the diceDont just roll the dice
Dont just roll the dicemustafa sarac
 

More from mustafa sarac (20)

Uluslararasilasma son
Uluslararasilasma sonUluslararasilasma son
Uluslararasilasma son
 
Real time machine learning proposers day v3
Real time machine learning proposers day v3Real time machine learning proposers day v3
Real time machine learning proposers day v3
 
Latka december digital
Latka december digitalLatka december digital
Latka december digital
 
Axial RC SCX10 AE2 ESC user manual
Axial RC SCX10 AE2 ESC user manualAxial RC SCX10 AE2 ESC user manual
Axial RC SCX10 AE2 ESC user manual
 
Array programming with Numpy
Array programming with NumpyArray programming with Numpy
Array programming with Numpy
 
Math for programmers
Math for programmersMath for programmers
Math for programmers
 
The book of Why
The book of WhyThe book of Why
The book of Why
 
BM sgk meslek kodu
BM sgk meslek koduBM sgk meslek kodu
BM sgk meslek kodu
 
TEGV 2020 Bireysel bagiscilarimiz
TEGV 2020 Bireysel bagiscilarimizTEGV 2020 Bireysel bagiscilarimiz
TEGV 2020 Bireysel bagiscilarimiz
 
How to make and manage a bee hotel?
How to make and manage a bee hotel?How to make and manage a bee hotel?
How to make and manage a bee hotel?
 
Cahit arf makineler dusunebilir mi
Cahit arf makineler dusunebilir miCahit arf makineler dusunebilir mi
Cahit arf makineler dusunebilir mi
 
How did Software Got So Reliable Without Proof?
How did Software Got So Reliable Without Proof?How did Software Got So Reliable Without Proof?
How did Software Got So Reliable Without Proof?
 
Staff Report on Algorithmic Trading in US Capital Markets
Staff Report on Algorithmic Trading in US Capital MarketsStaff Report on Algorithmic Trading in US Capital Markets
Staff Report on Algorithmic Trading in US Capital Markets
 
Yetiskinler icin okuma yazma egitimi
Yetiskinler icin okuma yazma egitimiYetiskinler icin okuma yazma egitimi
Yetiskinler icin okuma yazma egitimi
 
Consumer centric api design v0.4.0
Consumer centric api design v0.4.0Consumer centric api design v0.4.0
Consumer centric api design v0.4.0
 
State of microservices 2020 by tsh
State of microservices 2020 by tshState of microservices 2020 by tsh
State of microservices 2020 by tsh
 
Uber pitch deck 2008
Uber pitch deck 2008Uber pitch deck 2008
Uber pitch deck 2008
 
Wireless solar keyboard k760 quickstart guide
Wireless solar keyboard k760 quickstart guideWireless solar keyboard k760 quickstart guide
Wireless solar keyboard k760 quickstart guide
 
State of Serverless Report 2020
State of Serverless Report 2020State of Serverless Report 2020
State of Serverless Report 2020
 
Dont just roll the dice
Dont just roll the diceDont just roll the dice
Dont just roll the dice
 

Recently uploaded

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Recently uploaded (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

Object oriented programming

  • 1. 1 Object-oriented programming (OOP) is a computer science term used to characterize a programming language that began development in the 1960’s. The term ‘object-oriented programming’ was originally coined by Xerox PARC to designate a computer application that describes the methodology of using objects as the foundation for computation. By the 1980’s, OOP rose to prominence as the programming language of choice, exemplified by the success of C++. Currently, OOPs such as Java, J2EE, C++, C#, Visual Basic.NET, Python and JavaScript are popular OOP programming languages that any career- oriented Software Engineer or developer should be familiar with. OOP is widely accepted as being far more flexible than other computer programming languages. OOPs use three basic concepts as the fundamentals for the programming language: classes, objects and methods. Additionally, Inheritance, Abstraction, Polymorphism, Event Handling and Encapsulation. Common Questions & Answers 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 behavior. 3) What is an Object? Object is an instance of a class. It has state, behavior and identity. It is also called as an instance of a class. 4) What is an Instance? An instance has state, behavior and identity. The structure and behavior 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 focusing on the essential characteristics of an object. Abstraction is one of the fundamental elements of the object model. 7) What is meant by Encapsulation? Encapsulation is the process of compartmentalizing the elements of an abstraction that defines the structure and behavior. 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 behavior defined in another class. This is called Single Inheritance. If a class shares the structure or behavior 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 generalized superclasses. Object Oriented Programming (Interview Questions & Answers) Collected from different websites. Use for non-commercial purpose. Sohail Basheer Lecturer- Computer Science (visiting) Department of Computer Science & IT (Evening Program) Federal Urdu University Arts, Science & Technology Gulshan Campus Karachi
  • 2. 2 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 behavior, typically by implementing its abstract operations. 11) What is an Interface? Interface is an outside view of a class or object which emphasizes its abstraction while hiding its structure and secrets of its behavior. 12) What is a base class? Base class is the most generalized class in a class structure. Most applications have such root classes. In Java, Object is the base class for all classes. 13) What is a subclass? Subclass is a class that inherits from one or more classes 14) What is a superclass? superclass is a class from which another class inherits. 15) What is a constructor? Constructor is an operation that creates an object and/or initializes its state. 16) 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. 17) What is meant by Binding? Binding denotes association of a name with a class. 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) Define Modularity? Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules. 21) What is meant by Persistence? Persistence is the property of an object by which its existence transcends space and time. 22) What is collaboration? Collaboration is a process whereby several objects cooperate to provide some higher level behavior.
  • 3. 3 23) In Java, How to make an object completely encapsulated? All the instance variables should be declared as private and public getter and setter methods should be provided for accessing the instance variables. 24) How is polymorphism achieved in java? Inheritance, Overloading and Overriding are used to achieve Polymorphism in java What is a class? Class is concrete representation of an entity. It represents a group of objects, which hold similar attributes and behavior. It provides Abstraction and Encapsulations. What is an Object? What is Object Oriented Programming? Object represents/resembles a Physical/real entity. An object is simply something you can give a name. Object Oriented Programming is a Style of programming that represents a program as a system of objects and enables code-reuse. What is Encapsulation? Encapsulation is binding of attributes and behaviors. Hiding the actual implementation and exposing the functionality of any object. Encapsulation is the first step towards OOPS, is the procedure of covering up of data and functions into a single unit (called class). Its main aim is to protect the data from out side world What is Abstraction? Hiding the complexity. It is a process of defining communication interface for the functionality and hiding rest of the things. What is Overloading? Adding a new method with the same name in same/derived class but with different number/types of parameters. It implements Polymorphism. What is Overriding A process of creating different implementation of a method having a same name as base class, in a derived class. It implements Inheritance. What is Shadowing? When the method is defined as Final/sealed in base class and not override able and we need to provide different implementation for the same. This process is known as shadowing, uses shadows/new keyword. What is Inheritance? It is a process of acquiring attributes and behaviors from another object (normally a class or interface). What is an Abstract class? An abstract class is a special kind of class that cannot be instantiated. It normally contains one or more abstract methods or abstract properties. It provides body to a class.
  • 4. 4 What is an Interface? An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. What is Polymorphism? Mean by more than one form. Ability to provide different implementation based on different number/type of parameters. What is Pure-Polymorphism? When a method is declared as abstract/virtual method in a base class and which is overridden in a base class. If we create a variable of a type of a base class and assign an object of a derived class to it, it will be decided at a run time, which implementation of a method is to be called. This is known as Pure- Polymorphism or Late-Binding. What is a Constructor? A special function Always called whenever an instance of the class is created. • Same name as class name • No return type • Automatically call when object of class is created • Used to initialize the members of class class Test { int a,b; Test() { a=9; b=8; } }; Here Test() is the constructor of Class Test. What is copy constructor? Constructor which initializes it's object member variables ( by shallow copying) with another object of the same class. If you don't implement one in your class then compiler implements one for you. for example: Test t1(10); // calling Test constructor
  • 5. 5 Test t2(t1); // calling Test copy constructor Test t2 = t1;// calling Test copy constructor Copy constructors are called in following cases: • when a function returns an object of that class by value • when the object of that class is passed by value as an argument to a function • when you construct an object based on another object of the same class • When compiler generates a temporary object What is default Constructor? Constructor with no arguments or all the arguments has default values. In Above Question Test() is a default constructor What is a Destructor? A special method called by GC. just before object is being reclaimed by GC. How a base class method is hidden? Hiding a base class method by declaring a method in derived class with keyword new. This will override the base class method and old method will be suppressed. What Command is used to implement properties in C#? get & set access modifiers are used to implement properties in c#. What is method overloading? Method overloading is having methods with same name but carrying different signature, this is useful when you want a method to behave differently depending upon a data passed to it. Can constructors have parameters? Yes, constructors can have parameters. so we can overload it. What are Static Assembly and Dynamic Assembly? Static assemblies can include .NET Framework types (interfaces and classes) as well as resources for the assembly (bitmaps, JPEG files, resource files, and so forth). Static assemblies are stored on disk. Dynamic assemblies run directly from memory and are not saved to disk before execution. Describe the functionality of an assembly. It is the smallest unit that has version control. All types and resources in the same assembly are versioned as a unit and support side by side execution. Assemblies contain the metadata and other identities which allow the common language runtime to execute. They are the boundaries providing the type check. They the unit where security permissions are requested and granted. What is serialization? Serialization is the process of converting an object into a stream of bytes. De-serialization is the opposite process of creating an object from a stream of bytes. Serialization/De-serialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database). There are two separate mechanisms provided by the .NET class library for serialization - XmlSerializer and
  • 6. 6 SoapFormatter and BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting. What are C++ storage classes? auto:the default. Variables are automatically created and initialized when they are defined and are destroyed at the end of the block containing their definition(when they are out of scope). They are not visible outside that block auto int x; int y; Both are same statement. auto is defalt register:a type of auto variable. a suggestion to the compiler to use a CPU register for performance(Generally Used in loops) static:a variable that is known only within the function that contains its definition but is never destroyed and retains its value between calls to that function. It exists from the time the program begins execution void example() { static int x = 0; // static variable x++; cout << x <<endl; } If this function is called 10 times, the output will be 1,2,3,4..etc., The value of the variable x is preserved through function calls. If this static variable is declared as a member of a class, then it will preserve the value for all the objects of the class.i.e, one copy of this data variable will be shared by all objects of the class Note: if we will declare variable like this int x=0; in the above example. then it will print 1 every it will be called extern:a static variable whose definition and placement is determined when all object and librar modules are combined (linked) to form the executable code file. It can be visible outside the file where it is defined. What is RTTI? Runtime type identification (RTTI) lets you find the dynamic type of an object when you have only a pointer or a reference to the base type. RTTI is the official way in standard C++ to discover the type of an object and to convert the type of a pointer or reference (that is, dynamic typing). The need came from practical experience with C++. RTTI replaces many homegrown versions with a solid, consistent approach. What is friend function? As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be listed in the class definition.
  • 7. 7 What is a scope resolution operator? A scope resolution operator (::), can be used to define the member functions of a class outside the class. What do you mean by pure virtual functions? A pure virtual member function is a member function that the base class forces derived classes to provide. Normally these member functions have no implementation. Pure virtual functions are equated to zero. class Shape { public: virtual void draw() = 0; }; What is the difference between declaration and definition? The declaration tells the compiler that at some later point we plan to present the definition of this declaration. E.g.: void stars () //function declaration The definition contains the actual implementation. E.g.: void stars () { for(int j=10; j > =0; j--) //function body cout << *; cout << endl; } What are the advantages of inheritance? It permits code reusability. Reusability saves time in program development. It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional. Association Association is a relationship where all object have their own lifecycle and there is no owner. Let’s take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own lifecycle. Both can create and delete independently. Aggregation Aggregation is a specialize form of Association where all object have their own lifecycle but there is ownership and child object can not belongs to another parent object. Let’s take an example of Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the department teacher object will not destroy. We can think about “has-a” relationship.
  • 8. 8 Composition Composition is again specialize form of Aggregation and we can call this as a “death” relationship. It is a strong type of Aggregation. Child object dose not have their lifecycle and if parent object deletes all child object will also be deleted. Let’s take again an example of relationship between House and rooms. House can contain multiple rooms there is no independent life of room and any room can not belongs to two different house if we delete the house room will automatically delete. Let’s take another example relationship between Questions and options. Single questions can have multiple options and option can not belong to multiple questions. If we delete questions options will automatically delete. How to Implement (Code Example) Class Circle { Point point; }; Class Point { int x; int y; }; Here Circle is composed of Point.... you can't make a circle without point (Strong dependency) Distinguish between the terms fatal error and non–fatal error. Why might you prefer to experience a fatal error rather than a non–fatal error? A fatal error causes a program to terminate prematurely. A nonfatal error occurs when the logic of the program is incorrect, and the program does not work properly. A fatal error is preferred for debugging purposes. A fatal error immediately lets you know there is a problem with the program, whereas a nonfatal error can be subtle and possibly go undetected. What are virtual functions? Describe a circumstance in which virtual functions would be appropriate Virtual functions are functions with the same function prototype that are defined throughout a class hierarchy. At least the base class occurrence of the function is preceded by the keyword virtual. Virtual functions are used to enable generic processing of an entire class hierarchy of objects through a base class pointer. For example, in a shape hierarchy, all shapes can be drawn. If all shapes are derived from a base class Shape which contains a virtual draw function, then generic processing of the hierarchy can be performed by calling every shape’s draw generically through a base class Shape pointer. Given that constructors cannot be virtual, describe a scheme for how you might achieve a similar effect Create a virtual function called initialize that the constructor invokes.
  • 9. 9 How is it that polymorphism enables you to program “in the general” rather than “in the specific.” Discuss the key advantages of programming “in the general.” Polymorphism enables the programmer to concentrate on the processing of common operations that are applied to all data types in the system without going into the individual details of each data type. The general processing capabilities are separated from the internal details of each type. Discuss the problems of programming with switch logic. Explain why polymorphism is an effective alternative to using switch logic. The main problem with programming using the switch structure is extensibility and maintainability of the program. A program containing many switch structures is difficult to modify. Many, but not necessarily all, switch structures will need to add or remove cases for a specified type. Note: switch logic includes if/else structures which are more flexible than the switch structure. Distinguish between static binding and dynamic binding. Explain the use of virtual functions and the vtable in dynamic binding. Static binding is performed at compile-time when a function is called via a specific object or via a pointer to an object. Dynamic binding is performed at run-time when a virtual function is called via a base class pointer to a derived class object (the object can be of any derived class). The virtual functions table (vtable) is used at run-time to enable the proper function to be called for the object to which the base class pointer "points". Each class containing virtual functions has its own vtable that specifies where the virtual functions for that class are located. Every object of a class with virtual functions contains a hidden pointer to the class’s vtable. When a virtual function is called via a base class pointer, the hidden pointer is dereferenced to locate the vtable, then the vtable is searched for the proper function call. Distinguish between inheriting interface and inheriting implementation. How do inheritance hierarchies designed for inheriting interface differ from those designed for inheriting implementation? When a class inherits implementation, it inherits previously defined functionality from another class. When a class inherits interface, it inherits the definition of what the interface to the new class type should be. The implementation is then provided by the programmer defining the new class type. Inheritance hierarchies designed for inheriting implementation are used to reduce the amount of new code that is being written. Such hierarchies are used to facilitate software reusability. Inheritance hierarchies designed for inheriting interface are used to write programs that perform generic processing of many class types. Such hierarchies are commonly used to facilitate software extensibility (i.e., new types can be added to the hierarchy without changing the generic processing capabilities of the program.) Distinguish between virtual functions and pure virtual functions A virtual function must have a definition in the class in which it is declared. A pure virtual function does not provide a definition. Classes derived directly from the abstract class must provide definitions for the inherited pure virtual functions in order to avoid becoming an abstract base class