Question

In: Computer Science

Assume we have already defined two classes, ClickableShape and Pentagon. Using only the extends functionality of...

Assume we have already defined two classes, ClickableShape and Pentagon. Using only the extends functionality of Java, can we create a new class ClickablePentagon?

Solutions

Expert Solution

Answer

No in java we cannot create a new class only using the extends functionality it will occur compiler error becuase java does not support multiple inheritance

example

two classes ClickableShape and Pentagon already exist we try to create a new class ClickablePentagon with the help of extends functionality

for good understanding we will create the following java programe ->

 class ClickableShape{
        void fun(){
        System.out.println("This is ClickableShape property");
        }
}

 class Pentagon{
        void fun(){
        System.out.println("This is Pentagon property");
        }
}

 class ClickablePentagon extends ClickableShape, Pentagon
 {





public static void main(String[] args){
        
        ClickablePentagon myClickablePentagon=new ClickablePentagon();
        myClickablePentagon.fun();
        
        


}


}

this programe will show follwing error due to compiler error

Main.java:13: error: '{' expected
 class ClickablePentagon extends ClickableShape, Pentagon
                                               ^
1 error

hence we cannot create new class only using extends functionality


Related Solutions

Assume the following functions have already been defined, write a main() using c++ that uses them...
Assume the following functions have already been defined, write a main() using c++ that uses them to fill a vector with random integers, remove the smallest and largest integers from the vector, save the result in a file called "trimmed.txt" void fillRandom(vector & nums, int howMany); // fill with specified number of integers int minValue(vector nums); // return smallest value in vector int maxValue(vector <;int> nums); // return largest value in vector void writeFile(string outFileName, vector nums ); // writes...
Using the Note class and the Quadratic classes you have already developed, make each one Comparable....
Using the Note class and the Quadratic classes you have already developed, make each one Comparable. A Note is larger than another note if it is higher in frequency. A Quadratic is bigger than another Quadratic if it opens faster. 2. Write a driver for each (Note and for Quadratic). In the driver program create a few objects and compare them . then create a list of those objects and sort them. 3. Rewrite the Note class so that a...
Assume you already have a non-empty string S, which is guaranteed to contain only digits 0...
Assume you already have a non-empty string S, which is guaranteed to contain only digits 0 through 9. It may be of any length and any number of digits may occur multiple times. Starting from the front of the string, write a loop that jumps through the characters in the string according to the following rule: Examine the current character and jump that many characters forward in the string Stop if you jump past the end of the string, or...
Machine Learning - multivariate methods Let us say in two dimensions, we have two classes with...
Machine Learning - multivariate methods Let us say in two dimensions, we have two classes with exactly the same mean. What type of boundaries can be defined? show a picture of the options
A small school has only two 4th grade classes and two 5th grade classes. Each year,...
A small school has only two 4th grade classes and two 5th grade classes. Each year, students at the school take the Nebraska Test of Basic Skills (NTBS) in math and Language Arts. The Excel file, 745 Project Data, contains all of the scores for a certain class tracked over their 4th and 5th grade years. Create a frequency distribution and cumulative frequency distribution of the 4th Grade Math test scores for all of the students. Use 5 classes. Create...
A small school has only two 4th grade classes and two 5th grade classes. Each year,...
A small school has only two 4th grade classes and two 5th grade classes. Each year, students at the school take the Nebraska Test of Basic Skills (NTBS) in math and Language Arts. The Excel file, 745 Project Data, contains all of the scores for a certain class tracked over their 4th and 5th grade years. Create a frequency distribution and cumulative frequency distribution of the 4th Grade Math test scores for all of the students. Use 5 classes. Create...
Using Java This is two-part question, but I have already completed the first part and just...
Using Java This is two-part question, but I have already completed the first part and just need help with the second. Here I will provide both questions and my answer to the first part: Part I Question: Write a class called Dog that contains instance data that represents the dog’s name, breed, weight, birthdate, and medical history. Define the Dog constructor to accept and initialize instance data (begin the medical history with an empty line). Include accessor and mutator methods...
This is the only info that we have: 2. It is illegal for any two firms...
This is the only info that we have: 2. It is illegal for any two firms that sell similar products to engage in price fixing agreements. Violating the anti-trust laws can bring both civil and criminal prosecutions. Nevertheless, price fixing does take place. Examples would be found at the service plazas along the NY State Thruway and the NJ Turnpike. Each location has a small number of fast food restaurants. Each fast food restaurant belongs to a different firm, which...
This is the only info that we have: 2. It is illegal for any two firms...
This is the only info that we have: 2. It is illegal for any two firms that sell similar products to engage in price fixing agreements. Violating the anti-trust laws can bring both civil and criminal prosecutions. Nevertheless, price fixing does take place. Examples would be found at the service plazas along the NY State Thruway and the NJ Turnpike. Each location has a small number of fast food restaurants. Each fast food restaurant belongs to a different firm, which...
For this question we will be using arrays and classes in Java to compute the min,...
For this question we will be using arrays and classes in Java to compute the min, max, and average value of items for a given array of integers. Complete the following using the base template provided below: -Create methods for min, max, and average and call them from main to print out their values. -Add a method to determine the median (http://www.mathsisfun.com/median.html) and print that value. This method is currently not in the template, so you will need to add...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT