Ask Experts Questions for FREE Help !
Ask
    Chrissy00's Avatar
    Chrissy00 Posts: 4, Reputation: 0
    New Member
     
    #1

    Dec 11, 2012, 08:38 AM
    Are my answers right? Java
    Use the following class definitions to answer questions 4 through 7

    public class Vehicle
    {
    private int passengers;
    private int fuelcap;
    private int mpg;
    Vehicle(int p, int f, int m)
    {
    passengers = p;
    fuelcap = f;
    mpg = m;
    }
    }
    public class Truck extends Vehicle
    {
    private int cargocap;
    private int test;
    Truck(int p, int f, int m, int c)
    {
    super(p,f,m);
    cargocap = c;
    }
    }
    public class TruckDemo
    {
    public static void main(String[] args)
    {
    Truck semi = new Truck(2,200,7,44000);
    Truck pickup = new Truck(3,28,15,2000);
    }
    }

    4. Class Vehicle shown above contains this definition of an attribute: private int passengers. According to the rules of Java, I can directly access Class Vehicles passengers attribute from Class TruckDemo by using Vehicle.passengersTRUE FALSE

    5. In the example above, Class Vehicle is the parent (or base) class, while class Truck is the child (or derived) class.
    TRUE FALSE

    6. The main method in the TruckDemo class instantiates two identical objects of the Truck class.
    TRUE FALSE

    7. The Truck class may include a static method.
    TRUE FALSE

Check out some similar questions!

Ask for help in java [ 0 Answers ]

Hi guys can you help me on java. I want to add some data on a jcombobox from mysql database. I created 2 comboboxes. After I retrieve the necessary data from the database it will automatically fill up the first combobox. And then in the first combobox the user chooses the data he wants...

Java [ 2 Answers ]

Write a program that converts 10, 50, and 100 kilograms to pounds

Java questions - I need the answers [ 3 Answers ]

Declare each of the following: (a) a field of data type boolean and name isFound; (b) a local variable of data type String and name carModel; (c) a field of data type double and name weight; (d) a field of data type Employee and name secretary. 2. Write a declaration for an array variable...

Java? [ 1 Answers ]

The problem is: "Design a class whose instance stands for one pack of cards and an other class whose instance stands for one card. Your program choose two cards randomly and output the result of comparison of the chosen cards. The suits order is spade >heart > diamond > club. The comparison...

By using vc++ or java? [ 1 Answers ]

Hi, I want to make image processing application.which programming language I should use? Either vc++ or java or anything else? Please guide me early.


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.