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
frez [133]
3 years ago
9

Do an Internet search for multiple inheritance in programming languages. What are the pros and cons of multiple inheritance? Why

do you think the developers of C#, Java, and Objective-C chose a single inheritance model? Explain your answer.
Computers and Technology
1 answer:
Andrei [34K]3 years ago
5 0

Answer:

Pros and cons of multiple inheritance

Pros

a) You categorize classes in many different ways. Multiple inheritance is a way of showing our natural tendency to organize the world. During analysis, for example, we use multiple inheritance to capture the way users classify objects.

b) By having multiple superclasses, your subclass has more opportunities to reuse the inherited attributes and operations of the superclasses.

Cons

a) If two classes have a method with the same name, the new subclass doesn't know which one to call.

b) multiple inheritance can lead to a lot of confusion when two base classes implement a method with the same name.

c) The more superclasses your subclass inherits from, the more maintenance you are likely to perform. If one of the superclasses happens to change, the subclass may have to change as well.

d) When a single subclass inherits the same attribute or operation from different superclasses, you must choose exactly which one it must use.

Explanation: Question 2

Some programming languages such as Java don’t allow you to use multiple inheritance. You must translate multiple inheritance into single inheritance or individual Java interfaces. This can be confusing and difficult to maintain because the implemented code for categorizing objects is quite different from the way the user organizes those objects. So, when the user changes their mind or adds another category, it is difficult to figure out how to program the new subclass.

You might be interested in
In this assignment, you are provided with working code that does the following: 1. You input a sentence (containing no more than
Olegator [25]

Answer:

The code is given below,

import java.io.File;

import java.io.FileInputStream;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class SentenceUtilsTest {

public static void main(String[] args) {

List<SentenceUtils> sList = new ArrayList<SentenceUtils>();

try{

File file = new File(args[0]);

Scanner scanner = new Scanner(new FileInputStream(file));

while(scanner.hasNextLine()){

String sent = scanner.nextLine();

if(sent.trim().length() > 0){

SentenceUtils sUtils = new SentenceUtils(sent);

sList.add(sUtils);

}

}

System.out.println("File that was read:" + args[0]);

System.out.println("File contains " + sList.size() + " sentences.\n");

System.out.println("Sentences reports:\n");

for(int line = 0; line < sList.size(); line++){

System.out.println("Sentences " + line +";");

System.out.println(sList.get(line).getSentence());

SentenceUtils lineText = sList.get(line);

String[] tokens = lineText.getTokens();

for(int id = 0; id < tokens.length; id++){

System.out.println(id+":"+tokens[id]);

}

String[] shingles = lineText.getShingles();

for(int id = 0; id < shingles.length; id++){

if(shingles[id] != null){

System.out.print(shingles[id]+" ");

}

}

System.out.println("\n");

}

}catch(Exception ex){

ex.printStackTrace();

}

}

}

package sentenceutils;

import java.util.ArrayList;

import java.util.List;

public class SentenceUtils {

private String sentence;

private String[] tokens;

private String[] shingles;

public SentenceUtils(String s){

this.sentence = s;

generateTokens();

generateShingles();

}

private void generateShingles() {

List<String> shinglesList = new ArrayList<String>();

for (int index=0; index < sentence.length()-1; index++) {

shinglesList.add( sentence.charAt(index) +""+sentence.charAt(index+1) );

}

shingles = new String[sentence.length()];

shinglesList.toArray(shingles);

}

private void generateTokens() {

tokens = sentence.split(" ");

}

public String getSentence() {

return sentence;

}

public String[] getTokens() {

return tokens;

}

public String[] getShingles() {

return shingles;

}

}

4 0
3 years ago
How can you use the cash envelop system and the 50-30-20 rule at the same time
Amanda [17]

Answer:

hi

Explanation:

6 0
3 years ago
What are other ways you could use the shake or compass code blocks in physical computing projects?
BabaBlast [244]

Answer:there are different ways of quick navigation between files and functions. ... You should use the menu 'Remove file from project' instead of deleting files. ... A Makefile generation tool for Code::Blocks IDE by Mirai Computing

7 0
3 years ago
If you are recordng a singer who is performing to the prerecorded sound of an orchestra, what type of feed would you most likely
zloy xaker [14]
You would most likely use a mix-minus
8 0
4 years ago
Write a program that asks a user to roll a single die twice to get a sum value of 7. If the sum is 11, the user loses. If the su
barxatty [35]

Answer:

Check the explanation

Explanation:

#include <stdio.h>

int dice1;

int dice2;

int sum;

int roll_die_twice(int dice1,int dice2){

 

if(sum==7){

printf("winner");

 

}

else if (sum==11){

printf("looser");

}

else if (sum!=7 && sum!=11)

{

printf("nor winner or looser");

 

}

}

int main()

{

roll_die_twice(2,7);

return 0;

}

The code screenshot and code output can be seen in the attached image below.

6 0
3 years ago
Read 2 more answers
Other questions:
  • The method of transferring data one word at a time from the CPU to a device is called
    7·1 answer
  • What company was credited with developing the first smartphone?
    6·2 answers
  • The ____ is the configuration of a system documented at the beginning of the project and consists of all necessary system requir
    8·1 answer
  • Let A be an array of n numbers. Recall that a pair of indices i, j is said to be under an inversion if A[i] &gt; A[j] and i &lt;
    11·1 answer
  • What is not a basic function of a computer?
    10·2 answers
  • Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked
    8·1 answer
  • Which statement describe the advantages of using XML? more than one answer can be correct
    9·1 answer
  • what should the timing of transition slides be per minute? maintain the flow of the presentation to ______ slides per minute.
    9·1 answer
  • What does the “MIN” and “MAX” functions allow you to do when inserted in a spreadsheet?
    6·1 answer
  • HELP ME PASS!
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!