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

Java Advanced Inheritance Review Questions 1. Parent classes are a. less specifi

ID: 3691140 • Letter: J

Question

Java Advanced Inheritance Review Questions 1. Parent classes are a. less specific , less specifethan their child classes b. more specific c. casier to understand d. more cryptic 2. Abstract classes differ from other classes in that you must not code any methods within them a. b. must instantiate objects from them c. cannot instantiate objects from them d. cannot have data fields within them 3. Abstract classes can contain a. abstract methods b. nonabstract methods c, both of the above d. none of the above 4. An abstract class Produet has two subclasses. Perishable and NonPerishable. None of the constructors for these classes requires any arguments. Which of the following statements is legal? a. Product myProductnew Product0 b. Perishable myPzoduct-new Product c. NonPezishable myProduct new NonPerishable o d. none of the above 5. An abstract class Employee has two subclasses, Fermanent and Tempozary. The Employee class contains an abstract method named set?ype ().Before you can instantiate Permanent and Temporary objects, which of the following statements must be true? a. You must code statements for the setType () method within the Permanent class. You must code statements for the set Type ( : Permanent and Temporary classes b. method within both the c You must not code statements for the setType) method within either the Permanent or Temporary class. d. You can code statements for the setType() method within the Permanent class or the Temporary class, but not both 6. When you create a superclass and one or more subclasses, each object of the subclass Superclass object. a. overrides the b. "is a c. "is not a" d. is a new Which of the following statements is true? a. Superclass objects are members of their subclass b. Superclasses can contain abstract methods. 7. c. You can create an abstract class object using the new operator d. An abstract class cannot contain an abstract method

Explanation / Answer

1. (a) less specific
2. (c) Cannot instantiate objects from them
3. (a) Abstruct methods
4. (c) Because we can not use abstruct class to instantiate a object
5. (b) Because abstruct methods doesn't contains any code. So whenever a class is derived from a abstruct class, all methods needs to be coded.
6. (a) Subclass method overrides superclass objects
7. (a) Superclass objects are members of their subclass
8. (b) Pointer. Pointers holds address to objects, veriables etc.
9. (b) Dynamic
10. (b)
11. (a) Yes. You can. See below example

class Complex {
private double re, im;

public Complex(double re, double im) {
this.re = re;
this.im = im;
}

/* Returns the string representation of this Complex number.
The format of string is "Re + iIm" where Re is real part
and Im is imagenary part.*/
@Override
public String toString() {
return String.format(re + " + i" + im);
}
}

// Driver class to test the Complex class
public class Main {
public static void main(String[] args) {
Complex c1 = new Complex(10, 15);
System.out.println(c1);
}
}

12. (b) One argument. See below example

System.out.println(x.equals(y));

13. (c) Both of the above is correct

14. (c) Data type

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