fsdgbf

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following statements about abstract classes is NOT true? You can declare a class as abstract only when it contains all abstract methods. You can declare a class as abstract if it contains some abstract methods. You cannot instantiate an abstract class. You must declare a class as abstract if it inherits an abstract method without overriding it.

Correct Answer You can declare a class as abstract only when it contains all abstract methods.

A method that has no implementation is called a/an ____ method. interface implementation overloaded abstract

Correct Answer abstract

All methods located inside of an interface are automatically labeled with which of the following modifiers? static abstract final protected interface

Correct Answer abstract

A class can implement how many other interfaces? 0 1 2 as many as you want A and D only

Correct Answer as many as you want

An interface can extend how many other interfaces? 0 1 2 as many as you want A and D only

Correct Answer as many as you want

What type of variable is variable s? public interface Skeleton { String s = "Check it Yo!"; } instance class argumentative private self

Correct Answer class

Which of the following could fill <blank 1>? public interface Variable { <blank 1> } int x; int x = 9.6; double y = 99; B and C only A, B, and C

Correct Answer double y = 99;

Which of the following could fill <blank 1>? public interface Variable { <blank 1> } final int x; final int x = 9.6; final double y = 99; B and C only A, B, and C

Correct Answer final double y = 99;

An interface can extend another _________________ . abstract class class interface A and B A, B, and C

Correct Answer interface

All methods located inside of an interface are automatically set with what access? public private protected A and B only A, B, and C

Correct Answer public

Which of the following could fill <blank 1>? public interface Locatable { int getX(); public abstract int getY(); double getSpeed(); } public class Ship implements Locatable { private int xPos, yPos; private double speed; <blank 1> Ship() { //code not shown } public Ship(int x, int y, double s) { xPos=x; yPos=y; speed=s; } <blank 2> int getX() { return xPos; } <blank 2> int getY() { return yPos; } <blank 2> double getSpeed() { return speed; } } //code in the main method of another class <blank 3> public protected private abstract A, B, and C

A, B, and C

How many rows does a have if it is created as follows int[][] a = {2, 4, 6, 8}, {1, 2, 3, 4};?

Answer: (2)

How many columns does a have if it is created as follows int[][] a = {2, 4, 6, 8}, {1, 2, 3, 4};?

Answer: (4)

ticketInfo = new int [2][3]; seatingChart = new String [3][2]; How many elements are in ticketInfo?

Answer: (6)

Given the following code segment, what is the value of sum after this code executes? int[][] matrix = {1,1,2,2},{1,2,2,4},{1,2,3,4},{1,4,1,2}; int sum = 0; int col = matrix[0].length - 2; for (int row = 0; row < 4; row++) { sum = sum + matrix[row][col]; }

Answer: (8)

int[][] ticketInfo; String[][] seatingChart; What is printed when you type System.out.println(ticketInfo); after you do the above declarations?

Answer: (null, Null, NULL)

Which of the following could fill blank < *1 > ? public abstract class Theory { public int f(int x){ return 2 * x; } public < *1 > int g(int x); } I. abstract II. final III. static I only II only III only I and II only II and III only

Correct Answer I only

Which of the following could fill blank < *1 > ? public abstract class Theory { < *1 > } I. public Theory(int x){ } II. public int go(int x){ return x*5; } III. private int stop(){ return 887; } I only II only I and II only I and III only I, II, and III only

Correct Answer I, II, and III only

Which of the following could fill blank < *1 > ? public abstract class Theory { public < *1 > int HAL=9000; public int f(int x){ return 2 * x; } } I. abstract II. final III. static I only II only III only I and II only II and III only

Correct Answer II and III only

A class that inherits an abstract method but does not override it ____. Cannot be inherited by other classes. Must be declared as an abstract class. Can have objects instantiated from it. Must be declared as an anonymous class.

Correct Answer Must be declared as an abstract class.

If a class has an abstract method, which of the following statements is NOT true? You can construct an object from this class. You cannot construct an object from this class. You cannot inherit from this class. All non-abstract subclasses of this class must implement this method.

Correct Answer You can construct an object from this class.

All variables located inside of an interface are automatically labeled with which of the following modifiers? static abstract final A and C only C only

A and C only

int[][] ticketInfo = {25,20,25}, {25,20,25}; String[][] seatingInfo = {"Jamal", "Maria"}, {"Jake", "Suzy"}, {"Emma", "Luke"}; int value = ticketInfo[1][0]; String name = seatingInfo[0][1]; What is the value of name after the code above executes? A) Emma B) Maria C) Jamal D) Suzy E) Jake

Correct Answer B) Maria

Which of the following is the correct way to get the first value in a list called nums? A) nums[0] B) nums.get(0) C) nums.get(1) D) nums.first() E) nums[1]

Correct Answer B) nums.get(0)

Which of the following is the correct way to remove the value 3 from the list nums = [5, 3, 2, 1]? A) nums.remove(new Integer(3)); B) nums.remove(3); C) nums.remove(1); D) nums.remove(2);

Correct Answer C) nums.remove(1);

Which of the following is the correct way to set the second value in a list called nums to 5? A) nums.set(5, 1); B) nums[2] = 5; C) nums.set(1, 5); D) nums.set(2, 5); E) nums[1] = 5;

Correct Answer C) nums.set(1, 5);

Which index is the last element in an arraylist called nums at? A) nums.length B) nums.size C) nums.length - 1 D) nums.size() - 1

Correct Answer D) nums.size() - 1

Which of the following sets the value for the 3rd row and 2nd column of a 2D array called nums? A) nums[3][2] = 5; B) nums[2][3] = 5; C) nums[1][2] = 5; D) nums[2][1] = 5;

Correct Answer D) nums[2][1] = 5;

int[][] ticketInfo = {25,20,25}, {25,20,25}; String[][] seatingInfo = {"Jamal", "Maria"}, {"Jake", "Suzy"}, {"Emma", "Luke"}; What is the value at seatingInfo[2][1] after the code above executes? A) Suzy B) Jake C) Emma D) Maria E) Luke

Correct Answer E) Luke

How would you get the value 6 out of the following array int[][] a = {2, 4, 6, 8}, {1, 2, 3, 4};? A) a[2][0] B) a[0][3] C) a[3][1] D) a[1][3] E) a[0][2]

Correct Answer E) a[0][2]

Which of the following is the correct way to add 2 between the 1 and 3 in the following list nums = [1, 3, 4]? A) nums.add(2, 0); B) nums.add(2, 2); C) nums.add(0, 2); D) nums.add(2, 1); E) nums.add(1, 2);

Correct Answer E) nums.add(1, 2);

An interface can extend how many other classes? 0 1 2 as many as you want A and D only

Correct Answer 0

A class that implements Comparable has to at least have how many methods? public interface Comparable { public abstract int compareTo(); } 0 1 2 3 4

Correct Answer 1

What is the minimum number of methods a class extending abstract class Demo could have? public abstract class Demo { public Demo() { } public abstract String destroy(); public String toString() { return "--"; } } 0 1 2 3 4

Correct Answer 1

What is the minimum number of methods a class extending abstract class Demo could have? public abstract class Demo { public abstract String destroy(); } 0 1 2 3 4

Correct Answer 1

A class that implements Locatable has to at least have how many methods? public interface Locatable { int getX(); int getY(); double getSpeed(); } 0 1 2 3 4

Correct Answer 3

Which of the following statements about abstract classes is NOT true? A class that inherits an abstract method and does not override it must be declared as abstract. A class cannot be declared as abstract if it has no abstract methods. You cannot instantiate an object from an abstract class. You can construct a variable whose type is an abstract class.

Correct Answer A class cannot be declared as abstract if it has no abstract methods.

Which of the following could fill <blank 1>? public interface Testable { <blank 1> } double getScore(); public double getScore(); public abstract double getScore(); A and B only A, B, and C

Correct Answer A, B, and C

A class from which you cannot create objects is called a/an ____. Abstract class. Concrete class. Non-inheritable class. Static class.

Correct Answer Abstract class.

A class that cannot be instantiated is called a/an ____. Abstract class. Anonymous class. Concrete class. Non-inheritable.

Correct Answer Abstract class.

Which of the following statements about abstract methods is true? An abstract method has a name, parameters, and a return type, but no code in the body of the method. An abstract method has parameters, a return type, and code in its body, but has no defined name. An abstract method has a name, a return type, and code in its body, but has no parameters. An abstract method has only a name and a return type, but no parameters or code in its body.

Correct Answer An abstract method has a name, parameters, and a return type, but no code in the body of the method.

Which of the following statements about abstract classes and interfaces is NOT true? Abstract classes can have instance variables but interfaces cannot. Both abstract classes and interfaces can have instance variables. Abstract classes can have concrete methods but interfaces cannot. Abstract classes can have constructors but interfaces cannot.

Correct Answer Both abstract classes and interfaces can have instance variables.

Which of the following could fill blank < *1 > ? public abstract class Theory { < *1 > } I. public Theory(int x){ } II. private Theory(int x){ } III. public final Theory(int x){ } I only II only I and II only I and III only I, II, and III only

Correct Answer I and II only

Assuming <blank 1> is filled correctly, which of the following could fill <blank 3>? public interface Locatable { int getX(); public abstract int getY(); double getSpeed(); } public class Ship implements Locatable { private int xPos, yPos; private double speed; <blank 1> Ship() { //code not shown } public Ship(int x, int y, double s) { xPos=x; yPos=y; speed=s; } <blank 2> int getX() { return xPos; } <blank 2> int getY() { return yPos; } <blank 2> double getSpeed() { return speed; } } //code in the main method of another class <blank 3> Locatable x = new Locatable(); Ship w = new Ship(3,5); Locatable s = new Ship(3,5,7.8); Ship w = new Locatable(3,5,7.8); Locatable s = new Ship(3.5,5,7);

Locatable s = new Ship(3,5,7.8);

Which of the following could not fill <blank 1>? public interface Testable { <blank 1> } private void setScore(double s); void setScore(double s); abstract void setScore(double s) A and B only A, B, and C

private void setScore(double s);

All variables located inside of an interface are automatically set with what access? public private protected A and B only A, B, and C

public

Assuming <blank 1> is filled correctly, which of the following could fill <blank 2>? public interface Locatable { int getX(); public abstract int getY(); double getSpeed(); } public class Ship implements Locatable { private int xPos, yPos; private double speed; <blank 1> Ship() { //code not shown } public Ship(int x, int y, double s) { xPos=x; yPos=y; speed=s; } <blank 2> int getX() { return xPos; } <blank 2> int getY() { return yPos; } <blank 2> double getSpeed() { return speed; } } //code in the main method of another class <blank 3> public protected private abstract A, B, and C

public


Conjuntos de estudio relacionados

BUS 3010: Chapter 17 - Managing Conflict, Politics, and Negotiation

View Set

Intro to Cell- Final Exam w/Coach Moon

View Set

AH2- Blood Administration Module Quiz A F17- ATI

View Set

Testout Study Guide Chapters 2-4

View Set

CMA Part 2 Section D- Risk Management

View Set

GEOG 200 AUST, NEW ZEAL, ANTARCTICA AND PACIFIC

View Set

II Lecture Chapter 16 Short Answer: Ophthalmic Procedures pp 362

View Set