Search This Blog

save java programs with".java" extension

examples :

helloworld.java
sample.java
match.java
send-mail.java

quick links

Abstract Demo

import java.util.Scanner;
/*1*/abstract class vehicle5
{
private int wheel;
vehicle5()
{
System.out.println("Some vehicles instanciated");
wheel=4;
}
void start()
{
System.out.println("Every vehicle starts like this");
}
abstract void move();
}
class car6 extends vehicle5
{
void move()
{
System.out.println("Exellent transportation");
}
}
class zeep extends vehicle5
{
void move()
{
System.out.println("Good transportation");
}
}
class AbstractExample {

public static void main(String[] args) {
vehicle5 v;
Scanner s = new Scanner(System.in);
System.out.println("What vehicle you want car/zeep");
String choice=s.next();
if(choice.equals("car"))
v=new car6();
/*if(choice.equals("zeep"))
v=new zeep();*/ //error
else
v=new zeep();
v.start();
v.move();
}
}