Question
6. What is output by the following code? ArrayList a = new ArrayList(); ArrayList b = a; a.add(new Integer(4)); b.add(new Integer(5)); a. add(new Integer(6)); b.add(new
6. What is output by the following code?
ArrayList a = new ArrayList();
ArrayList b = a;
a.add(new Integer(4));
b.add(new Integer(5));
a. add(new Integer(6));
b.add(new Integer(7));
System.out.println(a.get(3));
19. What is stored in the array a after the following code executes?
int[] a ={17,34,43,71};
int I = 0;
while (i { if((a[i]%3; } eles { a[i] = a [i]/3; } i++; } A.{2, 10, 11, 1} B.{2, 11, 1, 2} C.{1,11,2,10} D.{2,11,1,10} E. An ArrayIndexOutOfBoundsException occurs. 20. What is the purpose of the keyword this? A. It allows you to instantiate an object and not give it a name. B. It allows you to instantiate an object when the class does not provide a constructor. C. It allows a method in a class to pass a reference to the object currently represented by that class to a method in another class. D. It is the mechanism by which polymorphism is implemented. E. It allows you to extend an abstract class. 22. Account is an abstract class with one abstract method named getInterestRate. BasicCheckingAccount is a concrete class that extends Account. EnhancedCheckingAccount extends BasicCheckingAccount, and overrides getinterestRate. A. Account B. BasicCheckingAccount C.EnhancedCheckingAccount D.SavingsAccount E. The code cannot run because the variable a cannot be assigned to an EnhancedCheckingAccount object in the line before assignment
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started