1. [BankAccount example] Given a superclass BankAccount and SavingsAccount subclass, what can be a valid reason for setting BankAccount's withdraw method to final? (select all that apply) a) The...


Please answer all the questions.


1. [BankAccount example] Given a superclass BankAccount and SavingsAccount subclass, what<br>can be a valid reason for setting BankAccount's withdraw method to final? (select all that apply)<br>a) The withdraw method is common to all account types<br>b) To hide the implementation of withdraw<br>c) Withdraw method is required in the subclass<br>d) None of the above<br>2. Which of the following is TRUE about setters and getters?<br>a) A class should have a getter for each of its attributes<br>b) There should be a corresponding setter for every getter in a<br>c) The return type of a getter is void<br>d) A getter can return object references and arrays<br>e) All of the above<br>3. Which of the following statements is/are TRUE?<br>Classes without specified package names are automatically placed inside an unnamed<br>package.<br>II.<br>I.<br>The java.util package is automatically imported by the Java compiler for convenience.<br>I only<br>Il only<br>Both I and II<br>Neither I nor II<br>4. Which line(s) of code will produce an error? *<br>package letter;<br>package shape;<br>import letter.A;<br>import letter.B;<br>public class A {<br>private int x;<br>void getX() {)}<br>}<br>public class Round {<br>void getCircumference() {<br>A a1 = new A();<br>в b1 %3 new B();<br>a1.getX(); (3)<br>b1.write(); (4)<br>}<br>package letter;<br>public class B {<br>public void write() {<br>A a1 = new A();<br>a1.x =<br>2; (1)<br>a1.getX(); (2)<br>}<br>}<br>1 and 2 only<br>1 and 3 only<br>2 and 3 only<br>3 and 4 only<br>O 1, 2, and 3 only<br>

Extracted text: 1. [BankAccount example] Given a superclass BankAccount and SavingsAccount subclass, what can be a valid reason for setting BankAccount's withdraw method to final? (select all that apply) a) The withdraw method is common to all account types b) To hide the implementation of withdraw c) Withdraw method is required in the subclass d) None of the above 2. Which of the following is TRUE about setters and getters? a) A class should have a getter for each of its attributes b) There should be a corresponding setter for every getter in a c) The return type of a getter is void d) A getter can return object references and arrays e) All of the above 3. Which of the following statements is/are TRUE? Classes without specified package names are automatically placed inside an unnamed package. II. I. The java.util package is automatically imported by the Java compiler for convenience. I only Il only Both I and II Neither I nor II 4. Which line(s) of code will produce an error? * package letter; package shape; import letter.A; import letter.B; public class A { private int x; void getX() {)} } public class Round { void getCircumference() { A a1 = new A(); в b1 %3 new B(); a1.getX(); (3) b1.write(); (4) } package letter; public class B { public void write() { A a1 = new A(); a1.x = 2; (1) a1.getX(); (2) } } 1 and 2 only 1 and 3 only 2 and 3 only 3 and 4 only O 1, 2, and 3 only

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here