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

What is the use of set in java?

837


Why do we need wrapper class?

730


What is space character in java?

769


What is percentage in java?

753


What is the meaning of 3 dots in java?

874


How do you sort a string in alphabetical order in java?

732


Detail discussions on JVM, memory management and garbage collector.

741


Can you instantiate the math class in Java?

802


What are the features of java?

734


define the terminology association.

867


How is abstraction implemented in java ?

714


Is string serializable in java?

739


What is the purpose of garbage collection in java? When is it used?

787


What is the main method java?

744


What is meant by method?

775