logo

Crowdly

Browser

Додати до Chrome

Questions Bank (1604553 total)

Переглянути це питання
Переглянути це питання
Переглянути це питання
Переглянути це питання

Suppose you have a Java class, Student, which needs to keep track of an ID number for each student object that is created. This ID number needs to be different for each student, but once it has been assigned to a particular student, its value should not be changed.

What is the best way of defining and initialising the ID variable?

❌
❌
✅
❌
Переглянути це питання

Consider the following code fragment:

Room office = new Room();

Room classroom = new Room();

office.setArea(125.0);

classroom.setArea(350.0);

office = classroom;

classroom.setArea(200.0);

Which of the following will be true, after this code executes? (Assume all classes and methods have been defined elsewhere correctly.)

0%
100%
0%
0%
0%
0%
0%
Переглянути це питання

Constant (final) variables in Java can be...

0%
50%
50%
0%
0%
Переглянути це питання

Suppose the following method is defined in some class:

public int someMethod(int x)

{

return x + z;

}

Assume that the rest of the surrounding class has been defined correctly, and that z is the name of a static field variable in that class.

What, if anything, is wrong with this code?

0%
100%
0%
0%
0%
Переглянути це питання

Consider the following partial code for some Java class:

public class Person

{

public static final int maxPeople = 10;

public Person()

{

/* ... rest of class continues here... */

Assume the remainder of the class is defined correctly. What, if anything, is the biggest problem with this portion of code?

75%
25%
0%
0%
0%
Переглянути це питання

Consider the following partial code for some Java class:

public class Person

{

public static final int MAX_PEOPLE;

public Person()

{

/* ... rest of class continues here... */

Assume the remainder of the class is defined correctly. What, if anything, is the biggest problem with this portion of code?

0%
0%
0%
0%
0%
Переглянути це питання