Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

OOP Viva Questions

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 8

hat are the principle concepts of OOPS?

There are four principle concepts upon which object oriented design and programming rest. They are:

Abstraction Polymorphism Inheritance Encapsulation

1) What is meant by Object Oriented Programming? OOP is a method of programming in which programs are organised as cooperative collections of objects. Each object is an instance of a class and each class belong to a hierarchy. What is an Object? Object is an instance of a class. It has state,behaviour and identity. It is also called as an instance of a class. What is meant by abstraction? Abstraction defines the essential characteristics of an object that distinguish it from all other kinds of objects. Abstraction provides crisply-defined conceptual boundaries relative to the perspective of the viewer. Its the process of focussing on the essential characteristics of an object. Abstraction is one of the fundamental elements of the object model. What is meant by Encapsulation? Encapsulation is the process of compartmentalising the elements of an abtraction that defines the structure and behaviour. Encapsulation helps to separate the contractual interface of an abstraction and implementation.

What is the difference between abstraction and encapsulation?

Abstraction focuses on the outside view of an object (i.e. the interface) Encapsulation (information hiding) prevents clients from seeing its inside view, where the behavior of the abstraction is implemented. Abstraction solves the problem in the design side while Encapsulation is the Implementation. Encapsulation is the deliverables of Abstraction. Encapsulation barely talks about grouping up your abstraction to suit the developer needs.

8) What is meant by Inheritance? Inheritance is a relationship among classes, wherein one class shares the structure or behaviour defined in another class. This is called Single Inheritance. If

a class shares the structure or behaviour from multiple classes, then it is called Multiple Inheritance. Inheritance defines is-a hierarchy among classes in which one subclass inherits from one or more generalised superclasses. 9) What is meant by Polymorphism? Polymorphism literally means taking more than one form. Polymorphism is a characteristic of being able to assign a different behavior or value in a subclass, to something that was declared in a parent class. 10) What is an Abstract Class? Abstract class is a class that has no instances. An abstract class is written with the expectation that its concrete subclasses will add to its structure and behaviour, typically by implementing its abstract operations. 11) What is an Interface? Interface is an outside view of a class or object which emphaizes its abstraction while hiding its structure and secrets of its behaviour. What is a constructor? Constructor is an operation that creates an object and/or initialises 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. 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 acheived in java? Inheritance, Overloading and Overriding are used to acheive Polymorphism in java.

What are the various elements of OOP? Various elements of OOP are: Object, Class , Method Class A class is a collection of data and operations on data. Data and operations / functions / methods are placed together in a single unit, i.e., class. This feature is known as encapsulation

What is Loosely Coupling in Object Oriented Programming or Software Design?

System should have as many dependencies as is needed to do their job - and the dependencies should be few. What is a Concrete Object? A concrete object is any object created with the keyword new.

What is the difference between interpreters and compilers? Interpreters read through source code and translate a program, turning the programmer's code, or program instructions, directly into actions. Compilers translate source code into an executable program that can be run at a later time. When is the destructor called? The destructor is called each time an object is destroyed, either because it goes out of scope or because you call delete on a pointer pointing to it. What is the protected keyword used for? protected members are accessible to the member functions of derived objects. 49. What is a down cast? A down cast (also called "casting down") is a declaration that a pointer to a base class is to be treated as a pointer to a derived class.

What is a friend class? A friend class is a class declared so that all its member functions are friend functions of your class. Can we inherit priVATe members of class ?
Asked By: Anjaly | Asked On: Jul 27th, 2006 Answered by: ProgrmmingBOT on: Nov 20th, 2011 13 answers

we cannot inherit private members of a class,but you can use friend functions to access private data
Answered by: sean on: Oct 10th, 2011

if you can declare the sub class in the base class (i.e if you make sub class as inner class in base class), you will be able to access the private members of the base class.

Aggregation: In aggregation , one object is composed of multiple objects and every object is useless without the relationship. Suppose there is a car object, so car object is useless without the tyre or steering object, and steering object is useless without car. This type of relationship is called Aggregation. Compostion: One object is composed of several objects, in this type of relationship, every object has its own existence.

What is Abstract method?


Posted by: Raja

Abstract method doesn't provide the implementation & forces the derived class to override the method.

What is Virtual method?


Posted by: Raja

Virtual Method has implementation & provide the derived class with the option to override it.

What is Static field? Posted by: Poster

To indicate that a field should only be stored once no matter how many instance of the class we c

What is Static Method? Posted by: Poster

It is possible to declare a method as Static provided that they don't attempt to access any instanc methods.

What is the difference between constructor and method? Ans: Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.
)What are different types of access modifiers? Ans: public: Any thing declared as public can be accessed from anywhere. private: Any thing declared as private can't be seen outside of its class. protected: Any thing declared as protected can be accessed by classes in the same package and subclasses in the other packages. default modifier : Can be accessed only to classes in the same package.

What is method overloading and method overriding? Ans: Method overloading: When methods in a class having the same method name with different arguments is said to be method overloading. Method overriding : When methods in a class having the same method name with same arguments is said to be method overriding. 12)What is difference between overloading and overriding? Ans: a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method. b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass. c) In overloading, separate methods share the same name whereas in overriding,subclass method replaces the superclass. d) Overloading must have different method signatures whereas overriding must have same signature.
What is method overloading? Method Overloading means to have two or more methods with same name in the same class with different arguments. The benefit of method overloading is that it allows you to implement methods that support the same semantic operation but differ by argument number or type. What is method overriding? Method overriding occurs when sub class declares a method that has the same type arguments as a method declared by one of its superclass. The key benefit of overriding is the ability to define behavior thats specific to a particular subclass type. Is it possible to override the main method in java? NO, because main is a static method. A static method can't be overridden in Java. What is an Interface?

An interface is a description of a set of methods that conforming implementing classes must have. Note:

You cant mark an interface as final. Interface variables must be static. An Interface cannot extend anything but another interfaces.

Advantages of DBMS? Redundancy is controlled. Unauthorised access is restricted. Providing multiple user interfaces. Enforcing integrity constraints. Providing backup and recovery. Define the "integrity rules" There are two Integrity rules. Entity Integrity: States that Primary key cannot have NULL value Referential Integrity: States that Foreign Key can be either a NULL value or should be Primary Key value of other relation. What is E-R model? This data model is based on real world that consists of basic objects called entities and of relationship among these objects. Entities are described in a database by a set of attributes. What is an Entity? It is a 'thing' in the real world with an independent existence. 17. What is an Entity type? It is a collection (set) of entities that have same attributes. 18. What is an Entity set? It is a collection of all entities of particular entity type in the database. What is Weak Entity set? An entity set may not have sufficient attributes to form a primary key, and its primary key compromises of its partial key and primary key of its parent entity, then it is said to be Weak Entity set. 21. What is an attribute? It is a particular property, which describes the entity. What is degree of a Relation? It is the number of attribute of its relation schema. 24. What is Relationship? It is an association among two or more entities. What is DDL (Data Definition Language)? A data base schema is specifies by a set of definitions expressed by a special language called DDL. Read more: http://www.ittestpapers.com/articles/faq--interview-questions-indbms.html#ixzz1mcpO4nJ1

You might also like