Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

58. The data components in a class definition which may have unique values for e

ID: 3596293 • Letter: 5

Question

58. The data components in a class definition which may have unique values for each created object are often called the __________ of the class definition.

access types

instance variables

methods

objects

59.

What is displayed when the following code is executed?

System.out.println(“Welcome” + 1 + 1*2 );

Welcome11*2

Welcome4

Welcome12

Welcome3

60. Which of these data types requires the least amount of memory?

float

double

short

byte

61. Analyze the following code:

String numString = JOption.showInputDialog(null, "Enter a number:" , "Exam Input", JOptionPane.QUESTION_MESSAGE);

int number = Interger.parseInt (numString);

if (number <= 0)

System.out.println(number);

System.out.print.ln(number);

number is always printed out at least once

number is printed out twice if number is zero

number is printed out twice if number is negative

number is printed out only once if number is positive

All of the above are true

62. Analyze this code and indicate which of the following statements is true:

int [] list = new int [10];

for (int i = 0; i <= list.length; i++)

{

list[i] = (int) (Math.random() * 10);

}

Program must be modified to replace list.length by 10

The loop body will execute 10 times, filling up the array with random numbers.

The loop body will execute 10 times, filling up the array with zeros.

The code will have a runtime error indicating the array index is out of bound.

None of the above.

63. Suppose that f is an instance of class Foo:

class foo

}

public int i;

public static int s;

public void imethod()

{

}

public static void smethod()

{

}

}



which of the following statements is incorrect?

Foo.smethod();

System.out.println(Foo.s);

f.imethod();

System.out.println(Foo.i);

None. All are correct.

64. Given the following partial class definitions where both class Student and class BirthDate declare all data (attributes) as private, and given the definition of the setYear() method in class BirthDate,

Both classes are immutable

Only class Student is immutable

Only class BirthDate is immutable

Neither class is immutable

65. Given that iNum is an int, and fNum is a float, when calling a method defined as

void doSomeThing(int param1, float param2)
__________ is a valid call.

val = doSomeThing(iNum, fNum);

doSomeThing(int iNum, float fNum);

doSomeThing(iNum, fNum);

none of these

66. A class is not which of the following:

an abstract data type

a "pattern", or design, for an object

an instance of the object

none of the above - all are true of a class

67. All of the following are false except _____.

All classes are in a package.

Use import statement to place code into a package

To place a method in a package, use specifier package instead of public.

None; all are true.

68. The following code segment is syntactically correct. If the purpose is to display just the English word for the given numeric value, what if anything needs to be done to correct it?

Rearrange the case statements in ascending numerical order (case 1, case 2, etc.)

Insert a break after case 2

Insert a default case

no change is needed

69. What is the output of running the class C in the following code?

AB

BA

AA

none of the above

a.

access types

b.

instance variables

c.

methods

d.

objects

Explanation / Answer

58. instance variables. The variables' values could be different for each object. For example, let the class correspond the Student. Now, each student object will have a different name (name being the instance variable).

59. Welcome12 is printed. This is because the integers 1 and 2 (after calculating 1*2) are put dirctly by println().

60. short takes the least amount of memory.

61. All of the above are true. Number will be printed once for positive, and twice for the negative cases. Anyways, it will be printed at least once. Thus, all the cases become true.

62, 63, 64 - Question not available.

65. doSomething(iNum, fNum) will be correct. Because, we can not assign the return type void to int (option a). Option b is syntactically wrong because while passing the arguments to a method we should not use the data type.

66. A class is not an instance of the object.

67. "All classes are in a package" is true, all others are false. If a package is not specified in java, the class goes in the "default" package.

68, 69. Question not available.

Please do not hesitate to reach me in the comment in case you have any doubt. Thank you!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote