Exp 5
**** Exp 5: Concept of single inheritance*******
public class inherit {
public static void main(String[] args) {
// TODO Auto-generated method stub
derived obj= new derived();
obj.display();
}
}
class base
{
int a=10;
}
class derived extends base
{
void display()
{
System.out.println("Value of a ="+a);
}
}
******OUTPUT*****
Value of a =10
public class inherit {
public static void main(String[] args) {
// TODO Auto-generated method stub
derived obj= new derived();
obj.display();
}
}
class base
{
int a=10;
}
class derived extends base
{
void display()
{
System.out.println("Value of a ="+a);
}
}
******OUTPUT*****
Value of a =10
Comments
Post a Comment