a.
Explanation of Solution
Given:
//Create an object
Sandwich sub = new Sandwich();
//Create an object
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
//Assign null value
Edible e = null;
“e = sub;”:
The given assignment statement is legal.
Justification:
- One can convert from a class type to any interface type that the class implements...
b.
Explanation of Solution
Given:
//Create an object
Sandwich sub = new Sandwich();
//Create an object
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
//Assign null value
Edible e = null;
“sub = e;”:
The given assignment statement is illegal.
Justification:
- One can convert from a class type to any interface type that the class implements.
- Given that the class “Sandwich” implements an interface “Edible”...
c.
Explanation of Solution
Given:
//Create an object
Sandwich sub = new Sandwich();
//Create an object
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
//Assign null value
Edible e = null;
“sub = (Sandwich) e;”:
The given assignment statement is legal.
Justification:
- Given that the class “Sandwich” implements an interface “Edible”.
- “sub” is an instance variable of “Sandwich” class, and “e” is a variable of “Edible” interface...
d.
Explanation of Solution
Given:
//Create an object
Sandwich sub = new Sandwich();
//Create an object
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
//Assign null value
Edible e = null;
“sub = (Sandwich) cerealBox;”:
The given assignment statement is legal.
Justification:
- Given that the class “Sandwich” implements an interface “Edible”...
e.
Explanation of Solution
Given:
//Create an object
Sandwich sub = new Sandwich();
//Create an object
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
//Assign null value
Edible e = null;
“e = cerealBox;”:
The given assignment statement is illegal.
Justification:
- Given that the class “Sandwich” implements an interface “Edible”...
f.
Explanation of Solution
Given:
//Create an object
Sandwich sub = new Sandwich();
//Create an object
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
//Assign null value
Edible e = null;
“e = (Edible) cerealBox;”:
The given assignment statement is legal.
Justification:
- Given that the class “Sandwich” implements an interface “Edible”...
g.
Explanation of Solution
Given:
//Create an object
Sandwich sub = new Sandwich();
//Create an object
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
//Assign null value
Edible e = null;
“e = (Rectangle) cerealBox;”:
The given assignment statement is illegal.
Justification:
- Given that the class “Sandwich” implements an interface “Edible”...
h.
Explanation of Solution
Given:
//Create an object
Sandwich sub = new Sandwich();
//Create an object
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
//Assign null value
Edible e = null;
“e = (Rectangle) null;”:
The given assignment statement is illegal...
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Big Java Late Objects
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education