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
coldgirl [10]
3 years ago
11

Consider the following classes: public class A { private int myNum; public A(int x) { myNum = x; } public int getNumber() { retu

rn myNum; } public String getLetters() { return "A"; } public String getMessage() { return this.getLetters() + "-" + this.getNumber(); } } public class AB extends A { public AB(int x) { super(x + 1); } public int getNumber() { return super.getNumber() + 1; } public String getLetters() { return "AB"; } } What is the output of the following code segment? A test = new AB(0); System.out.print(test.getMessage());
Computers and Technology
1 answer:
Lady bird [3.3K]3 years ago
7 0

Answer:

The output of the given code is "AB-2".

Explanation:

The description of the java program can be given as:

  • In this program firstly we define a class that is "A". In this class, we define a private integer variable that is "myNum" and parameterized constructor and pass an integer variable that is "x" and use a private variable to holds the constructor variable value.Then we define three function that is "getNumber(), getLetters() and getMessage()" this function we returns values.
  • Then we define another class that is "AB" which inherits the base class "A". In this class we define parameterized constructor and two methods that is "getNumber() and getLetters()". In the parameterized constructor and getNumber() method we use a super keyword that calls above(base class methods) and increases the value by 1. In getLetters() method we return value that is "AB".
  • In calling time we create a class object that is "test", and call the AB class and pass value 0 in the parameter, and call the getMessage() method.

That's why the output of this program is "AB-2".

You might be interested in
Define the acronym WAECUP and its components
Mariana [72]

WAECUP stands for waste, accident, error, crime, and unethical practices.

Assuming that the components are the same as what's included in the acronym, that should be your answer.

Hope this helps!

8 0
3 years ago
For your biology class, you have taken a number of measurements for a plant growth experiment. You wish to create a chart that s
Mamont248 [21]
Calc or excel
Hope this helps
4 0
3 years ago
Immigrants are allowed to enter the country to work when they have a(n)
Roman55 [17]

Answer:

D. a Visa

Explanation:

4 0
3 years ago
A(n) _____ chart is drawn on the same worksheet as the data.
Harrizon [31]
The answer is An embedded chart
6 0
3 years ago
Which logic gate produces an output of 1 only if both its inputs are 0
Anettt [7]

0=false

1=true

false + false = true

0+0=1

+ operator = and function

AND GATE

8 0
3 years ago
Read 2 more answers
Other questions:
  • When saving a file, you must provide a valid file name that adheres to specific rules, referred to as _______________.
    5·1 answer
  • Integrated circuits are made up of _____ and carry an electrical current
    14·1 answer
  • Changing the configuration of a database falls under which category of databaseâ administration?
    15·1 answer
  • Which education and qualifications are most helpful for Law Enforcement Services careers? Check all that apply.
    15·1 answer
  • Assume that input file references a Scanner object that was used to open a file. Which of the following while loops shows the co
    6·1 answer
  • What is the first step to creating a PivotTable?
    11·1 answer
  • Which of the following is true regarding data acquisition? Because data acquisition is often technical, the research team does n
    15·2 answers
  • Copyright applies to work at the time it was produced, written, and developed. True or False?
    10·2 answers
  • Select the correct answer from the drop-down menu.
    15·2 answers
  • Types of Computer games​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!