package javaapplication19;
abstract class
animal{
abstract void
eat();
abstract void run();
public void body()
{
System.err.println("two eye and two ear");
}
}
class lion extends animal{
public void
display(){
System.out.println("king");
}
@Override
void eat() {
System.err.println("Meat");
}
@Override
void run() {
System.err.println("fast");
}
}
class cow extends animal{
public void
display(){
System.out.println("mother");
}
@Override
void eat() {
System.err.println("grass");
}
@Override
void run() {
System.err.println("slow");
}
}
public class JavaApplication19 {
public static void
main(String[] args) {
lion obj = new
lion();
obj.body();
obj.eat();
obj.display();
obj.run();
}
}
INTERFACE
/*
* To change this
license header, choose License Headers in Project Properties.
* To change this
template file, choose Tools | Templates
* and open the
template in the editor.
*/
package javaapplication20;
interface mother{
void money();
void dis();
}
class father{
public void
money(){
System.err.println("10000");
}
void disp(){
System.err.println("m");
}
}
class son extends father implements mother{
public void
display()
{
System.err.println("son");
}
@Override
public void dis()
{
throw new
UnsupportedOperationException("Not supported yet."); //To change body
of generated methods, choose Tools | Templates.
}
}
public class JavaApplication20 {
public static void
main(String[] args) {
son obj = new
son();
obj.money();
}
}
No comments:
Post a Comment