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. |
|
| ||||
Interview Questions and Answers for 'Program' - 64 question(s) found - Order By Rating | ||||
| ||||
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 | ||||
| ||||
Ans. Inline functions , just like C++ Macros is an optimized technique used by compiler to reduce the execution time. If the function is working on pre identified values ( which aren't resolved at runtime ), the function can execute the method and evaluate the outcome at compile time only instead of making a function call at runtime. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  inline functions  inline methods  C++ Asked in 1 Companies | ||||
| ||||
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  C++ vs 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   | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
Ans. 1. Enforcing composition over inheritance 2. Restricting overriding of certain methods 3. Final methods are faster than regular instance methods 4. Enforcing Immutability | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  final class   reasons for final class   restricting inheritance  object oriented programming (oops)  oops concepts expert | ||||
| ||||
Ans. Yes, to a certain extent. But the objective for Final class could be beyond just enforcing composition as certain classes might have been created without inheritance or composition in mind. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  final class   composition  object oriented programming (oops)  oops concepts  inheritance  object oriented programming (oops)  oops concepts  composition  object oriented programming (oops)  oops concepts vs inheritance  object oriented programming (oops)  oops concepts expert | ||||
| ||||
Ans. No | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  abstract class   multiple inheritance  object oriented programming (oops)  oops concepts Asked in 2 Companies | ||||
| ||||
Ans. Reactive extensions have a steep learning curve which makes it confusing for beginner and intermediate developers. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  RxJava  ReactiveX  Reactive Programming | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
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  spring app  spring  aspect oriented programming | ||||
Very frequently asked. Usually among very first few questions. | ||||
| ||||
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 | ||||
| ||||
This question was recently asked at 'Ola Cabs'.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  program  code  coding  insertion sort   sort Asked in 1 Companies | ||||
| ||||
Ans. int compare(int a, int b) { a>b? return a: return b; } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  program  coding Asked in 1 Companies basic | ||||
| ||||
Ans. Java Programs are collection of objects that communicates with each other to get a task accomplished. To add to those objects, there are common spaces ( static i.e common for objects belonging to a class ) that are used too. We can visualize objects as departments of an organization in real world. Just like Task gets initiated in one department and then files are moved across different departments to get work done. In a similar fashion, a task is initiated in one object ( having main method ) and then information ( through POJOs / DTOs ) is moved across objects to accomplish a task. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  objects  Java Programs are collection of objects  real life example of object communication | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
Ans. Dynamic dispatch in java is also known as runtime polymorphism.It is a process in which a call to an overriden method is resolved at runtime. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  dynamic dispatch  runtime polymorphism  object oriented programming (oops)  oops concepts | ||||
| ||||
Ans. dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. This is used to achieve runtime polymorphism in java. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  overriding  runtime polymorphism  object oriented programming (oops)  oops concepts | ||||
| ||||
Ans. Java identifies the method to be called at runtime by the object that is being referenced. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  polymorphism  object oriented programming (oops)  oops concepts  overloading  overriding basic | ||||
| ||||
Ans. runtime polymorphism or method overriding doesn't require method name and signature to be different whereas compile time polymorphism or method overloading requires method name to be same but the signature to be different. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  polymorphism  object oriented programming (oops)  oops concepts  overloading  overriding basic | ||||
| ||||
Ans. Composition and Inheritance are the different types of Associations for Classes. Composition is a has-a association between classes. Inheritance is a is-a association between classes. | ||||
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  inheritance  object oriented programming (oops)  oops concepts  association  relationship between objects | ||||
| ||||
Ans. No exit is a method to exit execution of a program. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  exit  keywords  exit a program Asked in 1 Companies | ||||
| ||||
Ans. class A { void test() { System.out.println("test() method"); } } class B { void test() { System.out.println("test() method"); } } Suppose if Java allows multiple inheritance like this, class C extends A, B { } A and B test() methods are inheriting to C class. So which test() method C class will take? As A & B class test() methods are different , So here we would Facing Ambiguity. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  multiple inheritance  object oriented programming (oops)  oops concepts  diamond problem Asked in 20 Companies basic   frequent | ||||
| ||||
Ans. int[] arr = {1,-1,2,-3,3,-4,4,5,6,-5,-6,-7,-8,8,9,-9}; List positiveNumbers = new ArrayList<>(); List negativeNumbers = new ArrayList<>(); for(int i = 0; i < arr.length(); i ){ if(I < 0){ negativeNumbers.add(i); } else { positiveNumbers.add(i); } } System.out.println("Positive Numbers:" + positiveNumbers); System.out.println("Negative Numbers:" + negativeNumbers); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  code  program  coding Asked in 1 Companies | ||||