• +91 9971497814
  • info@interviewmaterial.com

OOP Interview Questions Answers

Question 1 : Does a class inherit the constructors of its superclass?

Answer 1 : A class does not inherit constructors from any of its super classes. If a class is declared without any access modifiers, where may the class be accessed? A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.

Question 2 : What is multithreading?

Answer 2 : Multithreading is the mechanism in which more than one thread run independent of each other within the process.

Question 3 : What are inner class and anonymous class?

Answer 3 : Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors.

Question 4 : What is the difference between superclass and subclass?

Answer 4 : A super class is a class that is inherited whereas sub class is a class that does the inheriting.

Question 5 : What is difference between overloading and overriding?

Answer 5 : 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.  

Question 6 : How many ways can an argument be passed to a subroutine?

Answer 6 : An argument can be passed in two ways. They are Pass by Value and Passing by Reference. Passing by value: This method copies the value of an argument into the formal parameter of the subroutine. Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter.

Question 7 : What is the difference between procedural and object-oriented programs?

Answer 7 : 1. In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code. 2. In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code.

Question 8 : What are the advantages of OOPL?

Answer 8 : Object oriented programming languages directly represent the real life objects. The features of OOPL as inheritance, polymorphism, encapsulation makes it powerful.

Question 9 : Can a method be overloaded based on different return type but same argument type ?

Answer 9 : No, because the methods can be called without using their return type in which case there is ambiguity for the compiler.

Question 10 : What is Downcasting ?

Answer 10 : Downcasting is the casting from a general to a more specific type, i.e. casting down the hierarchy.

OOP Contributors

krishan

Share your email for latest updates

Name:
Email:

Our partners