Purchase Solution

Java Programming

Not what you're looking for?

Ask Custom Question

I'll give a start; this is the class definition; it has one member variable, one constructor method, and another public method:

public class Car
{
private int no_doors;

public Car(int i) // constructor method
{
no_doors = i;
}

public int GetDoors()
{
return no_doors;
}
}

Now use this class and write a small program where in Main you create 2 objects of type car using the constructor method (one with 2 and one with 4); then print the number of doors for each car using GetDoors() (you cannot access the private variable no_doors directly).

Purchase this Solution

Solution Summary

Java Programming is featured and discussed.

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C# variables and classes

This quiz contains questions about C# classes and variables.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.