Friday, January 22, 2016

Top 10 OOPS Concepts Interview Questions and answers

In this post we will discuss different types of java interview questions that can be very useful when attending java interview.Basically, interviewer starts technical interview from basic questions such as Object Oriented programming questions to test your skills in java.

1.What is OOP? Use of OOP in java?
Ans: OOP stand for Object Oriented Programming,it is a computer programming language that is completely depends on class-based and Object oriented. If you develop any software by using Object Oriented based Programming language you will have many advantages. They are
  • Re-usability of the code
  • Easy maintenance and modifications
  • for programmers  very easy to understanding the code
  • it provides Security
  • Reliability and flexibility of the code

    2.   What are the Principles concepts in java?
   Ans: Object Oriented Programming contains significant features  they are
  •    encapsulation
  •    polymorphism
  •    inheritance
  •    abstraction       





3.  What is class in java?
Ans: A class is a blueprint of an object. That means we can create class from which objects of same type can be created. For Example take a car. There are thousands of cars with having same characteristics that is having same design and model. so all the same types are created from blueprint called  class.  class combination of variables and methods.

Ex:   
class Test{
int a,b;
void show();
{
}
}
4. what is object in java?
Ans: In Object Oriented Programming this is most basic concept in java.Object is instance of class. Object is an entity that has three characteristics they are:
  • State
  • behavior
  • identity
These are the example of objects, car,bike,dog,pen,table etc...Lets take an example of a car. car has some state like (gear,speed) and behavior (change gear,apply break). It identify the state and behavior of  real world object. This is very suitable program for solving real time problems. software objects are similar to the real world objects. An object stores its state in fields and expose through methods.

5. What is encapsulation?
Ans: Encapsulation can be achieved by combining variables and methods in the class.So class is the base of the encapsulation. This provides protective barrier that prevents the access of the code and data from outside of the class.The main advantages of the encapsulation are given below:
  • The internal state of every object is protected by its attributes
  • it improves the maintenance of the code and usability 

6. What is Inheritance?
Ans:  It is one of the most important feature in Object Oriented Programming. It has the capability of the one class to acquire common state and behavior of another class while adding its own functionality. That means getting properties from one class object to another class object.so re-usability happens here without rewriting same code.that means we can add additional features to a new class without modifying it.

More details on Inheritance: Inheritance in java

7. What is Polymorphism?
Ans: 
polymorphism means many forms. It has ability of one type to take more than one form.So we define multiple methods with same name.we can achieve polymorphism  in java in two ways they are
method overloading
method overriding

More details on Polymorphism: Polymorphism in java

8. What is abstraction?
Ans:It is a process of separating the ides from specific instances. It refers to the act of presenting the essential features without including background details or explanations. That means it hides the some of the details in order to bring out more clearly other aspects. Abstraction can be achieved in two ways

More details on Abstraction:  Abstraction in java

Abstract classes and interfaces

9. What is difference between abstraction and encapsulation?
Ans: Abstract focus on the outside view of an object and hides the unnecessary details whereas encapsulation provides a protective barrier to prevent access of the code and data from outside of the class
    Mainly we use abstraction in design side whereas  encapsulation in implementation side.

10. Is it possible to override main method in java?
Ans: No. Static methods can not be overridden in java 

    

No comments:

Post a Comment

High Paying Jobs after Learning Python

Everyone knows Python is one of the most demand Programming Language. It is a computer programming language to build web applications and sc...