Assume that the following statements are from a main method in a tester class. A
ID: 3797542 • Letter: A
Question
Assume that the following statements are from a main method in a tester class. Answer whether the following statements will cause a compiler error, a runtime error, or no error at all If there is an error, please also explain briefly why there is an error. These statements are not sequential to each other. Object obj1 = new Chicken(); obj1.howToCook(); Edible obj2 = new Chicken(); obj 2.howToCook(); Food obj3 = new Food(); obj 3.type(); Edible obj4 = new Chicken(); obj4.type (); Edible obj5 = new Chicken(); System.out.println(obj5.COMMODITY_TYPE); Food obj6 = new Chicken(); System.out.printIn(obj 6.COMMODITY_TYPE);Explanation / Answer
1. Compilation error as class Object doesn't know anything about howToCook()
2. No error Runs successfully
3. No error runs successfully
4. Compilation Error as Interface Edible doesn't know about type()
5. No error
6. Compilation error as class Food doesn't has any constant variable
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.