top 10 java oops interview questions

11
Top 10 Java Oops Interview Questions http://crbtech.in/Student-Review

Upload: riama-roy

Post on 13-Apr-2017

122 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Top 10 java oops interview questions

Top 10 Java Oops Interview Questions

http://crbtech.in/Student-Review

Page 2: Top 10 java oops interview questions

Top 10 Java Oops Interview Questions

http://crbtech.in/Student-Review

1.What exactly is the Java’s oops concept?Oops is a methodology that gives a way for modularizing a program by developing a partitioned memory location for both data and its methods that can be utilized as format for creating duplicates of such modules on interest.

The four types include:Inheritance

PolymorphismEncapsulation

Abstraction

Page 3: Top 10 java oops interview questions

Top 10 Java Oops Interview Questions

http://crbtech.in/Student-Review

2. What do you mean by encapsulation?The process of associating data with related methods is called encapsulation. Class forms the core of this.3. Define a class:In case of oops, a class is a collection of variable/s and method/s for a particular type of object. An object is considered to be an instance of a class. It happens to be a user defined data type in Java.4. What do you mean by an object?It forms an instance of a class. Object can be defined as any entity that has attributes, methods associated with it. An object is used to allocate dynamic memory to a class.5. State the object characteristicsThe three characteristics of an object are:IdentityBehaviorState6. Explain inheritanceSelf explanatory, it means to intake what already exists.One of the most important concepts. The purpose is purely re-usability.Used for inheriting properties from one class object to another one.In simple terms, just like you inherit qualities from your parents!

Page 4: Top 10 java oops interview questions

Top 10 Java Oops Interview Questions

http://crbtech.in/Student-Review

7. How is inheritance put to use in Java?Inheritance is used in Java with the help of two keywords namely ‘extends’ and ‘implements’.With the help of ‘extends’, inheritance between two interfaces or classes can be established. While,‘implements’ is used to establish inheritance amongst interface and class.e.g.package com.instanceofjava;class A{  }package com.instanceofjava;class B extends A{ }

Page 5: Top 10 java oops interview questions

Top 10 Java Oops Interview Questions

http://crbtech.in/Student-Review

8. State the different types of inheritancesInheritance is divided into two main types namely-Multiple inheritanceMultilevel inheritanceMultiple inheritance:The funda of getting objects from multiple classes into single class object is called multiple inheritance. It is not supported in Java programming.Multilevel inheritance:Getting properties from object of one class to another class object, is called multilevel inheritance.e.g. package com.instanceofjava;class A{  }class B extends A{}class C extends B{}

Page 6: Top 10 java oops interview questions

Top 10 Java Oops Interview Questions

http://crbtech.in/Student-Review

9. Define polymorphismUsing same names for more than one method.One of the most popular java interview questions.Two types are:Static polymorphism and Dynamic polymorphismStatic:Also called as method overloadingMultiple methods with same name and different parameters.Dynamic:Defining more than one methods with identical signature in sub class and super class.The always executed method in this case will be sub most object.

Page 7: Top 10 java oops interview questions

Top 10 Java Oops Interview Questions

http://crbtech.in/Student-Review

10. Elaborate this and super keywordsSuper:A keyword used to store super class non -static members reference in sub class object.Used to differentiate between sub class and super class members if the names are same.System.out.println(super); would give compilation Error.This:Current object reference is stored in this.Should be used when non-static variable and local variables’ name happens to be one.System.out.print(this); would work fine.So, these were some of the popular oops concepts and the very basic ones that form Java core interview questions.There are many institutes present for Java training Pune. You can benefit by joining them.

Page 8: Top 10 java oops interview questions

Top 10 Java Oops Interview Questions

http://crbtech.in/Student-Review

Page 9: Top 10 java oops interview questions

CRB TECH PRESENTATION

http://crbtech.in/Student-Review

Page 10: Top 10 java oops interview questions

CRB TECH PRESENTATION

http://crbtech.in/Student-Review

Page 11: Top 10 java oops interview questions

CRB TECH PRESENTATION

http://crbtech.in/Student-Review