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 would you enter at the command prompt to start a new bourne again shell session?
butalik [34]

The answer is bash . The bash command opens a Bourne-again sheel (bash) session. It is the standard shell used in most Linux computers and it uses commands similar to a UNIX shell. Bash includes features such as:

1) Command completion when pressing the tab key.

2) Command history.

3) Improved arithmetic functions.

6 0
3 years ago
Who invented the balloons?
Alexandra [31]
<span>Professor Michael Faraday</span>
6 0
3 years ago
Read 2 more answers
PrintErrorDescription is a function that accepts one int parameter and returns no value. Write a statement that calls the functi
dmitriy555 [2]

Answer:

  1.    public static void main(String[] args) {
  2.        printErrorDescription(14);
  3.    }
  4.    public static void printErrorDescription(int value){
  5.        //some codes
  6.    }

Explanation:

Given a function <em>printErrorDescription() </em>with one parameter (Line 5 - 7). To call the function, we can write the function name and place the value of 14 within the parenthesis (Line 2). The value of 14 is a function argument. The value of 14 will be processed within the function to meet some purposes.    

3 0
3 years ago
THE BRAINLY SERVERS WAS ATTACKED!!!!! If you had some lag, do not worry, the servers will be up shortly
Nina [5.8K]
Okayyyyyyyyyyyyyyyyy
4 0
3 years ago
Read 2 more answers
Can someone help me with this using the template?
VladimirAG [237]

Answer:

over

Explanation:

due now 2 weeks ago thats it

8 0
3 years ago
Other questions:
  • Sera ético cargar a la www un vídeo que no es de su propiedad
    15·1 answer
  • The IBM 370 mainframe computer was introduced in 1970. The 370 Model 145 could hold up to 524,288 bytes of data (512 Kbytes). It
    8·1 answer
  • I need someone who knows HTML to finish the code.
    12·2 answers
  • Which of the following is NOT a valid declaration for a character string?
    8·1 answer
  • Which of the following describes the phishing method of information security crime?
    14·2 answers
  • URGENT HELP PLEASE
    13·1 answer
  • our grandmother tells you a dollar doesn’t go as far as it used to. She says the “purchasing power” of a dollar is much less tha
    6·1 answer
  • Good Morning! Please Help!
    15·1 answer
  • After turning volume all the way up on your computer speaker you still can’t hear any sound. What should be done next
    15·1 answer
  • Segregation based on laws is called _____
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!