Java Codes: Write A Program To Implement Polymorphism, Inheritance Using Methods in Java
Java Codes: Write A Program To Implement Polymorphism, Inheritance Using Methods in Java
Java Codes: Write A Program To Implement Polymorphism, Inheritance Using Methods in Java
class X
{
X()
{
System.out.println(Inside super class parameterized constructor);
fun();
}
void fun()
{
System.out.println(Parent);
}
}
class Y extends X
{
Y()
{
System.out.println(Inside child class parameterized constructor);
}
void fun()
{
System.out.println(Child);
}
}
class Demo extends Y
{
public static void main(String args[])
{
Y d=new Y();
d.fun();
}
}
Write a program to implement packages and interface in Java
package p1;
public class A
{
public void fact(int x)
{
int i, f=1;
for(i=x;i>1;i--);
f=f*i;
System.out.println(The factorial is:+f);
}
}
interface number
{
final int n=5;
void show();
)
import p1.*;
public class B implements number
{
void show()
{
fact(n);
}
public void main(String args[])
{
B ab=new B();
ab.show();
}
}