write a simple program inheritance?

Answer Posted / dhawal

class A
{
int a=10;
}
class B extend A
{
public static void main(String[] a)
{
B objB;
objB=new A();
System.out.println("Value of a is"+objB.a);
}
}

Is This Answer Correct ?    2 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are the imports checked for validity at compile time? Will the code containing an import such as java.lang.abcd compile?

596


Can a constructor call another constructor?

567


What if static is removed from main method?

575


How to split arraylist elements in java?

605


design an lru cache in java?

546






What is the purpose of skeleton and stub?

590


What are the two types of java programming?

539


How many inner classes can a class have?

582


Can we nested try statements in java?

632


What is the difference between break and continue statements?

550


What are the features of junit?

602


What is difference between path and classpath in java?

487


What is core java called?

526


What is a string token?

536


how does the run() method in runnable work? : Java thread

516