The Artima Developer Community
Sponsored Link

Java Buzz Forum
Can abstract class have Constructor in Java - Interview Question

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
Can abstract class have Constructor in Java - Interview Question Posted: Feb 11, 2013 5:14 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: Can abstract class have Constructor in Java - Interview Question
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
Yes, abstract class can have constructor in Java. You can either explicitly provide constructor to abstract class or if you don't, compiler will add default constructor of no argument in abstract class. This is true for all classes and its also applies on abstract class. For those who want to recall what is an abstract class in Java, its a class which can not be instantiated with new() operator or any other ways. In order to use abstract class in Java,  You need to extend it and provide a concrete class. Abstract class is commonly used to define base class for a type hierarchy with default implementation, which is applicable to all child classes. By the way difference between interface and abstract class in Java is also one of the popular and tricky Java questions and should be prepared well for Java interviews.  Can we declare constructor on abstract class in Java is followup of other  similar Java interview questions e.g. Can we override static method in Java?. Why interviewer ask this questions? Mainly because, trying to confuse programmer with fact that since abstract class can not be instantiated, why abstract class need constructor. In this Java Interview question article we will see that Abstract class can have constructor in Java.
Read more »

Read: Can abstract class have Constructor in Java - Interview Question

Topic: Codegeist is Back! Atlassian’s Developer Competition Returns Previous Topic   Next Topic Topic: History of Open Source

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use