Java - Interview Questions and Answers for 'Abstract' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Abstract' - 33 question(s) found - Order By Newest

Very frequently asked to Fresh graduates.
  Q1. What is the difference between Encapsulation and Abstraction?Core Java
Anonymous
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   abstraction   basic interview question     Synechron  Amazon  HCL Technologies  Tata Consultancy (TCS)  Wipro  Infosys Technologies  3DPLM Software Solutions      basic        frequent

Try 2 Question(s) Test


 Q2. Can you give a real world example of Encapsulation and Abstraction ?Core Java2016-05-29 13:47:31

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  abstraction  oops  oops features  java features     MAQ Software  Daffodil Software  Quickstart Global  Alliance Global Services  InfoStretch  Intelligrape  Prowareness  Support.com  Cognizant (CTS)  BNT SOFT  Clairvoyant TechnoSolutions  Suyati Technologies  3DPLM Software Solutions


Very Frequently asked. Have been asked in HCL Technologies very frequently ( based on 2 feedback ). Among first few questions in many interviews.
  Q3. Differences between abstract class and interface ?Core Java
Admin
info@buggybread.com
Ans. Abstract classes can have both abstract methods ( method declarations ) as well as concrete methods ( inherited to the derived classes ) whereas Interfaces can only have abstract methods ( method declarations ).

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

   Like      Discuss      Correct / Improve     java   classes   abstract class   interfaces     GlobalLogic  HCL Technologies  Tata Consultancy (TCS)  Infosys  Wipro  Mindtree  CapitalOne  Accenture  IBM India  Infoview Technologies  Salesforce  AT&T  United Health Group (UHG)  Verilogue  Amazon  Expeditors  Syntel  SalesForce  Cornerstone OnDemand  Expedia  OLA  NSF International  Copper Mobile  Think Future Technologies  MorphoTrust  Global Healthcare  Prodigious  Internet Brands  SciQuest  arvato Systems  iCIMS  Ideas2IT  virtusa polaris  Vitech Systems  Cognizant (CTS)      basic        frequent


 Q4. Difference between Abstract and Concrete Class ?Core Java
Anonymous
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   basic interview question     Goldman Sachs      basic        frequent


 Q5. Difference between Factory and Abstract Factory Design Pattern ?Design
Anonymous
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   technical lead      expert


 Q6. What are the design considerations while making a choice between using interface and abstract class ?Core Java
Anonymous
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     ADP  AI corporation


 Q7. How is Abstraction implemented in Java ?Core Java
Admin
info@buggybread.com
Ans. Abstraction is provided in Java by following ways -

Coding to the ( Interfaces / Abstract Classes ) or contracts

By Encapsulating details within classes and exposing the minimal Door ( few public methods )

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

   Like      Discuss      Correct / Improve     java   oops concepts   abstraction   interfaces   abstract class   encapsulation     Accenture  Bureau Veritas      basic        frequent


 Q8. If an Abstract class has only abstract methods, What's the difference between such a class and an interface ?Core Java2017-05-07 07:26:29

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     Tata Consultancy (TCS)      Basic


Very frequently asked. Usually asked in this format or as difference with interfaces / concrete classes.
  Q9. What is an abstract class ?Core Java2017-01-10 13:12:20

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     Multivision  Starkey Hearing Technologies  Avaya  Tridium  LinkedIn  Acute Informatics      basic        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. Can we declare an abstract method private ?
Anonymous
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


 Q11. Difference between Abstraction and Implementation hiding ?
Anonymous
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


 Q12. What are the examples of Abstraction in Java ?
Admin
info@buggybread.com
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


 Q13. 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
Admin
info@buggybread.com
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


 Q14. Will this code Work ? If not , Why ?

java.util.Calendar c = new java.util.Calendar();
Core Java
Admin
info@buggybread.com
Ans. No. It gives the error "Cannot Instantiate the type Calendar". Calendar is an abstract class and hence Calendar object should be instantiated using Calendar.getInstance().

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

   Like      Discuss      Correct / Improve     java   date   calendar   abstract class   yes-no


 Q15. Is java.util.Date an abstract Class ? Is java.util.Calendar an abstract Class ?Core Java
Admin
info@buggybread.com
Ans. Date is not a abstract class whereas Calendar is.

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

   Like      Discuss      Correct / Improve     java   date   calendar   abstract class


 Q16. Will this code compile ?

public class BuggyBread1{
abstract public void test();
}
Core Java
Admin
info@buggybread.com
Ans. No. It will give the compilation error saying "The abstract method test in type BuggyBread1 can only be defined by an abstract class".

We need to declare the class abstract for it to have any abstract method.

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

   Like      Discuss      Correct / Improve     java   oops   abstract class   abstract methods   java compilation error


 Q17. Will this Code compile ?

abstract public class BuggyBread1{
abstract public void test(){};
}
Core Java
Admin
info@buggybread.com
Ans. No. This will give a compilation error saying "Abstract methods do not specify a body".

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

   Like      Discuss      Correct / Improve     java   abstract classes   abstract methods   java compilation error   java coding   java code   coding   yes-no


 Q18. What is ADT or Abtstract Data Type ?Core Java

Ans. ADT is a container which holds different types of objects with specifications.

For example - Stack, Array, Liked list, Tree

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

   Like      Discuss      Correct / Improve     data types  abstract data types


 Q19. Why can't we declare a class abstract as well as final ?Core Java

Ans. Abstract means that the class is only meant to be subclassed whereas final means that it cannot be subclassed so both concepts - abstract and final are actually mutually exclusive and hence not permitted together.

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

   Like      Discuss      Correct / Improve     abstract   final   java keywords     VirtusaPolaris



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. In the following code , how many methods needs to be implemented in Class B ?

public interface A{
   public void method1();
   public void method2();
   public void method3();
}

abstract class B implements A{
}
Core Java

Ans. As Class B has been declared abstract , we can either implement any of these methods and just declare rest of them abstract.

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

   Like      Discuss      Correct / Improve     interfaces  abstract classes  code  coding

Try 2 Question(s) Test


 Q21. What should a class do if its extending an abstract class ?Core Java

Ans. It should either implement the abstract methods or re-declare them abstract.

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

   Like      Discuss      Correct / Improve     abstract class     TCS  Niftek      Basic        Frequent


 Q22. Can we declare a main method as abstract ?2016-06-21 13:11:31

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


 Q23. When should we use Abstract classes ?Core Java2016-12-23 20:12:52

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     Polaris


 Q24. Can we overload abstract methods ?Core Java2017-03-01 09:43:18

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


 Q25. Can we override abstract methods ?Core Java2017-03-01 09:45:08

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


 Q26. Can we override an abstract method with abstract method in the derived class ?Core Java2017-03-01 09:46:35

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


 Q27. What was the need of creating an abstract class in Java when we cannot instantiate an object of it ?Core Java2017-04-03 09:18:49

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


 Q28. Why can't we create an instance of abstract class ? Why is it restricted by compiler ?Core Java2017-04-03 13:27:57

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


 Q29. What is the importance of Abstract Class ?Core Java2017-04-30 09:37:41

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



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q30. What are the uses of Abstraction ?Core Java2017-08-03 07:41:32

 This question was recently asked at 'Zipdial mobile solutions'.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     oops concepts  abstraction     Zipdial mobile solutions


 Q31. 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 Java2017-08-17 19:28:33

 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     abstract classes  interfaces  default method      expert


 Q32. Which of the following is not true for abstract classes ?Core Java
a. Abstract Class is only meant to be sub classed and not supposed to be instantiated.
b. Abstract class handlers can be used to handle derived class objects.
c. We can't have an abstract class without abstract methods.
d. Abstract class has member elements.

Ans.c. We can't have an abstract class without abstract methods.

 Q33. Which of the following can be declared abstract ?Core Java
a. static methods
b. instance methods
c. static variable
d. instance variables

Ans.b. instance methods



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: