Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can you have a constructor in abstract class?

Answer Posted / swapnil bhosale

ya ,we can define and call costructor in abstract class but just by using super keyword in base class ,but keep in mind we cannot create instance ob abstract class,this just another way to call contructor in abstract class,go run and see o/p
import java.io.*;
abstract class A
{
A()
{
System.out.println("hi am conS in absT");
}
}
class AA extends A
{
AA()
{
super();//calling abstract constructor
System.out.println("hi i am conS in sub class ");
}
}
class AbstConst2
{
public static void main(String arg[])
{
AA ob=new AA();//creating instance of base class consT
}
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you add spaces in java?

942


If I only change the return type, does the method become overloaded?

876


What is polymorphism in java? What are the kinds of polymorphism?

1008


What is == and === in javascript?

994


Can a final variable be null?

957


How do you decide when to use arraylist and linkedlist?

944


Does sprintf add a null terminator?

1041


What is encapsulation in java?

1049


Explain the difference between abstraction and encapsulation.

924


What is the main method java?

970


What are constants and how to create constants in java?

938


What is jar?

1068


What is a function argument in java?

946


Why do we create threads in java?

1149


How is abstraction implemented in java ?

921