Can someone help me answer these questions please! Thanks so much!
MULTIPLE CHOICE 1. Assuming all classes are defined in a manner appropriate to their names, which of the following statements will cause a compile-time error? (a) Object obj = new Lunch(); (b) Lunch lunch = new Lunch(); (c) Lunch sandwich = new Lunch(); (d) Lunch lunch = new Object(); (e) Sandwich sandwich = new Sandwich(); Question 2 refers to the following classes: public class Club { private ArrayList
members; public club() public Club (ArrayList theMembers) members = the Members; } /* Additional implementation not shown */ } public class Schoolclub extends Club { private String moderator; public SchoolClub (String the Moderator, ArrayList the Members) 1 /* missing code */ ) /* Additional implementation not shown */ } 2. Which of the following could replace /* missing code */ in the Schoolclub constructor to ensure that all instance variables are initialized correctly? (a) super (theMembers); moderator = the Moderator; (b) super (newClub (the Members)); moderator - the Moderator; (c) this. SchoolClub = new Club (members); moderator = the Moderator; (d) moderator = the Moderator; (e) moderator = the Moderator; super (the Members); Questions 3-4 refer to the following classes. public class Present private String contents; public Present (String c) { contents = c; } public String getContents() return contents; } public void setContents (String theContents) { contents = the Contents; ) public String toString() 1 return "contains + getContents(); } } public class KidPresent extends Present private int age; public Kids Present (String c, int a) { Super (C); Age = a; ) public int getAge() { return age; } public String toString() { return super.toString() + " for a child age + getAge(); } 3. Consider the following code segment. Present p = new KidPresent ("kazoo", 4); System.out.println(p); What is printed as a result of executing the code segment? (a) contains kazoo (b) kazoo (c) contains kazoo for a child age 4 (d) Nothing is printed. Compile time error (e) Nothing is printed. Run-time error 4. Consider the following code segment. p.setContents ("blocks"); System.out.println(p); What is printed as a result of executing the code segment? (a) contains blocks (b) contains blocks for a child age 4 (c) contains kazoo for a child age 4 (d) Nothing is printed. Compile time error: there is no setContents method in the KidPresent class (e) Nothing is printed. Run-time error: there is no setContents method in the KidPresent class 5. Consider the following class definitions. public class A private int al; public void methodA () { System.out.println("Aa"); } } public class B extends A public void methods() { methodA(); } The following code segment appears in a class other than A or B. What is the result of executing the code? A objA = new A; A objB = new B(); objB.methodA(); objA.methodB(); (a) Aa (b) Aa (c) Nothing is printed due to a run-time error: Class B does not have a methodA() (d) Nothing is printed due to a compile-time error: Class A does not have a methodB() (e) Nothing is printed due to a compile - time error: Class B does not have a methodA()