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
Karo-lina-s [1.5K]
3 years ago
9

Write a class named Add that has the following data members, constructor, and methods:

Computers and Technology
1 answer:
taurus [48]3 years ago
7 0

Answer:

A class is like a blueprint of object.

Explanation:

A class defines the kinds of data and the functionality their objects will have.

A class enables you to create your own custom types by grouping together variables of other types, methods and events.

In C#, we can create a class  using the class keyword.

Here's a sample program:

using System;

namespace ConsoleApplication

{

   public class Test

   {

       public static void Main()

       {

           Add a1 = new Add(70, 50);

           a1.AddNumbers();                    

           Console.ReadLine();

       }      

   }

     class Add

   {

       private int row;

       private int column;

       public Add(int r, int c)

       {

           row = r;

           column = c;

       }

       public void AddNumbers()

       {

           Console.WriteLine(row+column);

       }

   }

}

output: 120

Explanation of the program:

I have created a class named Add. Within a class, row and column are two fields and AddNumbers() is a method. We also have constructor to initialize row and column.

In main method, If I need to invoke members of the class, I must create  an instance of the class. We can create any number of instances using the single class.IN our program, a1 is the reference variable using which we can invoke members of the class. I invoked function in the class and passed arguments to the constructor while creating an instance.

Those values are assigned to method variables and it operated the addition. Thus the output is 120.

You might be interested in
Which of the following is NOT a file format used for word processing documents? A. .ppt B. .rtf C. .doc D. .odt
ohaa [14]

Answer:

ppt

Explanation:

ppt is a PowerPoint document

Extra Notes:

rtf: Rich Text Format

odt: Open Doc Text

doc: Microsoft Word File (Compatibility File) .docx is newer standard

4 0
2 years ago
Effective presentations vary the color scheme on each slide.<br><br> True<br> False
KengaRu [80]

Answer:

TRUE

Explanation:

7 0
3 years ago
Read 2 more answers
Write the definition of a function max that has three int parameters and returns the largest.
g100num [7]

Solution:

The definition of a function max that has three int parameters and returns the largest is given bellow:

def max(x,y,z):

if (x>z and x>y):

return (x)

elif (y>x and y>z):

return y

else:

return z

Thus this is required right answer.

4 0
3 years ago
Read 2 more answers
What are four differences between tablets and smartphones?
Oksi-84 [34.3K]

Answer:

1. tablets are less portable than smartphones

2. smartphones are considered necessities and tablets are considered luxuries

3. smartphones are personal devices; tablets are usually shared

4. Tablets have larger screens for more extensive use of applications as opposed to the smaller, less versatile mobile phone screens.

8 0
3 years ago
Read 2 more answers
Do network packets take the shortest route?
Sergio039 [100]

Answer:

The packet will take a shorter path through networks 2 and 4

5 0
2 years ago
Read 2 more answers
Other questions:
  • Failure to verify information can lead to?
    10·1 answer
  • Who is typically considered to be the father of computing
    6·1 answer
  • Markaplier nand jackceptieye are the best YT ever who agrees
    5·2 answers
  • Dust buildup inside a desktop PC case can be managed effectively by ____.
    7·2 answers
  • What kind of company would hire an Information Support and Service employee?
    7·1 answer
  • Which component of the windows desktop allows you to retrieve files that have recently been deleted?
    11·1 answer
  • Do you remember your first 3D movie experience? What was the movie, what was the experience like, and why was it memorable? (If
    7·1 answer
  • You are asked to write a program that prompts the user for the size of two integer arrays, user input for the size must not exce
    13·1 answer
  • In your own words, what is Cryptocurrency?
    15·2 answers
  • While conducting routine maintenance, you discover a network server that needs to
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!