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
Adios brainly, you were sh.t sometimes, but you had your moments, wont be posting that much take my points away i d c
svlad2 [7]

you got a bad day today, bud?

3 0
3 years ago
Read 2 more answers
(03.04 MC) While working in a group, two members are not getting along. You ask each one what is happening, and they both say th
solniwko [45]

Answer:

Agree upon the problem Brainstorm possible

Explanation:

7 0
4 years ago
Read 2 more answers
How do you perceive the importance of Internet?
Igoryamba

The Internet had been used since the 1960's. The internet has capability of giving any answer you need or just having fun. If you want more, wikipedia the internet.

8 0
3 years ago
Read 2 more answers
Which of the following could be true of two diffrent speicies that have competitieve realtionship in the same ecosytem?
chubhunter [2.5K]

they both an enemy that is the same but they also have a same niche so the have the same niche

6 0
3 years ago
Adios brainly, wont be posting that much take my points away i d c
mrs_skeptik [129]
Omg I would die to have your points because when I get on people call me a noob because I just got the app like 3 days ago and every time I answer a question some says noob like dang I just started
5 0
3 years ago
Read 2 more answers
Other questions:
  • The negotiation by the transport layer at the sender with the transport layer at the receiver to determine what size packets sho
    14·1 answer
  • A computer is an electronic device operating under the control of instructions stored in its own memory that can accept, manipul
    11·1 answer
  • An oligopoly is a unique market structure. Which of the following is NOT necessary to have a oligopolistic market structure?
    10·1 answer
  • What is the importance of internet safety?
    11·1 answer
  • PLEASE HELLPPPPP EVERYONE IS IGNORING THISSSSSSSSSS
    11·1 answer
  • When using a small mic that attaches to your interview subject, where should you place that mic and why?
    5·1 answer
  • A protocol stack is _____.
    11·2 answers
  • How much download speed does netflix take away from gaming
    12·1 answer
  • Write an algorithm to calculate the average<br> value of array of integer elements
    13·1 answer
  • To freeze rows 1 and 2, and columns 1, 2, and 3, which cell should you highlight before selecting freeze panes?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!