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
What does GUI stands for and what is it function?​
mars1129 [50]

Answer:

A GUI (graphical user interface) is a system of interactive visual components for computer software. A GUI displays objects that convey information, and represent actions that can be taken by the user. The objects change color, size, or visibility when the user interacts with them.

5 0
3 years ago
Read 2 more answers
The slide layout has placeholders for text, charts, and tables. true or false.
Ksju [112]
The answer to this is true
3 0
3 years ago
Read 2 more answers
In cell j6, enter a formula to determine the cost of gas if the customer chose that option as indicated in column i. if the cust
Alex73 [517]

Answer:

a t t i c

Explanation:

7 0
3 years ago
Students who understand what the teacher is saying do not need to take notes.
padilas [110]
Trueeeeeeeeeeeeeeeeee
6 0
3 years ago
Read 2 more answers
What is the maximum number of ip addresses that can be assigned to hosts on a local subnet that uses the 255.255.255.224 subnet
FinnZ [79.3K]
30 including the router.
7 0
3 years ago
Other questions:
  • What type of firestopping technology expands as much as 25 times in volume?
    6·1 answer
  • Which result would support the particle theory of light?
    6·2 answers
  • Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards
    7·1 answer
  • According to a recent study, more than 75 percent of teens between the ages of twelve and seventeen in the United States have a
    11·2 answers
  • Discuss about the main frame computer​
    9·1 answer
  • Question # 2
    7·1 answer
  • Giving brainliest if you answer question.
    8·1 answer
  • Heeeeeeeelp :)<br> thx<br> jfdyiusjmkdsuiho;dmcvrvho;j
    5·2 answers
  • Write a format operation that builds a string for the float variable amount that
    11·1 answer
  • Out put of Print (3**2*2)
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!