Describe Object in table below: Class Objects Other Objects Used in Java 1 3 2 4
ID: 3577783 • Letter: D
Question
Describe Object in table below:
Class Objects
Other Objects Used in Java
1
3
2
4
How are objects created in java, identify the keyword syntax.
>You create an object from a class. Objects have states and behaviors. And a class provides the blueprints for object.
There are three steps when creating an object from a class.
Declaration - A variable declaration with a variable name with an object type.
Instantiation - the "new" keyword is used to create the object.
Initialization - the "new" keyword is followed by a call to a constructor. This call initializes the new object.
For example,
public class Food {
public Food(String Country) {
// This constructor has one parameter, Country.
System.out.println("My Favorite Food is: " + Country);
}
public static void main(String []args) {
// Following statement would created an object myFood
Food myFood = new Food ("Korean Food");
}
}
As a result, the output will say-
Favorite Food is : Korean Food
Class Objects
Other Objects Used in Java
1
3
2
4
Explanation / Answer
class Object:
myFood -> which is the Food Object
Other java Objects.
Country -> which is the String object.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.