oops Interview questions for freshers as well 1 to 3 year experienced on advance and basic Object Oriented Programming with examples that cover the essentials of oops means all type of oops questions covered under this page and also a form is given at the end of this page for those user who want more Interview questions and answer on core and advanced oops just need to fill the form and send us we will send all the answers to them and it for both freshers and experienced condidate and also chat option is given in right hand side for directly chat with expert for answers
Questions : 1 | What is Object Oriented Programming ? |
Answers : 1 |
It is a problem solving technique to develop software systems. It is a technique to think real world in terms of objects. Object maps the software model to real world concept. These objects have responsibilities and provide services to application or other objects. |
Questions : 2 | What is a Class ? |
Answers : 2 |
A class describes all the attributes of objects, as well as the methods that implement the behavior of member objects. It is a comprehensive data type which represents a blue print of objects. It’s a template of object. |
Questions : 3 | What is an Object ? |
Answers : 3 |
It is a basic unit of a system. An object is an entity that has attributes, behavior, and identity. Objects are members of a class. Attributes and behavior of an object are defined by the class definition. |
Questions : 4 | What is the relation between Classes and Objects? |
Answers : 4 |
They look very much same but are not same. Class is a definition, while object is instance of the class created. Class is a blue print while objects are actual objects existing in real world. Example we have class CAR which has attributes and methods like Speed, Brakes, Type of Car etc.Class CAR is just a prototype, now we can create real time objects which can be used to provide functionality. Example we can create a Maruti car object with 100 km speed and urgent brakes. |
Questions : 5 | What are different properties provided by Object-oriented systems ? |
Answers : 5 |
Following are characteristics of Object Oriented System’s:- |
Questions : 6 | What is an Abstract class ? |
Answers : 6 |
Abstract class defines an abstract concept which can not be instantiated and comparing
o interface it can have some implementation while interfaces can not. Below are some |
Questions : 7 | What are Abstract methods? |
Answers : 7 |
Abstract class can contain abstract methods. Abstract methods do not have implementation.
Abstract methods should be implemented in the subclasses which inherit them. So if an
abstract class has an abstract method class inheriting the abstract class should implement
the method or else java compiler will through an error. In this way, an abstract class can
define a complete programming interface thereby providing its subclasses with the method
declarations for all of the methods necessary to implement that programming interface.
Abstract methods are defined using "abstract" keyword. Below is a sample code snippet. |
Questions : 8 | What is the difference between Abstract classes and Interfaces ? |
Answers : 8 |
Difference between Abstract class and Interface is as follows:-
|
Questions : 9 | What is difference between Static and Non-Static fields of a class ? |
Answers : 9 |
Non-Static values are also called as instance variables. Each object of the class has its own copy of Non-Static instance variables. So when a new object is created of the same class it will have completely its own copy of instance variables. While Static values have only one copy of instance variables and will be shared among all the objects of the class. |
Questions : 10 | What are inner classes and what is the practical implementation of inner classes? |
Answers : 10 |
Inner classes are nested inside other class. They have access to outer class fields and
methods even if the fields of outer class are defined as private. |
Questions : 11 | What is a constructor in class? |
Answers : 11 |
Constructor has the same name as the class in which it resides and looks from syntax point of view it looks similiar to a method. Constructor is automatically called immediately after the object is created, before the new operator completes. Constructors have no return type, not even void. This is because the implicit return type of a class' constructor is the class type itself. It is the constructor's job to initialize the internal state of an object so that the code creating an instance will have a fully initialized, usable object immediately. |
Questions : 12 | Can constructors be parameterized? |
Answers : 12 |
Yes we can have parameterized constructor which can also be termed as constructor
overloading. Below is a code snippet which shows two constructors for pcdsMaths class
one with parameter and one with out. |
Questions : 13 | What is the use if instanceof keyword? and How do refer to a current instance of object? |
Answers : 13 |
"instanceof" keyword is used to check what is the type of object. |
Questions : 14 | what is Bootstrap, Extension and System Class loader? or Can you explain primordial class loader? |
Answers : 14 |
There three types of class loaders:- |
Questions : 15 | what’s the main difference between ArrayList / HashMap and Vector / Hashtable? |
Answers : 15 |
Vector / HashTable are synchronized which means they are thread safe. Cost of thread
safe is performance degradation. So if you are sure that you are not dealing with huge number of threads then you should use ArrayList / HashMap.But yes you can still |
Questions : 16 | What are access modifiers? |
Answers : 16 |
Access modifiers decide whether a method or a data variable can be accessed by another
method in another class or subclass. |
Questions : 17 | Define exceptions ? |
Answers : 17 |
An exception is an abnormal condition that arises in a code sequence at run time. Basically there are four important keywords which form the main pillars of exception handling: try, catch, throw and finally. Code which you want to monitor for exception is contained in the try block. If any exception occurs in the try block its sent to the catch block which can handle this error in a more rational manner. To throw an exception manually you need to call use the throw keyword. If you want to put any clean up code use the finally block. The finally block is executed irrespective if there is an error or not. |
Questions : 18 | What is serialization?How do we implement serialization actually? |
Answers : 18 |
Serialization is a process by which an object instance is converted in to stream of bytes. There are many useful stuff you can do when the object instance is converted in to stream of bytes for instance you can save the object in hard disk or send it across the network. In order to implement serialization we need to use two classes from java.io package ObjectOutputStream and ObjectInputStream. ObjectOutputStream has a method called writeObject, while ObjectInputStream has a method called readObject. Using writeobject we can write and readObject can be used to read the object from the stream. Below are two code snippet which used the FileInputStream and FileOutputstream to read and write from harddisk. |