Computer Programming

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The Math.random method generates a random number x, such that

0 <=x<1

Possible output? For (int k=1;k<=10; k++) { double var1=Math.random() * 100; int var2 = (int) var1 +10 ; System.out.print(var2 + ". ")

10 numbers, lowest variable 10, highest no greater than 100

how many objects are being shown? (revert to the study guide)

13 (13 bugs placed on the grid)

Approximately how many different graphics colors can Java produce?

16,000,000

how many classes are being shown? (revert to study guide)

5 (5different types of bugs)

Output? import Java.util.Random; public static void main (String args []) { Random rand= new Random(); rand.setSeed(100); System.out.println(rand.nextDouble()); System.out.println(rand.nextDouble()); System.out.println(rand.nextDouble()); System.out.println(rand.nextDouble()); System.out.println(rand.nextDouble());

5 double numbers greater or equal to zero and less than 1

Math.sqrt(81); The method sqrt in the Math class is

A class method

Assume rand is an object of the Random Class. What is the output of this statement? System.out.println(rand.nextInt(1000));

A random number between 0 and 999

Assume rand is an object of the Random Class. What is the output of this statement? System.out.println(rand.nextInt(1001));

A random number between 0 to 1000

Assume rand is an object of the Random Class. What is the output of this statement? int x = rand.nextInt(1000)+1 System.out.println(x);

A random number from 1 to 1000

What is the output of the following statement? System.out.println( (int) (100*Math.random());

An integer in the [0...99] range

Bank Tom =new Bank (); What is Tom?

An object

Bank Tom =new Bank (); What is bank?

An object method

In the statement Bank tom = new Bank(5000.0); What is the class?

Bank

nextInt and nextDouble are methods of what classes?

Both Random and Scanner

Integer.MAX_VALUE and Integer.MIN_VALUE

Can be accessed like Math.PI,are constant values, are members of the Integer class

2.Integer.MAX_Value and Integer.MIN_VALUE

Constant fields or attributes

A class is a

Data type

DrawPolygon and fillPolygon are both methods of the _ class

Graphics

Which class makes it possible to draw a six sided polygon?

Polygon

nextInt and nextDouble are both methods of which classes?

Random and Scanner

Which if these statements will cause a different set of random numbers to be generated every time the program is executed?

Random rand = new Random ();

The new Java keyword must be used with

The construction of each object

Using the scanner class with numbers and strings can have unexpected results. This unexpected result can be cured by

Using a dummy String variables

An object is a type of

Variable

Java can combine 3 primary colors to create virtually any color. Which of the following is NOT one of those colors?

Yellow (rgb)

What is int?

a data type

Objects without identifiers are called ___ objects

anonymous

Which of the following statement generates a random character in the [A...Z] range?

char number = (char) (rand.nextInt(26)+65);

An example of a named object

g.setColor(myRed);

An example of an anonymous object?

g.setColor(newColor(100,100,100));

Which of the following statement generates a random number in the [0..100] range?

int number = rand.nextInt(101);

Which of the following statement generates a random number in the [-41..101] range?

int number = rand.nextInt(143)-41;

Which of the following statement generates a random number in the [200..600]range?

int number = rand.nextInt(401)+200;

Assume rand is an Object of the random class which of the following statements will cause Xt to have a random value in the same range as this statement Int x = rand.nextInt(1001) +500;

int x = (int) (Math.random() * 1001 + 500);

Assume rand has is an object of the Random class Which of the following statements will cause x to have a random value between 100 and 500

int x = rand.nextInt(401)+100;

The Random class is found inside the ________ package

java.util

The random method of the math class behaves Just like the_____ method of the _____ class.

nextDouble, Random

Which of the following are methods of the Random Class

nextInt, nextDouble, setSeed

Which graphics method changes color?

setColor

Access to methods of the Bank class requires

the creation of one of more Bank objects

In the statement Bank tom = new Bank(5000.0); Which is the object?

tom

Integer and Double are

wrapper classes


Set pelajaran terkait

Insulins: Onset, Peak, and Duration

View Set

Government Unit 3 United States Government

View Set

HA - Chapter 10: Assessing for Violence

View Set

ATI ——— Targeted Med-Surg GI

View Set

FIN 515: Financial Markets & Institutions - Ch. 4 Q&As

View Set