menu
Qamnty
Login
Register
My account
Edit my Profile
Private messages
My favorites
In Java, write a constructor in such a way that a Vehicle object with color and type can be constructed directly via, say: Vehicle("Pink", "Car");
Ask a Question
Questions
Unanswered
Tags
Ask a Question
In Java, write a constructor in such a way that a Vehicle object with color and type can be constructed directly via, say: Vehicle("Pink", "Car");
asked
Dec 6, 2020
170k
views
2
votes
In Java, write a constructor in such a way that a Vehicle object with color and type can be constructed directly via, say:
Vehicle("Pink", "Car");
Computers & Tech
college
Findango
asked
by
Findango
8.6k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
2
votes
Answer:
Step-by-step explanation:
In Java, a Constructor is similar to that of a method which will be called when creating a new object for the class.
There is no return type for a Constructor.
public Vehicle (String color, String type)
{
colourName = color;
typeName = type;
}
In Java, you can use new operator to create an object of a class.
Here, the object for the class Vehicle is created like Vehicle vehicle = new Vehicle("Pink", "Car");
When creating the object of the class, the new operator calls the constructor.
If there is no constructor defined explicitly, a default constructor is created by the compiler.
DerBenniAusA
answered
Dec 10, 2020
by
DerBenniAusA
8.3k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
← Prev Question
Next Question →
Related questions
asked
Sep 20, 2024
114k
views
JAVA ECLIPSE Write a class named PhoneBookEntry that has fields for a person's name and phone number. The class should have a constructor and appropriate accessor and mutator methods. Then write a program
Numerator
asked
Sep 20, 2024
by
Numerator
7.9k
points
Computers & Tech
college
1
answer
0
votes
114k
views
asked
Nov 10, 2024
135k
views
Item Node.java public class ItemNode { private String item; private ItemNode nextNodeRef; // Reference to the next node public ItemNode() { item = ""; nextNodeRef = null; } // Constructor public ItemNode(String
Harminder
asked
Nov 10, 2024
by
Harminder
8.8k
points
Computers & Tech
college
1
answer
3
votes
135k
views
asked
Jun 25, 2024
20.7k
views
Java Exercise Create a class consisting of the following information. 1. no parameter constructor that creates an empty ArrayList of bank account data (account number, name) that are both Strings. 2. a
L Smeets
asked
Jun 25, 2024
by
L Smeets
7.9k
points
Computers & Tech
high-school
1
answer
1
vote
20.7k
views
Ask a Question
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.
Categories
All categories
Mathematics
(3.7m)
History
(955k)
English
(903k)
Biology
(716k)
Chemistry
(440k)
Physics
(405k)
Social Studies
(564k)
Advanced Placement
(27.5k)
SAT
(19.1k)
Geography
(146k)
Health
(283k)
Arts
(107k)
Business
(468k)
Computers & Tech
(195k)
French
(33.9k)
German
(4.9k)
Spanish
(174k)
Medicine
(125k)
Law
(53.4k)
Engineering
(74.2k)
Other Questions
“What does it mean when we “rework” copyrighted material?”
The book shows how to add and subtract binary and decimal numbers. However, other numbering systems are also very popular when dealing with computers. The octal (base 8) numbering system is one of these.
Seven basic internal components found in a computer tower
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search Qamnty