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]
3 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]3 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]3 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
The permissions of a file in a Linux system are split into three sets of three permissions: read, write, and execute for the own
Reptile [31]

Answer:

Explanation:

def octal_to_string(octal):

   result = ''

   value_letters = [(4, 'r'), (2, 'w'), (1, 'x')]

   for c in [int(n) for n in str(octal)]:

       for value, letter in value_letters:

           if c >= value:

               result += letter

               c -= value

           else:

               result += '-'

   return result

print(octal_to_string(755))

print(octal_to_string(644))

print(octal_to_string(750))

print(octal_to_string(600))

**************************************************

7 0
3 years ago
What is the default font style of “Title” box in MS PowerPoint 2013?
butalik [34]

Answer:

A) Calibri Light

Explanation:

After Office 2013, All versions of PowerPoint title font is "Calibri Light"

7 0
3 years ago
As a photographer, what will be the driving force behind everything that you produce?
GREYUIT [131]

Answer:

You have to like it to be successful in photography.

Explanation:

8 0
3 years ago
Draw a full binary tree of height 2. How many nodes does it have?
Paraphin [41]

Answer:

The number of nodes in a full binary tree of height 2 = 7

Explanation:

At each level k, of the full binary tree there are usually 2^{k} \\ nodes.

So the full binary tree of height 2 has nodes= 2^{0} \\ + 2^{1} \\ + 2^{2} \\.

which is 7.

6 0
4 years ago
What is a Database, Flat file and Relational Database?
Marta_Voda [28]

Answer:

A flat file database stores data in a single table structure. A relational database uses multiple table structures, cross-referencing records between tables. Tables in both organize records in rows, with each column containing a single piece of data in the record.

8 0
2 years ago
Other questions:
  • While creating your résumé, what should you do before making a final copy to fix any typos or errors?
    6·1 answer
  • Help me with this please, it is for tech
    11·1 answer
  • What is an identifier? Give an example of an identifier.
    13·1 answer
  • Explain the importance of determinism in an industrial LAN
    8·1 answer
  • import java.util.Scanner; public class TeenagerDetector { public static void main (String [] args) { Scanner scnr = new Scanner(
    6·2 answers
  • Can I get the code for the Edhesive Assignment 3 Chatbox in python? Thanks.
    15·1 answer
  • Think about that the C, B and S parameters of a Cache. Think about what happens to compulsory, capacity, conflict misses, if onl
    7·1 answer
  • PLEASE HELP ILL GIVE BRAINIEST
    6·2 answers
  • Write a program, using case statements, that mimics a calculator. The program should take as input two integers and the operatio
    9·1 answer
  • When one loop appears inside another, the loop that contains the other loop is called the ____ loop. Group of answer choices ind
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!