need code

need code

Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional attributes:loading capacity( 100 tons?).Add a behavior to change the color and loading capacity. Display the updated truck details.

View Answers

January 21, 2011 at 11:18 AM

Hi Friend,

Here is the required code:

import java.util.*;
class  Vehicle
{
    int no;
    String model;
    String manufacturer;
    String color;

    Vehicle(int no,String model,String manufacturer,String color){
        this.no=no;
        this.model=model;
        this.manufacturer=manufacturer;
        this.color=color;
    }
}
    public class Truck extends Vehicle{
        int capacity;
        Truck(int no,String model,String manufacturer,String color,int capacity){
        super( no, model, manufacturer, color);
        this.capacity=capacity;
        }
    void show(){
      System.out.println("No = " + no);
      System.out.println("Model = " + model);
      System.out.println("manufacturer = " + manufacturer);
      System.out.println("Color = " + color);
      System.out.println("Capacity = " + capacity);
    }

    public static void main(String[] args) 
    {
    Scanner input=new Scanner(System.in);
    System.out.println("Truck No: ");
    int no=input.nextInt();

    System.out.println("Model: ");
    String model=input.next();

    System.out.println("Manufacturer: ");
    String manufacturer=input.next();

    System.out.println("Color: ");
    String color=input.next();

    System.out.println("Loading Capacity: ");
    int cap=input.nextInt();

        Truck t=new Truck(no,model,manufacturer,color,cap);
        System.out.println("****Truck Details****");
        System.out.println();
        t.show();
    }
}

Thanks









Related Tutorials/Questions & Answers:
need of code
need of code  howto convert greyscale image to binary image in java
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
Advertisements
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
Need sample code
Need sample code  Need code for graph which shows the performance comparission of aprior algorithm and coherent rule algorithm.plz can any one help me i need in a week
need JSP Code.
need JSP Code.  **Hi I need JSP code for selling Products which are in Database. Please can any one help for this.URGENT... Thank You..! Abhijeet
Need a JSP CODE
Need a JSP CODE  *Hi I need JSP source code for selling products which are in database.. please can any one help me ..URGENT* Thank You
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I want to use some code in, and I am proficient in python but that looks fairly simple so I was hoping java would look more impressive. So I just need a visual
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I want to use some code in, and I am proficient in python but that looks fairly simple so I was hoping java would look more impressive. So I just need a visual
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I want to use some code in, and I am proficient in python but that looks fairly simple so I was hoping java would look more impressive. So I just need a visual
need code - Java Beginners
need code   i want to take the html coding. if user give a input html file the out is html coding in text file. i want to take html coding only... are sending you a sample code which will be helpful to you. import java.io.
need code for file browser
need code for file browser  hi, i need to write a code to browse the file in my computer using Jsp or java.. what is the code for file browser?   JSP Code for browsing: 1)page.jsp: <%@ page language="java" %>
Need a jsp code
Need a jsp code  I need a jsp code in which when i select a value.....please help me for this.   The given code retrieves the employee name...)For the above code, we have created following table: CREATE TABLE `employee
code need - Java Beginners
code need  hi i want to code doing for this. If i have enter the text file in my java project. example input is 1,2,3,4,5(it is in input text file...)  Hi Friend, Try the following code. We hope this will help you
Need source code - Swing AWT
Need source code  Hai, I need a source code for developing the project, title is "Face Recognition" and the backend as My-sql.... Thanks & Regards
need code for login in asp.net with c#
need code for login in asp.net with c#  hai iam trying to develop a project in asp.net with c#,so i need a code for login page using which admin and other users can log in.plz help me, thanks in advance
need java code - Java Beginners
need java code  I want java code for connect to bit.ly and our link is converted into shorten link and give me response. as a converted link
NEED CODE FOR APPLICATION - Development process
NEED CODE FOR APPLICATION  i want to build a supermarket software that has the features of stock taking and receipt priting. can u help me
Need source code - Swing AWT
Need source code  Hai, I need a idea and code for developing the project "Face Recognition" with the backend as My-sql.... Thanks & Regards
Need the Following MobileApplication Related Code
Need the Following MobileApplication Related Code  Hi, I need java...: and one Daemon Thread class need's to run while doing the above operations and if you can provide code in switch cases,I feel more happy. Please reply me ASAP.ADS
need a Sample code - Development process
need a Sample code  i want run the python script in java code by using Runtime class and output should be formed like XML format.please help me. Advanced Thanks, Krishna
need someone to do/help with code
need someone to do/help with code  i need someone to do a code for me. It is a restaurant menu that displays a list of 10 food items. A customer..., along with the number of items sold..please help did a code 500 times cant
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
Need Java Source Code - JDBC
Need Java Source Code  I have a textfield for EmployeeId in which the Id, for eg: "E001" has to be generated automatically when ever i click... be implemented.  Hi friend, Please send me code because your posted
java - need code - Java Beginners
java - need code  i am java developer. i want to remove file from one folder and same file is paste another folder. i need this code. (java)  hi, I am sending you the code which moves the file from one folder
Need source code - Swing AWT
Need source code  Hai friends, How can I, view all the datas from the mysql database table in the jframe........  Hi Friend, Try the following code: import java.awt.*; import java.sql.*; import
Need source code - Swing AWT
Need source code  Hai, In java swing, How can upload and retrieve the images from the mysql database?   Hi Friend, To upload and insert image in database, try the following code: import java.sql.*; import
need java code - Java Beginners
need java code  i want a program for an algorithm in java which is it has some transactions T1=ABCE T2=CDE T3=DE T4=CDEG T5=BG T6... result . For this algorithm i need a program can any help me
i need a java code for finding typemismatch in an editor.
i need a java code for finding typemismatch in an editor.  hi im sriram, i need a java code in such a way that typemismatch code is embedded with the simple java editor. the sample output is shown below !alt text
i need the source code to generate id in jsp
i need the source code to generate id in jsp  hai,i need the source code for generate id...which is i need to generate the new id from the maximum... of generate ids each should have some range...plz give the source code in jsp with ms
Need a Code to calculate hair density in java
Need a Code to calculate hair density in java  Hello, Would you please give me a code to calculate the hair density on scalp from image in java
in need od source code - Development process
in need od source code  i am in the process of developing..., module, activity, and no of hours worked from week start to weekend... i need a source code for creating the front end, and for database, and linking from front end
need java code for <company:loc="bang">
need java code for   hi i want to write code like , i used setAttribute method for this. but its showing ERROR: 'Namespace for prefix 'company' has not been declared.' javax.xml.transform.TransformerException
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
need pyspark lit function example code
need pyspark lit function example code  Hi, I want to use the lit... to use it. It will be very helpful for me if someone shares me the code of pyspark... it in your PySpark program by adding following code in your python file: from
Need to have a Java Code - Java Beginners
Need to have a Java Code  Dear Friend, Can we run a unix command like "df -tg" in a remote linux system through FTP server using Java Program? Kindly give me the solution for the above query. Thanks & Regards
i need to replace this if statement code with switch case code
i need to replace this if statement code with switch case code   i need to replace this code with switch case for(int i=0;i<100;i++){ if((i... is your required code: class Loops{ public static void main(String[] args
need help to remove and optimise the code for creating a page
need help to remove and optimise the code for creating a page   i have the following code but it has some sorts of error whenever i run the page after validation through javascript it calls for the servlets and then i tried
i need attendce management system source code in java
i need attendce management system source code in java  i need attendance management system source code in java
Need simple java code to start and stop the remote windows service.
Need simple java code to start and stop the remote windows service.  Hi, I Need simple java code to start and stop the remote windows service. Example:There are two servers 1) Server A and 2) Server B. If a notepad.exe file
need complete jsp code for transactions using mysql - WebSevices
need complete jsp code for transactions using mysql  iam doing online banking project.i want the code to transfer funds from one account to another... to lasya or lasya to prathika. I need complete jsp code for transactions using
Need change in code to make website compatible with any browser
Need change in code to make website compatible with any browser  I have newly joined to one firm for application maintenance. They have their own.... So i should make changes in code so that website can open in any browser. What
Need someone to check and modify my simple code - Java Beginners
Need someone to check and modify my simple code   How to write a class that contains Variables that hold hourly rate of pay, number of hours...); } }   Hi Friend, You can use following code: import
need
need  i need a jsp coding based project plz help me
I need jsp code for how to write text field value into property file.
I need jsp code for how to write text field value into property file.  Hi , I need to set the text field value into property file using jsp code. Example : Username : Valar , I have entered the value "Valar" in the text field
urgent need for jsp code with mysql query for uploading and downloading file - JSP-Servlet
urgent need for jsp code with mysql query for uploading and downloading file  can anyone tell me how to upload and download a doc file using jsp with mysql as the back end... and kindly help me to create the table too
need source code fir automatic timesheet filling. can anyone peass help?
need source code fir automatic timesheet filling. can anyone peass help?  Hi friends, I wants to develop a software that should automatically fills the time sheet using the login and log out entries. Can anyone please help me
need help for writting code in struts action class for check boxes and radio buttons - Struts
need help for writting code in struts action class for check boxes and radio buttons  Hello frnds, i need help from u esteemed and talented people.iwould like to write code in struts action class for check boxes and radio
Can any one please help me in this ,,,,,,, need java code for this ,,,,please anyone
Can any one please help me in this ,,,,,,, need java code for this ,,,,please anyone  The Airport Valet Parking Company (AVP) is a company which... information; Bookings for the service need to be made at least 1 day in advance
Need Sample code To check the Windows services status is up or down in Linux mechine
Need Sample code To check the Windows services status is up or down in Linux mechine  Hi, I did code to check the windows services are up or down... application please provide any sample code. below code can work in only windows box

Ads