class A
{
private void hello()
{
System.out.println("hi in class A");
}
}
class B extends A
{
private void hello() //Question is is this method overriding or not ?? please post your comments I will reply for the same
{
System.out.println("hi in class B");
}
}
class D extends B
{
protected void hello() // is this overriding B class method or not justify
{
System.out.println("hi in class D");
}
class C
{
public static void main(String... args)
{
B b1=new B();
b1.hello();
A a1=new B();
a1.hello(); // Another Question will this execute if yes explain ?n if no ,justify
}
}
class X
{
private void hello()
{
System.out.println("HI I am A");
}
}
class Y extends X
{
protected void hello()
{
System.out.println("HI I am B");
}
}
class Z extends Y
{
private void hello() ///cannt reducwe the visibility from protected to private
{
System.out.println("HI I am C");
}
}
public class InheritanceDemo {
public static void main(String[] args)
{
X x1=new Y();
x1.hello();//it will throw complie time error becoz confused X private method or Y
}
}
{
private void hello()
{
System.out.println("hi in class A");
}
}
class B extends A
{
private void hello() //Question is is this method overriding or not ?? please post your comments I will reply for the same
{
System.out.println("hi in class B");
}
}
class D extends B
{
protected void hello() // is this overriding B class method or not justify
{
System.out.println("hi in class D");
}
class C
{
public static void main(String... args)
{
B b1=new B();
b1.hello();
A a1=new B();
a1.hello(); // Another Question will this execute if yes explain ?n if no ,justify
}
}
class X
{
private void hello()
{
System.out.println("HI I am A");
}
}
class Y extends X
{
protected void hello()
{
System.out.println("HI I am B");
}
}
class Z extends Y
{
private void hello() ///cannt reducwe the visibility from protected to private
{
System.out.println("HI I am C");
}
}
public class InheritanceDemo {
public static void main(String[] args)
{
X x1=new Y();
x1.hello();//it will throw complie time error becoz confused X private method or Y
}
}