subject
Computers and Technology, 20.03.2020 18:11 jahzz

Questions 2 – 4 refer to the following classes:
public class Thing {
private int value;

public Thing() {
value = (int)(Math. random () * 100);
}

public String toString() {
return "" + value;
}

// other methods not shown
}
public class Cog extends Thing {
private int num;

public Cog () {
num = (int)(Math. random () * 100);
}

public String toString() {
return "" + num;
}
}

Consider the following declaration:
public class Gear extends Cog
Which of the following is true?

Gear cannot extend Cog since classes can only inherit from one class.
Gear can access all variables in both Cog and Thing.
Gear cannot access any methods in Thing.
Gear's constructor calls the constructor in Cog and Thing.
Gear's constructor calls the constructor in Cog, which calls the constructor in Thing.

Which of the following is NOT true?

Cog cannot directly access the variable value in Thing.
Cog can call the constructor in Thing directly using the super keyword.
The constructor in Cog automatically calls the constructor in Thing.
Cog can call the toString method in Thing.
Thing can call the toString method in Cog.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:00, 2alshawe201
The three logical operators used to write compound conditions are "and," "or," and "not." a: true b: false
Answers: 2
image
Computers and Technology, 23.06.2019 15:20, yeahmaneee
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
image
Computers and Technology, 23.06.2019 15:30, Dweath50
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
image
Computers and Technology, 23.06.2019 21:00, shyshy1791
Which set of steps will organize the data to only show foods with more than 100 calories and rank their sugar content from greatest to least?
Answers: 1
You know the right answer?
Questions 2 – 4 refer to the following classes:
public class Thing {
private int value;<...

Questions in other subjects:

Konu
Mathematics, 16.11.2020 21:30