Abstract
package com.company;
/*Abstract class ke help se aur dusri class banegi standard abstract class have no object
for abstract class extend the other class should have extract or the override the abstract
_ when an abstract class is sub classed ,the subclass usually implementations for all of the methods in parent class.If doesn't it must be declared abstract
*/
abstract class Parent{
public Parent(){
System.out.println("Mai base2 ka constructor hoon ");
}
public void sayhello(){
System.out.println("Hello");
}
abstract public void greet();
abstract public void greet2();
}
class child2 extends Parent{
@Override
public void greet(){
System.out.println("Good morning ");
}
@Override
public void greet2(){
System.out.println("Good Evening ");
}}
abstract class child3 extends Parent{
public void th(){
System.out.println("I am good ");
}
}
public class Abstract {
public static void main(String[] args) {
// Parent p=new parent(); It is the abstract class ----error
child2 c=new child2();
c.greet();
c.greet2();
// child3 c=new child3(); It is the abstract class ----error
}
}
//o\p
Mai base2 ka constructor hoon Good morning Good Evening
Comments
Post a Comment