0
Object vs class
Guys what is the syntax of making objects out of a class
5 Answers
+ 10
Class_Name Object_Name = new Class_Constructor;
Ex. Fruit apple = new Fruit();
0
Is wrong to say object vs class. A class is like a sketch plan. And the object is the product of the design. Having a design of something (e.g. Audi A4), you can create how many copies/custom cars.
AudiA4 sonsCar = new AudiA4 ("2 doors", "convetible")
AudiA4 mumsCar new AudiA4 ("4 doors", "nonconvertible")
0
Object is an instance of a class.
class A {
// ...
}
A object = new A(); // create ana instance of the class A.
0
class HelloWorld{
//...
}
HelloWorld object = new HelloWorld();
right?
do we need to block the object in braces
0
the object does not have braces. Only the class. HelloWorld () is the special method named constructor, has the same name as the class followed by the parantheses. The way to distinguish a class from an object is that the class is always with a capital letter, as well as the constructor. The object is always written with a lowercase letter. The object of a class can access any method or variable ( except the constructor)