java assignment

Ads
 

java assignment

I got assignment in "design a vehicle class hierarchy in java,write a test program to demonstrate polymorphism".please send me the necessary codings and algorithm.
View Answers

August 7, 2010 at 10:29 AM

Hi Friend,

Try the following code:

class Vehicle {
void test(){}
}
class Bus extends Vehicle{
void test()
{
System.out.println("I am a bus");
}
}
class Car extends Vehicle{
void test()
{
System.out.println("I am a car");
}
}
class Bike extends Vehicle{
void test()
{
System.out.println("I am a bike");
}
}
public class Polymorphism{
public static void main(String[]args){
Vehicle[] v = new Vehicle[3];
v[0]= new Bus();
v[1]=new Car();
v[2]=new Bike();
for(int i=0;i<v.length;i++){
v[i].test();
}

}
}

Thanks

Ads









Related Tutorials/Questions & Answers:
JAVA assignment
JAVA assignment  Is there any1 on this site who can write a java... want small java application? Please specify the type of java program you want. Have a look at the following link. This link consists of several java program
java assignment
java assignment  Write an application that allows the user to choose insurance options in JCheckBoxes. Use a ButtonGroup to allow the user to select only one of two insurance types√Ę‚?¨‚??HMO (health maintenance organization
Advertisements
java assignment - Java Beginners
java assignment  I got assignment in "design a vehicle class hierarchy in java,write a test program to demonstrate polymorphism".please send me the necessary codings and algorithm.  Hi Friend, Try the following code
Java with OOP assignment (Eclipse)
Java with OOP assignment (Eclipse)  How do i control the length of characters in an input? E.g.: Enter your name > Hi * Name too short
Assignment
Assignment  any one can help with a java assignment
Assignment Question on java programming
Assignment Question on java programming  Can somone help me on this . Thx You are required to write a complete Java program for a simple grading system. At the beginning of the system, you need to input number of students
Assignment operator in java
Assignment operator in java Assignment operator is very common to almost all... the value to the variable lying on the left side. Java assignment operator... to be assigned to the variable to the left side. Assignment operator is also used
assignment
assignment  Write a Java program that reads a file and prints the amount of palindromes contained within the file
assignment
assignment  Hi guys i wanna Know how to code for the following output in java. * ** *** **** ***** please guys if there is any1 who can help please do.  System.out.printf
assignment
: Write a Java program that will declare an array of THREE (3) Circle objects based
Java with OOP assignment (Eclipse) - Java Beginners
Java with OOP assignment (Eclipse)  "THREE Ts GAME" *Description.... In this assignment, you are required to write both the "tic-tac-toe" and "toe-tac-tic" games using Java. When your game application started, the players will be able
Assignment Operators in java 7
Assignment Operators in java 7 In this section you will learn about the Assignment Operators. This is one type of operators. Assignment Operators... to the variable by using any assignment operator. Your variables are placed
Assignment problem
Assignment problem  hello, I am designing a program partaining job assingment using hungarian algorithm,but i am totally confused, please help me out
my assignment
...this is my assignment....plz
Programming Assignment
Programming Assignment  Hey there, We were given an assignment to write a program to read 10 student marks from the keyboard without using an Array (only using switch statements, if statements or loops). As each mark is input
Assignment
ModuleNotFoundError: No module named 'assignment'
ModuleNotFoundError: No module named 'assignment'  Hi, My Python... 'assignment' How to remove the ModuleNotFoundError: No module named 'assignment' error? Thanks   Hi, In your python environment you
Urgent programming assignment
Urgent programming assignment   Hi, I am an Indian student in USA.I have been able to write all the java codes successfully , however this one is giving me tremors.Any help would be highly appreciated.I am attaching
Simple Assignment Operator
in Java that are know as compound assignment operators and can be used with all... Simple Assignment Operator       Assignment operator
Week 7 - Assignment
Week 7 - Assignment  Write a java program that takes the input from a file of numbers of type int and outputs the sum, count, and average of the numbers on the screen as shown in the example report below. The file contains
i have problem in that program to my assignment sir - JavaMail
i have problem in that program to my assignment sir   Develop a programmer's editor in Java that supports syntax-highlighting, compilation support, debugging support, etc
ModuleNotFoundError: No module named 'acs_examine_student_assignment'
ModuleNotFoundError: No module named 'acs_examine_student_assignment' ...: No module named 'acs_examine_student_assignment' How to remove the ModuleNotFoundError: No module named 'acs_examine_student_assignment' error
ModuleNotFoundError: No module named 'distributions-udacity-assignment'
ModuleNotFoundError: No module named 'distributions-udacity-assignment' ...: ModuleNotFoundError: No module named 'distributions-udacity-assignment' How to remove the ModuleNotFoundError: No module named 'distributions-udacity-assignment'
ModuleNotFoundError: No module named 'distributions-udacity-assignment'
ModuleNotFoundError: No module named 'distributions-udacity-assignment' ...: ModuleNotFoundError: No module named 'distributions-udacity-assignment' How to remove the ModuleNotFoundError: No module named 'distributions-udacity-assignment'
ModuleNotFoundError: No module named 'django-assignment-desk'
ModuleNotFoundError: No module named 'django-assignment-desk'  Hi...: No module named 'django-assignment-desk' How to remove the ModuleNotFoundError: No module named 'django-assignment-desk' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-assignment-desk'
ModuleNotFoundError: No module named 'django-assignment-desk'  Hi...: No module named 'django-assignment-desk' How to remove the ModuleNotFoundError: No module named 'django-assignment-desk' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-assignment-desk'
ModuleNotFoundError: No module named 'django-assignment-desk'  Hi...: No module named 'django-assignment-desk' How to remove the ModuleNotFoundError: No module named 'django-assignment-desk' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-assignment-desk'
ModuleNotFoundError: No module named 'django-assignment-desk'  Hi...: No module named 'django-assignment-desk' How to remove the ModuleNotFoundError: No module named 'django-assignment-desk' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-assignment-desk'
ModuleNotFoundError: No module named 'django-assignment-desk'  Hi...: No module named 'django-assignment-desk' How to remove the ModuleNotFoundError: No module named 'django-assignment-desk' error? Thanks   Hi
ModuleNotFoundError: No module named 'keystone-json-assignment'
ModuleNotFoundError: No module named 'keystone-json-assignment'  Hi...: No module named 'keystone-json-assignment' How to remove the ModuleNotFoundError: No module named 'keystone-json-assignment' error? Thanks  
ModuleNotFoundError: No module named 'odoo9-addon-openeducat-assignment'
ModuleNotFoundError: No module named 'odoo9-addon-openeducat-assignment' ...: ModuleNotFoundError: No module named 'odoo9-addon-openeducat-assignment' How to remove the ModuleNotFoundError: No module named 'odoo9-addon-openeducat-assignment'

Ads