Interview Questions and Answers for 'Oop' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Interview Questions and Answers - Order By Newest

   next 30
 Q161. What happens to private variables during inheritance ?Core Java
Ans. Private variables are not inherited. They are simply ignored and not made part of the derived object body.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     private variables  inheritance  object oriented programming (oops)  oops concepts


 Q162. How can we hide a class in Java ?Core Java
Ans. By encapsulating it within another class and declaring it private. In such a case, it will only be accessible through parent class or parent class object.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     private class   private inner class  class hiding  encapsulation  object oriented programming (oops)  oops concepts  inner classes   nested classes


Very frequently asked. Usually among very first few questions.
 Q163. Define encapsulation in Java ?Core Java
Ans. Encapsulation is a feature of OOP's that binds the data and it's associated methods together as a single unit and facilitate protection and data hiding by providing minimal interface to outside. For example - member variables are declared private and are accessed through public methods. Moreover we have private methods that can only be used internally and hence providing minimal interface to outside class through use of public methods.

  Sample Code for encapsulation

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     encapsulation  object oriented programming (oops)  oops concepts  oops  oops concepts  oops features     Asked in 4 Companies      Basic        frequent


 Q164. Give an example of how Object Oriented Programming Concepts can be implemented.Design
Ans. You can implement encapsulation in Java by keeping the fields (class variables) private and providing public getter and setter methods to each of them. Java Beans are examples of fully encapsulated classes. Encapsulation in Java: Restricts direct access to data members (fields) of a class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops example  oops concepts  oops features     Asked in 2 Companies      basic        frequent


 Q165. What are the different types of loops in Java ?Core Java
Ans. for, while and do while

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     loops  different type of loops  for loop  control statements  loop statement      basic


 Q166. What is an infinite loop ?Core Java
Ans. Infinite loop is a programming condition wherein the control goes into an infinite loop because the loop termination condition can never be met. For example -

for(int x=1;x>0;x++){
}

in this loop, with each increment the condition x > 0 will remain true till infinity.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     loop  infinite loop  for loop  control statements  loop statement      basic


 Q167. Explain Inheritance and Polymorphism.Core Java
Ans. Getting parent class object properties into child class is called Inheritance.

The process of representing one form into multiple forms is called polymorphism.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     inheritance  object oriented programming (oops)  oops concepts  polymorphism  object oriented programming (oops)  oops concepts     Asked in 1 Companies      Basic        frequent


 Q168. What is the difference between return and continue statement ?Core Java
Ans. return is used within a method to return control out of the method. It may be followed by a value which is returned from the method to calling method immediately preceding the point of call.

continue statement is used within a loop to start next iteration without executing the remaining statements in the loop.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     return statement  continue statement  return vs continue  for loop  control statements  loop statement


 Q169. What are the uses of Abstraction ?Core Java
Ans. Loose Coupling
Facilitates designing complex applications by making them modular.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops concepts  abstraction     Asked in 1 Companies


 Q170. Which of the OOP's features facilitate dependency injection ? Design
Ans. Inheritance , Runtime Polymorphism and Composition.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     dependency injection  inversion of control  ioc  oops  oops features


 Q171. Is Runtime Polymorphism possible without Inheritance ?Core Java
Ans. Yes, Runtime Polymprohism requires either Class inheritance or Interface implementation.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     runtime polymorphism  object oriented programming (oops)  oops concepts  method overriding  inheritance  object oriented programming (oops)  oops concepts


 Q172. Why Java is considered more purer object oriented language than C++ ?Core Java
Ans. Because of

lack of use of pointers,
Lack of structural programming and
Lack of Multiple Inheritance

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  java vc c++


 Q173. Why shouldn't we use string concatenation extensively or in a loop ?Core Java
Ans. Because String being an immutable object creates a new object upon each concatenation cycle. If there is any such need , we should use String Builder whose objects are mutable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     string  string immutable  immutability  for loop  control statements  loop statement     Asked in 1 Companies


 Q174. how does abstraction help your application ?Core Java
 This question was recently asked at 'Intel'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     abstraction  oops concepts     Asked in 1 Companies      basic


  Q175. Explain OOps concepts.Core Java
Ans. There are four main OOP concepts in Java. These are:

Abstraction. Abstraction means using simple things to represent complexity. We all know how to turn the TV on, but we don?t need to know how it works in order to enjoy it. In Java, abstraction means simple things like objects, classes, and variables represent more complex underlying code and data. This is important because it lets avoid repeating the same work multiple times.

Encapsulation. This is the practice of keeping fields within a class private, then providing access to them via public methods. It?s a protective barrier that keeps the data and code safe within the class itself. This way, we can re-use objects like code components or variables without allowing open access to the data system-wide.

Inheritance. This is a special feature of Object Oriented Programming in Java. It lets programmers create new classes that share some of the attributes of existing classes. This lets us build on previous work without reinventing the wheel.

Polymorphism. This Java OOP concept lets programmers use the same word to mean different things in different contexts. One form of polymorphism in Java is method overloading. That?s when different meanings are implied by the code itself. The other form is method overriding. That?s when the different meanings are implied by the values of the supplied variables. See more on this below.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops concepts     Asked in 16 Companies      basic        frequent


 Q176. What is composition ?Core Java
 This question was recently asked at 'MST Solutions'.This question is still unanswered. Can you please provide an answer.


  Sample Code for composition

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     composition  object oriented programming (oops)  oops concepts  oops concepts     Asked in 1 Companies      basic        frequent


 Q177. What is Overriding ?Core Java
Ans. Overriding refers to the Methods with same name and parameters, such that the later over rides the former method.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops concepts  overriding     Asked in 1 Companies      basic        frequent


 Q178. What are the characteristics of the object ? Core Java
Ans. 1. State

Instance variable or member elements forms the object state.

2. Behavior

Member functions forms the object behavior

3. Identity

Every object has a unique identity within JVM through a unique Id.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops concepts


 Q179. Which of the OOP's feature - encapsulation or abstraction - is more important ?Core Java
Ans. Encapsulation facilitates security by hiding data and logic whereas Abstraction simplifies organization of data and related logic.

As applications scale, both concepts are required for easy management and maintenance. Encapsulation for security and criss cross communication between objects / modules will make it vulnerable. and Abstraction for better organization that enables better understanding of application code and easy maintainability.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops features  oops concepts


 Q180. Which of the polymorphism type - static or runtime - is more important ?Core Java
Ans. Method overloading / static polymorphism compared to method overriding / runtime polymorphism has very limited usage as it just opens up an alternate way of defining a different method with the same name.

Method Overriding on other hand opens up many other features like contracting , interfacing , pluging development and hence development of libraries and frameworks.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops features  oops concepts


 Q181. Which of the OOP's feature is most important ?Core Java
Ans. Encapsulation facilitate hiding and restricted access and hence more of a security feature. Encapsulation is definitely a great feature as when applications expand criss cross communication between objects / modules could lead to blunders.

Inheritance facilitates code reuse.

Polymorphism comprise of method overloaded ( which to me is negligible usage ) and method overriding. Method overriding is of great usage as it facilitates concept of interfaces and plugin development.

So it’s Security / Organization vs

Code Reuse / Support for other features like overriding vs

Contracts / Plugin Development facilitating the creation of frameworks / libraries.

Which is more important may vary from application to application , its scale , its use , its sensitivity etc.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     oops  oops features  oops concepts


 Q182. How to instantiate jsp variable from another jsp?JSP
Ans. using session attribute.

session.setAttribute("userId",userId);

in first jsp

int userId=session.getAttribute("userId");

in second jsp;

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q183. Find unique values between two arrays using single for loop ?Core Java
 This question was recently asked at 'Net connect'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     for loop  control statements  loop statement     Asked in 1 Companies


 Q184. What is virtual table with respect to method overriding in Java ?Core Java
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     vtable  virtual method table   method overriding  runtime polymorphism  object oriented programming (oops)  oops concepts


 Q185. How is the virtual method table implemented in Java?Core Java
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     virtual method table   method overriding  runtime polymorphism  object oriented programming (oops)  oops concepts      expert        rare


 Q186. How many VTables are there for each class ? Core Java
Ans. There is one VTable for each class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     virtual table method  vtable  runtime polymorphism  object oriented programming (oops)  oops concepts   method overriding      intermediate        rare


 Q187. Can a class extend itself in Java ?Core Java
Ans. No

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     inheritance  object oriented programming (oops)  oops concepts


 Q188. Difference between hadoop 1.x and 2.x?Apache Hadoop
Ans. Hadoop 1.x

It supports only MapReduce (MR) processing model.
It has limited scaling of nodes. Limited to 4000 nodes per cluster.
It has single Namenode to manage the entire namespace.
It has Single-Point-of-Failure (SPOF)
Works on concepts of slots – slots can run either a Map task or a Reduce task
MR has to do both processing and cluster resource management.

Hadoop 2.x

It supports MR as well as other distributed computing models like Spark, Hama, etc
It has better scalability. Scalable up to 10000 nodes per cluster.
Works on concepts of containers. Using containers can run generic tasks.
It has Multiple Namenode servers manage multiple namespace.
YARN does cluster resource management and processing is done using different processing models.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q189. Difference between group and cogroup?Apache Hadoop
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q190. How Object-Oriented Programming is implemented in JavaScript? How they differ from other languages?Javascript
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     object oriented programming in javascript  oops in javascript


previous 30   next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: