Advertisement
abstract public void add();
Advertisement
//Java - Example of abstract class
abstract class A
{
abstract public void m();
abstract public void m2();
}
abstract class A
{
abstract public void m1();
public void m2()
{
System.out.println("Concrete method of abstract class");
}
}
//Java - Example of abstract class
abstract class A
{
abstract public void m();
}
class B extends A
{
public void m()
{
System.out.println("This method is inherited from the abstract class A");
}
}
//Java - Example of abstract class
abstract class A
{
private int i=10;
public void method()
{
System.out.println("method of class A");
}
}
//Java - Example of abstract class
class A
{
abstract public void m();
public void m2()
{
System.out.println("Concrete method of abstract class");
}
}
A.java:1: error: A is not abstract and does not override abstract method m() i
n A
class A
^
1 error
//Java - Example of abstract class
abstract class A
{
abstract void method1();
public void method()
{
System.out.println("Hello");
}
}
class Ex
{
public static void main(String[] ar)
{
A ob = new A();
}
}
D:\Java>javac Ab1.java
Ab1.java:16: error: A is abstract; cannot be instantiated
A ob = new A();
^
1 error
//Java - Example of abstract class
abstract class A
{
abstract public void m();
}
abstract class B extends A
{
}
//Java - Example of abstract class
interface A
{
void a();
void a_show();
}
abstract class B implements A
{
}
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement