1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Tatiana [17]
4 years ago
7

Define a class Person that represents a person. People have a name, an age, and a phone number. Since people always have a name

and an age, your class should have a constructor that has those as parameters.
Computers and Technology
2 answers:
katrin2010 [14]4 years ago
8 0

Answer:

public class Person {

   String name;

   int age;

   String phoneNumber;

   public Person(String name, int age, String phoneNumber){

          this.name = name;

          this.age = age;

          this.phoneNumber = phoneNumber;

   }

}

Explanation:

The code above is written in Java.

The following should be noted;

(i) To define a class, we begin with the keywords:

<em> public class</em>

This is then followed by the name of the class. In this case, the name is Person. Therefore, we have.

<em>public class Person</em>

<em />

(ii) The content of the class definition is contained within the block specified by the curly bracket.

(iii) The class contains instance variables name, age and phoneNumber which are properties specified by the Person class.

The name and phoneNumber are of type String. The age is of type int. We therefore have;

<em> String name;</em>

<em>int age;</em>

<em>String phoneNumber;</em>

(iv) A constructor which initializes the instance variables is also added. The constructor takes in three parameters which are used to respectively initialize the instance variables name, age and phoneNumber.

We therefore have;

<em>public Person(String name, int age, String phoneNumber){</em>

<em>           this.name = name;</em>

<em>           this.age = age;</em>

<em>           this.phoneNumber = phoneNumber;</em>

<em>    }</em>

(v) Notice also that a constructor has the same name as the name of the class. In this case, the constructor's name is Person.

marysya [2.9K]4 years ago
6 0

Answer:

The class and constructor in C++ is as follows:

class Person {

 public:

   string name;     int age;     int phone;

   Person (string x, int y) {  

     name = x;       age = y;  

   }

};

Explanation:

This defines the class

class Person {

The specifies the access specifier

 public:

This declares the attributes; name, age and phone number

   string name;      int age;      int phone;

This defines the constructor for the name and age

   Person (string x, int y) {  

This gets the name and age into the constructor

<em>      name = x;       age = y;  </em>

   }

};

You might be interested in
Free point giveaway pt.10 and brainliest to first answer
g100num [7]

Answer:

3+3=6

Explanation:

Tysm!!!

8 0
3 years ago
Read 2 more answers
How do i use marketing in my everyday life
Alexxandr [17]
1. Subscribe to more emails
2. Look at billboards
3. Stop muting those pesky commercials
4. Listen to music
5. Step away from your work
8 0
3 years ago
Objects both in the real world and in object-oriented programming contain ____ and methods.
larisa86 [58]

Objects both in the real world and in object-oriented programming contain <u>attributes</u> and methods.

<h3>What is an attribute?</h3>

In Computer technology, an attribute can be defined as a unique characteristic or quality which primarily describes an entity in a software program.

<h3>What is a method?</h3>

In Computer programming, a method can be defined as a block of executable code (sets of instruction) that are written and used by programmers to break down a given problem into small but manageable fragments (pieces).

This ultimately implies that, methods are typically written and used by programmers to break down any complex problem into simple and manageable fragments (pieces). Also, all modern programming languages comprises several methods that are predefined.

In this context, we can infer and logically deduce that all objects both in the real world and in object-oriented programming generally contain <u>attributes</u> and methods.

Read more on methods here: brainly.com/question/25619349

#SPJ4

6 0
2 years ago
Provides an array of buttons for quick access to commonly used commands and tools
MatroZZZ [7]

Answer:Tool bar

Explanation:

The toolbar is said to provide an array of buttons for quick access to commonly used commands and tools. Through the toolbar, one can easily access the commands that are commonly used.

We can see the toolbar in several software like the graphics editor, office suites, and browsers.

8 0
3 years ago
Read 2 more answers
Write a program that computes the area and perimeter of a rectangle given its radius
mezya [45]
D sag gg FYI hbd su such ja dash us di ggs xx NJ
7 0
4 years ago
Other questions:
  • What is the best programing language I should learn for 3d gaming?
    13·1 answer
  • Electronic files created on a computer using programs such as word software are considered to be
    15·1 answer
  • Why are the relational operators called relational?
    15·2 answers
  • A(n) ____________________ is an assessment to determine the characteristics of hardware or software needed to meet a user's job
    14·1 answer
  • The ______________________ are incident management personnel that the incident commander or unified command assign to directly s
    10·1 answer
  • What should you do if a dialog box covers an area of the screen that you need to see?
    10·2 answers
  • The web development team is having difficulty connecting by ssh to your local web server, and you notice the proper rule is miss
    8·1 answer
  • The working window of a presentation is the _____.
    6·2 answers
  • A(n) _____ is a computer network that uses Internet Protocol technology to share information, operational systems, or computing
    12·1 answer
  • Carlos is using the software development life cycle to create a new app. He has finished coding and is ready to see the output i
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!