answersLogoWhite

0


Best Answer

A class is like a template. You can define a class "Person", which defines what type of data you want to store for a person - for example, for a computer game, the person's name his accumulated score, and how many lives he has left. The class might better be called "Player" in this case - but you can just as well store other data for a Person.

Then, you create objects for two different players. You declare variables player1 and player2, both of type "Person". It is in these variables - player1 and player2 - where you store specific information about individual persons.

A class is like a template. You can define a class "Person", which defines what type of data you want to store for a person - for example, for a computer game, the person's name his accumulated score, and how many lives he has left. The class might better be called "Player" in this case - but you can just as well store other data for a Person.

Then, you create objects for two different players. You declare variables player1 and player2, both of type "Person". It is in these variables - player1 and player2 - where you store specific information about individual persons.

A class is like a template. You can define a class "Person", which defines what type of data you want to store for a person - for example, for a computer game, the person's name his accumulated score, and how many lives he has left. The class might better be called "Player" in this case - but you can just as well store other data for a Person.

Then, you create objects for two different players. You declare variables player1 and player2, both of type "Person". It is in these variables - player1 and player2 - where you store specific information about individual persons.

A class is like a template. You can define a class "Person", which defines what type of data you want to store for a person - for example, for a computer game, the person's name his accumulated score, and how many lives he has left. The class might better be called "Player" in this case - but you can just as well store other data for a Person.

Then, you create objects for two different players. You declare variables player1 and player2, both of type "Person". It is in these variables - player1 and player2 - where you store specific information about individual persons.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Classes & objects have the same relationship as of food with the recipe to make the food.

When we need to accomplish a job we make objects to do the job by the computer.

The instructions that the computer has to follow is stored in the hard-disk as what we say 'classes' in java. Actually, classes are the blueprints of objects that the computer has to follow while making objects.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

A class is like a template. You can define a class "Person", which defines what type of data you want to store for a person - for example, for a computer game, the person's name his accumulated score, and how many lives he has left. The class might better be called "Player" in this case - but you can just as well store other data for a Person.

Then, you create objects for two different players. You declare variables player1 and player2, both of type "Person". It is in these variables - player1 and player2 - where you store specific information about individual persons.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Object and classes Use a person as an example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is use of dot operator in java?

"the dot" connects classes and objects to members. The places where you use it in what I cover are:(1) when you are connecting an object reference variable to a method. The Extending Existing Classes lesson introduces the dot operator for this use, and(2) when you are connecting a class name to one of its static fields. An example of this is the dot between "System" and "out" in the statements we use to print stuff to the console window. System is the name of a class included in every Java implementation. It has an object reference variable that points to a PrintStream object for the console. So, "System.out.println( "text") invokes the println() method of the System.out object.


How many data types can the elements of an array have?

Depends on your language. Assuming java: If you make it an Object[] then it can contain any object For primitive types you must either make a primitive type array, ie double[], char[] which can contain only those primitives, or creater an Object[] and use primitive wrapper objects ie java.lang.Integer etc.


How do you use delete function in inheritence in classes using c plus plus?

You use delete to release the memory occupied by an object that is being pointed to by the pointer you delete. Provided all base classes have a virtual destructor, it doesn't matter what the type of pointer you actually delete is, so long as it is a type of class from which the object is actually derived. The destructor from the most-inherited class (the object itself) will be called first, which calls the destructors of its immediate base classes, and theirs, and so on until the object is completely released from memory.Note that you must not delete pointers to object references -- they must be nullified (not deleted) when they are no longer required. The referenced object will be deleted automatically when it falls from scope.


What class is the super class for ALL Java classes?

The Object class, in the java.lang package, sits at the top of the class hierarchy tree. Every class is a descendant, direct or indirect, of the Object class. Every class you use or write inherits the instance methods of Object. You need not use any of these methods, but, if you choose to do so, you may need to override them with code that is specific to your class


Compare anonymous class with abstract class?

Abstract Classes contain the work abstract in it. It is used when you know that you will need to use an object of its type but do not know the inner workings yet. Anonymous classes are those classes that are constructed on the fly. You need to know its inner workings.

Related questions

What object does Juliet use as an example of unimportance of names in romeo and Juliet?

what object does juliet use an example of unimportance of names


What is use of dot operator in java?

"the dot" connects classes and objects to members. The places where you use it in what I cover are:(1) when you are connecting an object reference variable to a method. The Extending Existing Classes lesson introduces the dot operator for this use, and(2) when you are connecting a class name to one of its static fields. An example of this is the dot between "System" and "out" in the statements we use to print stuff to the console window. System is the name of a class included in every Java implementation. It has an object reference variable that points to a PrintStream object for the console. So, "System.out.println( "text") invokes the println() method of the System.out object.


Is the word classes an object?

Classes is the plural of the word class. A class is not an object in the physical sense, it is an idea, a notion or concept. We typically use a class to define a classification, such as a class of people, a class of study or a class of object. In other words it defines a type.


When to use wrote or written?

Use "wrote" when referring to the past tense of the verb "to write," such as "She wrote a letter yesterday." Use "written" when the verb needs to be in the past participle form, such as "The letter was written by her."


What is the collective noun for classes?

The standard use of the collective noun 'classes' is 'classes of students'. The noun 'class' (or the plural form 'classes') is a general collective noun for people or things, for example 'classes of travelers' or 'classes of work animals'.


How do you find the deinsity of an object?

For example, you can use the definition of "density", and just divide the object's mass by its volume.


When do you use the pronoun I or me?

Use the pronoun "I" when referring to yourself as the subject of a sentence. For example, "I went to the store." Use the pronoun "me" when referring to yourself as the object of a verb or preposition. For example, "She gave the book to me."


Where can I take free typing classes online?

There Are alot of Websites that offer Free typing classes. For example you can use: www.goodtyping.com/, www.typingweb.com/, orwww.freetypinggame.net/


What is the proper way to use me in a sentence?

The proper way to use "me" in a sentence is as an object pronoun, typically after the verb or preposition. For example, "She gave the book to me," or "He is taller than me."


How do you use their and there?

Their is used if you are talking about another person's object. For example: "Have you given their ball back yet?" and "What did you do at their house?" For 'there' it's more about location. For example: "How long before we get there?" or "Are there any more ice-creams left in the freezer?"


What is heritance in java?

With inheritance, you can use methods and fields from the superclass in a subclass. So for example when I have a class Person with fields age and gender, I can make a subclass Student. a Student object has always the fields from its superclass Person (age and gender), but you can make extra fields for a Student object. The same is true for methods: a method defined in the Person class can also be used on a Student object because Student is a subclass from Person. Got it? ;)


How do you use the word there-and their?

Their is used if you are talking about another person's object. For example: "Have you given their ball back yet?" and "What did you do at their house?" For 'there' it's more about location. For example: "How long before we get there?" or "Are there any more ice-creams left in the freezer?"