a)
“abstract” class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather it can be sub classed.
Legal “abstract” class:
- The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Example of a Legal “abstract” class:
The example of a legal abstract class is mentioned below:
public abstract class GraphicRectangle {
//declare fields
//declare methods
abstract void drawRectangle();
}
Given code:
//class definition
class A {
//declaration of an abstract method
abstract void unfinished() {
}
//end of class
}
b)
“abstract” class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal “abstract” class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Example of a Legal “abstract” class:
The example of a legal abstract class is mentioned below:
public abstract class GraphicRectangle {
//declare fields
//declare methods
abstract void drawRectangle();
}
Given code:
//class definition
public class abstract A {
//declaration of an abstract method
abstract void unfinished();
//end of class
}
c)
“abstract” class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal “abstract” class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Example of a Legal “abstract” class:
The example of a legal abstract class is mentioned below:
public abstract class GraphicRectangle {
//declare fields
//declare methods
abstract void drawRectangle();
}
Given code:
//class definition
class A {
//declaration of an abstract method
abstract void unfinished();
//end of class
}
d)
“abstract” class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal “abstract” class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Example of a Legal “abstract” class:
The example of a legal abstract class is mentioned below:
public abstract class GraphicRectangle {
//declare fields
//declare methods
abstract void drawRectangle();
}
Given code:
//class definition
abstract class A {
//declaration of a protected method
protected void unfinished();
//end of class
}
e)
“abstract” class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal “abstract” class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Example of a Legal “abstract” class:
The example of a legal abstract class is mentioned below:
public abstract class GraphicRectangle {
//declare fields
//declare methods
abstract void drawRectangle();
}
Given code:
//class definition
abstract class A {
//declaration of an abstract method
abstract void unfinished();
//end of class
}
f)
“abstract” class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal “abstract” class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Example of a Legal “abstract” class:
The example of a legal abstract class is mentioned below:
public abstract class GraphicRectangle {
//declare fields
//declare methods
abstract void drawRectangle();
}
Given code:
//class definition
abstract class A {
//declaration of an abstract method
abstract int unfinished();
//end of class
}
Trending nowThis is a popular solution!
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- In Java, which of the following is true about an abstract base class? no constructors should be provided at least one member function should be abstract no objects of the class can be created exactly two of the abovearrow_forwardCreate a class called testThis with a main function. In the main function, create two objects of the above class (thisClass), called s1 and s2, and pass values to their constructors that conform to their appropriate datatypes specified in the class.arrow_forwardConsider the following declarations: (1, 2, 5, 7) How many members does class foodType have? How many private members does class foodType have? How many constructors does class foodType have? How many constant functions does class foodType have? Which constructor is used to initialize the object fruit1? Which constructor is used to initialize the object fruit2? Rewrite the definition of the class foodType so that each data member can be set individually. Write a C++ statement to replace the definition of the constructors with a constructor with default parameter.arrow_forward
- 6.Which among the following is correct for the following code? class A { public : class B { public : B(int i): data(i) { } int data; } }; class C: public A { class D:public A::B{ }; }; i Multi-level inheritance is used, with nested classes ii Multiple inheritance is used, with nested classes iii Single level inheritance is used, with enclosing classes iv Single level inheritance is used, with both enclosing and nested classesarrow_forwardTwo base classes have functions with the same name, while a class derived from both base classes has no function with this name. How do objects of the derived class access the correct base class function? Write your own program to explain the answer.arrow_forwardWhich of the following access specifier in C# allows a child class to access the member variables and member functions of its base class? A - Public B - Private C-Protected D - Internalarrow_forward
- Q# Which of the following might have only method signatures? Group of answer choices 1. An interface 2. An abstract class and a concrete class 3. An abstract class 4. An interface and an abstract class 5. None of these, they all require the implementation. 6. A concrete classarrow_forwardWhich of the following statements are true? Choose all options that apply.(a) Most superclasses are abstract.(b) Inheritance is preferable to composition.(c) Most superclasses are concrete.(d) Composition is preferable to inheritance.arrow_forward________________applies to a class rather than an object?arrow_forward
- Which of the following statements are correct? (Select all that applies.) Group of answer choices a) Inheritance is the process by which one object can acquire the properties of another object. b) "super" is used to access the method or member variables from the parent class. c) Constructors are used to initialize a newly created object. d) Method overriding occurs when a child class declares a method that has the same type of arguments as a method declared by one of its parent classes. e) An object that has more than one form is referred to polymorphism.arrow_forwardQ1) Write the Code the following scenario. Write an abstract function named receivePay in interface with return type double and no parameters. Write another incomplete function, name Show with return type void and an argument of type int in that interface. Build a class with name Bill that implements the above interface. Bill class with name BillId , itemsquantity and itemsprice with proper datatypes with private access . Define two constructors,one default and other is parameterized to initialize the class members . Now receivePay has to beimplemented in such a way that its displays product of itemsquantity and itemsprice and Display function will display the BillId.Can we do same task with abstract class instead of interface? NOTE:SUBJECT:CSHARP (VISUAL PROGRAMMING)arrow_forwardConsider the following class definitions: (2, 8) a. Which private members, if any, of smart are public members of superSmart? b. Which members, functions, and/or data, of the class smart are directly accessible in class superSmart?arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning