Home Answers Viewqa Java-Beginners java assignment

 
 


dhana
java assignment
1 Answer(s)      2 years and 10 months ago
Posted in : Java Beginners

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









Related Pages:
Assignment
Assignment  any one can help with a java assignment
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 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 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
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
Assignment of variables - JSP-Servlet
Assignment of variables  How to assign a javascript variable value to a java string variable. .... var strName="Tarunkanti Kar"; .... ... I want to access the script variable in java variable please give
Java assignment of variables - JSP-Servlet
Java assignment of variables   .... var strName="Tarunkanti Kar"; .... ... I want to access the script variable in java variable please give the code
assignment of variables - JSP-Servlet
assignment of variables  How to assign a javascript variable value to a java string variable. .... var strName="Tarunkanti Kar"; .... ... I want to access the script variable in java variable please give
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
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
Simple Assignment Operator
in Java that are know as compound assignment operators and can be used with all... Simple Assignment Operator       Assignment operator
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
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
Masters of Java Assignment Plugin
Masters of Java Assignment Plugin  ... : New Masters of Java Assignment Wizard which sets up project structure... assignment in the Masters of Java engine. Export Assignment Wizard which
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
sir i,have a assignment for these question plz help me sir - JavaMail
sir i,have a assignment for these question plz help me sir   1.Design a Java interface for ADT Stack. Develop two different classes... class hierarchy in Java. Write a test program to demonstrate polymorphism  
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 in OOP1
assignment in OOP1  Filename: CharCount.java Instructions: Ask a user to input a string Program should determine the number of occurrences of the letters contained on the input string based on the English alphabet. Note
Extended Assignment Operators
Java Notes: Extended Assignment Operators   In this tutorial you will learn how to use the extended assignment operators.   It's very common..., which kind of assignment to use is mainly a style or readability difference
sir i,have a another assignment for these question plz help me sir - JavaMail
sir i,have a another assignment for these question plz help me sir  ... a scientific calculator using event-driven programming paradigm of Java. 3. Write a multi-threaded Java program to print all numbers below 100,000
PHP Assignment Operators
Assignment Operator: We  have used the basic assignment operator in our life but a confusion may occur between an "assignment operator"... these are not. In the following examples different types of assignment operators
Java Operators
Java Operators       Simple Assignment Operator Assignment operator...; Bitwise and Bit Shift Operators In Java the bitwise
Java
Java  what is the difference between argument and assignment
Identify correct and incorrect statements or examples about the rules and semantics for relationship assignment and relationship updating in a CMP bean.
Identify correct and incorrect statements or examples about the rules and semantics for relationship assignment and relationship updating... for relationship assignment and relationship updating in a CMP bean. The assignment
Need Help in Java programming
Need Help in Java programming  Hello. Can someone please help me with writing the following program Java program that gives assignment details such as:assignment number,assignment name,due date,submission date,percentage marks
java basics
java basics  What is the difference between Assignment.... at declaration time. int i = 0; is an initialization Assignment means whenever we assign any value in any var. except const. int j = i; is an assignment
Data structures and algorithmms - Java Server Faces Questions
Data structures and algorithmms  Could u provide me with a solution to assignment COS212Assignment2008.doc on http://www.cs.up.ac.za
help to write java code
help to write java code  write a full code to produce a system... of assignment 1,assignment 2, midterms-test and lave work to get total marks... enter your carrymarks: matrik No: Text-field assignment 1: text-field /10 assignment
help to write java code
help to write java code  write a full code to produce a system... of assignment 1,assignment 2, midterms-test and lave work to get total marks... enter your carrymarks: matrik No: Text-field assignment 1: text-field /10
Java Stacks - Java Beginners
Java Stacks  Hello..Help me with this assignment plzz. Programming Assignment: A) Consider the outpatient pharamacy at University Hospital. At the entrance of the pharmacy, the patient gives his prescriptions
String.fromCharCode - Java Beginners
String.fromCharCode  This is a two part assignment. Part one... be a better way to do this, any clues? Student 070129 Assignment Four...; Student 070129 Assignment Four Enter text to be converted
Process Flows Output - Java Beginners
Process Flows Output  Hi, I have been asked to get a particular structure as the output. the assignment is as follows Any process flow has..... there might be a split activity sumwhere in the process, that splits the process flow
Java Program for Calculating Marks
Java Program for Calculating Marks  Hi Everyone, I have a assignment that requires me to a write simple java program that will calculate marks... of how to do this. Please someone help me with this assignment. Thank you very
Java Program for Calculating Marks
Java Program for Calculating Marks  Hi Everyone, I have a assignment that requires me to a write simple java program that will calculate marks... of how to do this. Please someone help me with this assignment. Thank you very
Java Program for Calculating Marks
Java Program for Calculating Marks  Hi Everyone, I have a assignment that requires me to a write simple java program that will calculate marks... of how to do this. Please someone help me with this assignment. Thank you very
Java Program for Calculating Marks
Java Program for Calculating Marks  Hi Everyone, I have a assignment that requires me to a write simple java program that will calculate marks... of how to do this. Please someone help me with this assignment. Thank you very
java - Java Interview Questions
java  hello sir this is suraj .i wanna ask u regarding interview questins in java .wat normally v see in interviews (tech apptitude)is one line question..lik for ex What is the difference between Assignment and Initialization
Java with Arrays
Java with Arrays  I was given the assignment to create two parallel arrays; both of size 50 (declares 50 as a constant) One is an array of strings and hold names, While the other is an array of numbers (int or double) to hold
Grading system - Java Beginners
Grading system  gud day...cn i ask for a javascript of a grading system text box input typed... that calculates quiz and assignment and a prelim + a quiz and assingment and a midterm + a quiz and assingment and a Semifinal
Sorting algorithms - Java Beginners
Sorting algorithms  I'v being given an assignment and I still couldn't find a proper answer for the following questions.Can anyone pls pls help me wi it? 1)Compare and contrast efficiencies of Shell,Quick,Heap and Radix sort
java Date - Java Beginners
java Date  Dear sir I have an assignment, It is .. "Develop Date class in java similar to the one available in java.util package.Use JavaDoc comments " Please help me to do the assignment, and tell me the steps
Java program problem
Java program problem  Hi, I took the chance to login here in your educational page due to my questions in mind about my java programming assignment. Please help me. I provided below the program assignment. Thanks in advance
Need help on JAVA JSP
Need help on JAVA JSP  Hi, I have never worked on java and I have been given an assignment where I have to fix existing issues in the tool(created using JAVA JSP). e.g. Tool does not adjust with the resolution of the screen
java program - Java Beginners
java program  ( JUnit Tests) 1. JUnit test (CollectionTest.java.... Notice 1: You are not allowed to use any of the classes in the Java Class Library... Queue code from the first assignment. 2. Write a JUnit test (QueueTest.java

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.