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
Setler79 [48]
3 years ago
15

Meg[] elements = {new Lois(), new Stewie(), new Meg(), new Brian()}; for (int i =0; i

Computers and Technology
1 answer:
Stells [14]3 years ago
7 0

Complete question is attached as snapshot.

Answer:

This will result in a compilation error.

Here's the inheritance hierarchy:

Meg -> Lois -> Brian -> Stewie

Now Meg has 2 public Fxns, a() and toString().

Lois inherits from Meg and all its public functions as well but, overrides the a() fxn of its super class.

So finally Lois has fxns a(), b() and toString().

Brian extends Lois and inherits all the above listed fxns of Lois, but overrides the b() and toString() fxns.

Stewie extends Brian and inherits all the fxns of Brian, but overrides the a() and toString() fxns.

In the Main driver fxn, we call a() and b() methods of all these classes but, the base class Meg has no b() and it is not extending any class so its not available in its scope.

This results in a compilation error.

Explanation:

You might be interested in
Cd-roms typically use the _______ filesystem type.
marissa [1.9K]
CD-<span>ROMs typically use the ____ filesystem type</span>
8 0
3 years ago
Look at the following list of peripheral items and determine what type they are: mouse, keyboard, webcam, microphone. Input Outp
-Dominant- [34]

Keyboard and mouse are input/output

Webcam and microphone are audio/visual


6 0
3 years ago
Write a static method called bothStart that allows the user to input two Strings and returns the String that is the longest subs
marishachu [46]

Answer:

  1.    public static String bothStart(String text1, String text2){
  2.        String s = "";
  3.        if(text1.length() > text2.length()) {
  4.            for (int i = 0; i < text2.length(); i++) {
  5.                if (text1.charAt(i) == text2.charAt(i)) {
  6.                    s += text1.charAt(i);
  7.                }else{
  8.                    break;
  9.                }
  10.            }
  11.            return s;
  12.        }else{
  13.            for (int i = 0; i < text1.length(); i++) {
  14.                if (text1.charAt(i) == text2.charAt(i)) {
  15.                    s += text1.charAt(i);
  16.                }else{
  17.                    break;
  18.                }
  19.            }
  20.            return s;
  21.        }
  22.    }

Explanation:

Let's start with creating a static method <em>bothStart()</em> with two String type parameters, <em>text1 </em>&<em> text2</em> (Line 1).  

<em />

Create a String type variable, <em>s,</em> which will hold the value of the longest substring that both inputs start with the same character (Line 2).

There are two possible situation here: either <em>text1 </em>longer than<em> text2 </em>or vice versa. Hence, we need to create if-else statements to handle these two position conditions (Line 4 & Line 13).

If the length of<em> text1</em> is longer than <em>text2</em>, the for-loop should only traverse both of strings up to the length of the <em>text2 </em>(Line 5). Within the for-loop, we can use<em> charAt()</em> method to extract individual character from the<em> text1</em> & <em>text2 </em>and compare with each other (Line 15). If they are matched, the character should be joined with the string s (Line 16). If not, break the loop.

The program logic from (Line 14 - 20) is similar to the code segment above (Line 4 -12) except for-loop traverse up to the length of <em>text1 .</em>

<em />

At the end, return the s as output (Line 21).

5 0
3 years ago
So girls i need advice i got a girliend and shes like awesome nice sweet and i need advice what to say or nice things girls like
Mila [183]
Try getting to know her or ask her about stuff she enjoys doing or hobbies she likes
4 0
3 years ago
Read 2 more answers
Which tab should you open to find the option for adding a header?
natima [27]

I normally just double click randomly on the page and I get the header. Laughing Out Loud.    


(trying to keep my useless answer it formal)

4 0
3 years ago
Other questions:
  • You have received several trouble tickets from the employees in the warehouse for the stand-alone computers used to control vari
    14·1 answer
  • Which aspects of a project do project makers oversee?
    12·2 answers
  • Which of the following can be created when two tables contain a common field?
    14·1 answer
  • Which function would you use to make sure all names are prepared for a mailing label?
    10·2 answers
  • his exercise creates a program to convert the temperature values form Fahrenheit to Celsius for a list of 10 temperature values
    6·1 answer
  • Credence is a student in college.
    13·2 answers
  • List the types of infrared we have
    12·1 answer
  • HELP PLEASE
    7·1 answer
  • Which of the following statement is correct ? A . potential difference is measured by ammeter . B . The unit of potential differ
    9·1 answer
  • What does it mean to clear a setting in a dialog box?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!