JAVA related questions. 1. Which of the following statements will generate a ran
ID: 3734167 • Letter: J
Question
JAVA related questions.
1.
Which of the following statements will generate a random number between -3 and 3 (inclusive). You can assume there is a Random object called generator.
generator.nextInt(6)-2
2.
values is the following int array:
What is values[4]?
None of these is correct.
3.
values is the following int array:
The statement System.out.println(values[7]); will
output 7
4.
values is the following int array:
What loop will add 1 to each element stored in values?
for (j=1; j<=values.length; j++) { values[j]++; }
5.
A class can contain both static and instance (non-static) variables.
False
6.
Within a class, you can invoke (call) a static method directly from within a non-static(instance) method.
False
7.
Java allows you use an abstract class or an interface as the declared type of an object.
False
8.
The relationship between a child and a parent class is referred to as a/an _____ relationship.
uses-a
9.
Which of the following is true regarding every Java class that you create from scratch?
Any class I write must have 1 child class but may have any number of parent classes.
none of these is correctExplanation / Answer
Question1
Answer:
generator.nextInt(7)-3
Question 2
Answer:
9
Question 3
Answer:
cause an ArrayoutOfBoundsException to be thrown (crashing the program)
Question 4
Answer:
for (j=0; j<values.length; j++) { values[j]++; }
Question 5
Answer:
True
Question 6
Answer:
False
Question 7
Answer:
False
Question 8
Answer:
is-a
Question 9
Answer:
Any class I write can have any number (0 or more) of parent classes and any number (0 or more) of child classes.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.