Abstract_interfaces_practice_questions

package com.company;

import java.sql.SQLOutput;

abstract class pen{
abstract void Refill();
abstract void write();
}
class FountainPen extends pen{
@Override
void Refill() {
System.out.println("Refiiling");
}
@Override
void write(){
System.out.println("Write ");
}
void ChangeNib(){
System.out.println("Changing nib..");
}
}


class Monkey{
void Jump(){
System.out.println("Jump");
}
void Bite(){
System.out.println("Biting");

}
}
interface BasicAnimal{
void eat();
void sleep();
}
class Human extends Monkey implements BasicAnimal{
@Override
void Jump() {
super.Jump();
}

@Override
void Bite() {
super.Bite();
}
@Override
public void eat() {
System.out.println("Eating");
}
@Override
public void sleep() {
System.out.println("Sleeping");
}
void Default(){
System.out.println("This is human ");
}
}


abstract class telephone{
abstract void Ring();
abstract void Lift();
abstract void Disconnect();
}
class smartphone1 extends telephone{
@Override
void Ring() {
System.out.println("Ringing");
}

@Override
void Lift() {
System.out.println("Lifting");
}

@Override
void Disconnect() {
System.out.println("Disconnected");
}
void Games(){
System.out.println("Opening GtaV ...");
}
}


interface smartTvremote{
void operatesmart();

}
interface Tvremote extends smartTvremote{
void operate();

@Override
void operatesmart();
}
class tv implements Tvremote{
@Override
public void operatesmart() {
System.out.println("Smartremote by new Generation");
}

@Override
public void operate() {
System.out.println("Old remote");
}
}
public class abstact_interfaces_practice {
public static void main(String[] args) {
// Q1+Q2
FountainPen pen=new FountainPen();
// pen.write();
// pen.Refill();
// pen.ChangeNib();

// Q3
// Human hiii=new Human();
// hiii.Bite();
// hiii.eat();
// hiii.sleep();
// hiii.Jump();
// hiii.Default();

//Q5
// Monkey m=new Human(); //polymorphism
// m.Jump();
// // m.Default();--> This can't be run because of the default is not in a monkey method
//
// BasicAnimal bo=new Human();
// bo.eat();
// bo.sleep();
//// bo.Default();--> This can't be run because of the default is not in a BasicHuman method
//Q4
// smartphone1 sm1=new smartphone1();
// sm1.Games();
// telephone tel=new smartphone1();
// tel.Disconnect();

//Q6
// tv toy=new tv();
// toy.operate();
// toy.operatesmart();


}
}


Comments

Popular posts from this blog

Inheritence

Number_guessing_game

Dynamic_method_dipatch