Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the class by the name \"Class\"? Suppose that we have an object named ob

ID: 3815552 • Letter: W

Question

What is the class by the name "Class"? Suppose that we have an object named obj. We any obj.getClass(). What will it return? What will obj.getClass().getName() return? b) We have learned interface. Here interface has another meaning. It is the set of things that can be seen from the outside of the class. What are they (things seen from the outside)? Does a client (a program) need to know the detailed implementation of the class in order to use the class? What does a client need to know in order to use this class? c) In Java, a class cannot have two super classes (i.e. no multiple inheritance for classes). How does Java support multiple inheritance? d) Define what an abstract class is. Describe how we use abstract classes and concrete classes to implement software for different kinds of restaurants (Chinese, Japanese, Italian, and so on). Show hierarchy of the classes.

Explanation / Answer

Hello! Thank you for using Chegg. Here are the answers to the questions above:-

Answer 1) a) Class by the name "Class" is Object Class. . Every Object in Java belongs to a certain class. That's why the Object class, which is inherited by all other classes, defines the getClass() method. The getClass method returns the object of type Class that provides the name,package,methods,fields, constructors and annotations about the class. In this question, it would return (class <Name of Class>). On the other hand obj.getClass().getName() would return only the Name of class.

b) Interface makes it easier for the programmer to define a basic property of a thing which the class can implement to provide their different functionalities. The things that can be seen from outside is the basic property that all the classes are exhibiting. For example, we are creating class pugs, class labradors and class poodles that describe the specific look and barking sound. Pugs, labradors and poodles are types of dogs and they have the same set of behaviors. That is, we can say that all dogs can bark, have a name, and may or may not have a curly tail. We can use an interface to define what all dogs can do, but leave it up to the specific types of dogs to implement those particular behaviors. The interface says "here are the things that all dogs can do" but doesn't say how each behavior is done. An interface give you the ability to specify a set of behaviors that all classes that implement the interface will share in common. The clients do need to know the detailed implementation of the class in order to use this class. The detailed implementations are the reasons for which interfaces are to be made and implemented to provide specific functionalities.

c) Java supports multiple inheritance through the use of interfaces.Interfaces specify only what the class is doing, not how it is doing it. The problem with multiple inheritance is that two classes may define different ways of doing the same thing, and the subclass can't choose which one to pick. This would lead to randomized outputs for the programmer essentialy erroding the language's usability.

d) An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed If a class includes abstract methods, then the class itself must be declared abstract. When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, then the subclass must also be declared abstract.

abstract class Restaurant

{

abstract void menu()

{

}

abstract void nameofchef()

{


}

}

class Chinese extends Restaurant

{

void menu()

{

}

void name of chef()

{

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote