Core Java - Interview Questions and Answers for 'Abstract' | 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

   



Core Java - Interview Questions and Answers for 'Abstract' - 40 question(s) found - Order By Rating

next 30
 Q1. Interface vs AbstractionCore Java
 This question was recently asked at 'Oracle financial services'.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     interface vs abstraction  interfacing vs abstraction  relation between interface and abstraction  How interface provide abstraction     Asked in 1 Companies


 Q2. Does abstract class have public constructor? Core Java
Ans. Yes, an abstract class can have a constructor in Java.

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

   Like         Discuss         Correct / Improve     abstract class  public constructor     Asked in 1 Companies


 Q3. Difference between Base Class, Derived Class , Abstract Class and Concrete Class ?Core Java
Ans. Base Class is a relative term used to signify the Parent class in Parent - Child or Base - derived relationship.

Derived Class is a relative term used to signify the Child class in Parent - Child or Base - derived relationship.

Abstract Class is a class that is not allowed to be instantiated and hence can serve only a base class for it's usage.

Concrete Class is the class which is supposed to be instantiated and hence provide definition for all implementing interface methods and extending abstract methods.

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

   Like         Discuss         Correct / Improve     Base Class   Derived Class    Abstract Class   Concrete Class


 Q4. Can an abstract class be a derived class ?Core Java
Ans. Yes, an abstract class can extend another class.

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

   Like         Discuss         Correct / Improve     abstract class


 Q5. What is the relationship between Base Class and Abstract Class ?Core Java
Ans. Abstract Class is a class that's only allowed to be a Base class for it's usage. It can never be instantiated on it's own.

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

   Like         Discuss         Correct / Improve     base class  abstract class      basic


 Q6. Can we declare an Interface with abstract keyword ? Core Java
Ans. Yes

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

   Like         Discuss         Correct / Improve     abstract keyword


 Q7. Can we have multiple inheritance in java using abstract class ?Core Java
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


 Q8. 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


 Q9. What is abstraction ?Design
Ans. Abstraction is a process of hiding the implementation details and describing only the functionality to the user.

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

   Like         Discuss         Correct / Improve     bstraction  oops concepts  oops principle     Asked in 22 Companies


 Q10. What are the advantage of Abstract classes over interfaces with respect to Java 7 ? and What changed in Java 8 to help facilitate that in Java 8 ?Core Java
Ans. Abstract Classes provide default implementations of methods that are inherited by the classes that extend them, which was not the case for Interfaces. This changed in Java 8, where default implementations are provided for methods.

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

   Like         Discuss         Correct / Improve     abstract classes  interfaces  default method     Asked in 1 Companies      expert


 Q11. 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


 Q12. If an Abstract class has only abstract methods, What's the difference between such a class and an interface ?Core Java
Ans. Such a class still can have member elements which can be inherited and hence facilitate code reuse. Moreover Abstract class can have non final static elements whereas interfaces are only allowed to have static final elements.

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

   Like         Discuss         Correct / Improve     abstract class   interfaces     Asked in 2 Companies      Basic


 Q13. What is the importance of Abstract Class ?Core Java
Ans. Abstract classes provide a mechanism of interfacing ( using abstract method ) as well as code reuse through inheritance ( extending abstract class )

Comparing to concrete class they have an advantage of providing interface which a concrete class doesn't provide.

Comparing to interfaces they have an advantage of providing code reuse through inheritance which interfaces dont provide.

  Sample Code for abstract class

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

   Like         Discuss         Correct / Improve     abstract class  importance of abstract class      Basic        frequent


 Q14. Why can't we create an instance of abstract class ? Why is it restricted by compiler ?Core Java
Ans. Because Abstract class is incomplete i.e there are abstract methods that needs to be defined by extending classes.

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

   Like         Discuss         Correct / Improve     abstract class


 Q15. What was the need of creating an abstract class in Java when we cannot instantiate an object of it ?Core Java
Ans. The objective of an abstract class is to provide an interface as well as code reuse. Though we cannot instantiate an instance of abstract class but we can reuse the code by extending such a class. Moreover abstract class provides interfacing to outside components just like interfaces.

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

   Like         Discuss         Correct / Improve     abstract class


 Q16. Can we override an abstract method with abstract method in the derived class ?Core Java
Ans. Yes, but in that case the derived class itself should be abstract. We cannot have an object of a class without definition for the method which has been declared abstract in the parent.

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

   Like         Discuss         Correct / Improve     overriding  overriding abstract methods  abstract methods


 Q17. Can we override abstract methods ?Core Java
Ans. Abstract methods are the methods that need to be overridden in the derived class ( either as implementing method or again abstract method ) so it's not only allowed but its required to override abstract method in the derived class.

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

   Like         Discuss         Correct / Improve     overriding  abstract methods  overriding abstract methods


 Q18. Can we overload abstract methods ?Core Java
Ans. Yes

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

   Like         Discuss         Correct / Improve     overloading  abstract methods  overloading abstract methods


Very frequently asked. Usually asked in this format or as difference with interfaces / concrete classes.
  Q19. What is an abstract class ?Core Java
Ans. Abstract class is the class that is not supposed to be instantiated. The purpose of the class to only have extension to the derived class.

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

   Like         Discuss         Correct / Improve     abstract class     Asked in 6 Companies      basic        frequent


 Q20. When should we use Abstract classes ?Core Java
Ans. Abstract classes provide a mechanism of interfacing ( using abstract method ) as well as inheritance ( extending abstract class ). So they should be used in place of interfaces in case there is some code ( methods ) or object body ( member elements ) that can be reused with inheritance.

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

   Like         Discuss         Correct / Improve     abstract classes     Asked in 1 Companies


 Q21. Can we declare a main method as abstract ?
Ans. No. Static methods cannot be overridden and hence make no sense to be declared abstract.

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

   Like         Discuss         Correct / Improve     main method   abstract

Try 1 Question(s) Test


 Q22. Can you give a real world example of Encapsulation and Abstraction ?Core Java
Ans. Car Engine is an example of encapsulation and abstraction. You ignite the car using an interface called starter and least bothered about how the tire actually moves (This is abstraction). The engine encapsulates the complete process to itself only and doesn't allow you to start the other components like the radiator etc ( this is excapsulation )

 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  abstraction  oops  oops features  java features     Asked in 13 Companies


Very frequently asked to Fresh graduates.
  Q23. What is the difference between Encapsulation and Abstraction?Core Java
Ans. 1.Abstraction solves the problem at design level while encapsulation solves the problem at implementation level

2.Abstraction is used for hiding the unwanted data and giving relevant data. while Encapsulation means hiding the code and data into a single unit to protect the data from outside world.

3. Abstraction lets you focus on what the object does instead of how it does it while Encapsulation means hiding the internal details or mechanics of how an object does something.

4.For example: Outer Look of a Television, like it has a display screen and channel buttons to change channel it explains Abstraction but Inner Implementation detail of a Television how CRT and Display Screen are connect with each other using different circuits , it explains Encapsulation.

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

   Like         Discuss         Correct / Improve     java   oops   oops concepts   encapsulation  object oriented programming (oops)  oops concepts   abstraction   basic interview question   encapsulation vs abstraction     Asked in 10 Companies      basic        frequent

Try 2 Question(s) Test


 Q24. Difference between Abstract and Concrete Class ?Core Java
Ans. Abstract classes are only meant to be sub classed and not meant to be instantiated whereas concrete classes are meant to be instantiated.

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

   Like         Discuss         Correct / Improve     java   oops   abstract classes   Abstract vs Concrete Class     Asked in 1 Companies      basic        frequent


 Q25. Difference between Factory and Abstract Factory Design Pattern ?Design
Ans. Factory Pattern deals with creation of objects delegated to a separate factory class whereas Abstract Factory patterns works around a super-factory which creates other factories.

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

   Like         Discuss         Correct / Improve     java   design pattern   factory design pattern   abstract factory design pattern   factory vs abstract factory      expert


 Q26. Can we declare an abstract method private ?
Ans. No Abstract methods can only be declared protected or public.

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

   Like         Discuss         Correct / Improve     java   abstract   oops   access specifier   private   yes-no      intermediate        rare


 Q27. What are the design considerations while making a choice between using interface and abstract class ?Core Java
Ans. Keep it as a Abstract Class if its a "Is a" Relationsship and should do subset/all of the functionality. Keep it as Interface if its a "Should Do" relationship.

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

   Like         Discuss         Correct / Improve     java   oops   abstract classes   interfaces   advanced     Asked in 3 Companies


 Q28. Difference between Abstraction and Implementation hiding ?
Ans. Implementation Hiding is a broader concept. Abstraction is a way of implementation hiding in OOP's.

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

   Like         Discuss         Correct / Improve     java   oops   oops concepts   abstraction   hiding information   build management


 Q29. What are the examples of Abstraction in Java ?
Ans. function calling - hides implementation details
wrapper classes
new operator - Creates object in memory, calls constructor

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

   Like         Discuss         Correct / Improve     java   oops   oops concepts   abstraction


 Q30. what will be the output ?

class Animal {
public void eat() throws Exception {
}
}

class Dog2 extends Animal {
public void eat(){}
public static void main(){
Animal an = new Dog2();
an.eat();
}
}
Core Java
Ans. Compile Time Error: Unhandled exception type Exception

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

   Like         Discuss         Correct / Improve     java   code   coding   overridding   late binding   exception handling   abstract class   abstract methods


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: