1. Suppose ArrayList X contains two strings[Beijing, Singapore]. Which of the fo
ID: 3610860 • Letter: 1
Question
1. Suppose ArrayList X contains two strings[Beijing, Singapore]. Which of the following method will causeruntime errors? (Select all that apply)
A) x.size()
B)x.set(2, "New York");
C) x.remove(2)
D) x.get(2)
E)x.get(1)
3. Which of the following declares an abstract method in anabstract Java class?
A) public void method() {}
B) public abstract method();
C) public abstract void method();
D) public void abstract Method();
E) public abstract void method() {}
4. What is the output of running class Test.
Public class Test{
Public static void main(String[] args) {
New Circle9();
}
}
public abstract class GeometricObject {
protected GeometricObject() {
System.out.print("A");
}
protected GeometricObject(String color, boolean filled) {
System.out.print("B");
}
}
public class Circle9 extends GeometricObject {
/** Default constructor */
public Circle9() {
this(1. 0);
System.out.print("C");
}
/** Construct circle with a specified radius */
public Circle9(double radius) {
this(radius, "white", false);
System.out.print("D");
}
/** Construct a circle with specified radius, filled, and color*/
public Circle9(double radius, String color, boolean filled) {
super(color, filled);
System.out.print("E");
}
}
A) BEDC
B) BACD
C) ABCD
D) AEDC
E) CBAE
Explanation / Answer
1 is easy: remember that list has only 2 elements and it alwaysstarts from zero so have elements 1 and zero 1. B,C,D 3. C because it must first say that it is abstract and thensay what is going to return such void or int 4. first we creating Circle 9 object then from Circle 9 object wecall other constructor of this class which call other consturctorthat takes 3 parameters this one called the super constructor whichprints B than E because we go back to method BEDC
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.