Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

none of these is correct
generator.nextInt(7)-3
generator.nextInt(6)-3
generator.nextInt(8)-3
generator.nextInt(7)-2;
generator.nextInt(6)-4
generator.nextInt(7)-4
generator.nextInt(8)-2
generator.nextInt(8)-4

generator.nextInt(6)-2

2.

values is the following int array:

3 17 2 22 9 7 6

What is values[4]?

3
22
9
2
17
7
6

None of these is correct.

3.

values is the following int array:

3 17 2 22 9 7 6

The statement System.out.println(values[7]); will

output nothing
output 6
cause an ArrayoutOfBoundsException to be thrown (crashing the program)
cause a syntax (compile-time) error

output 7

4.

values is the following int array:

3 17 2 22 9 7 6

What loop will add 1 to each element stored in values?

for (j=1; j
for (j=0; j
for (j=0; j<=values.length; j++) { values[j]++; }
for (j=0; j

for (j=1; j<=values.length; j++) { values[j]++; }

5.

A class can contain both static and instance (non-static) variables.

True

False

6.

Within a class, you can invoke (call) a static method directly from within a non-static(instance) method.

True

False

7.

Java allows you use an abstract class or an interface as the declared type of an object.

True

False

8.

The relationship between a child and a parent class is referred to as a/an _____ relationship.

has-a
is-a
was-a
instance-of

uses-a

9.

Which of the following is true regarding every Java class that you create from scratch?

Any class I write classes can have 0 or 1 parent classes and any number of child classes.
Any class I write can have any number (0 or more) of parent classes and any number (0 or more) of child classes.
Any class I write must have 1 parent class and may have at most a single child class.
Any class I write must have 1 parent but may have any number of child classes.

Any class I write must have 1 child class but may have any number of parent classes.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions