Exam 2: Data and Expressions

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Use the following class definition to answer the questions below. public class Questions1_4 { public static void main(String[ ] args) { System.out.print("Here"); System.out.println("There " + "Everywhere"); System.out.println("But not" + "in Texas"); } } -The final println command will output

(Multiple Choice)
4.7/5
(33)

There are three ways that data conversion may occur by assignment, by promotion, by casting.

(True/False)
4.8/5
(39)

For the following questions, refer to the class defined below: import java.util.Scanner; public class Questions33_34 { public static void main(String[ ] args) { int x, y, z; double average; Scanner scan = new Scanner(System.in); System.out.println("Enter an integer value"); x = scan.nextInt( ); System.out.println("Enter another integer value"); y = scan.nextInt( ); System.out.println("Enter a third integer value"); z = scan.nextInt( ); average = (x + y + z) / 3; System.out.println("The result of my calculation is " + average); } } -Questions33_34 computes

(Multiple Choice)
4.9/5
(40)

Explain, in words, what the following statement computes: int z = (int) Math.ceil(Math.sqrt(x) / Math.sqrt(y));

(Essay)
4.8/5
(41)

Which library package would you import to use the class Random?

(Multiple Choice)
4.7/5
(29)

Write a program which will input an int value x, and compute and output the values of 2ˣ and x¹⁰ as int values.

(Essay)
4.8/5
(30)

If x is the String "Hi There", then x.toUpperCase( ).toLowerCase( ); will return the original version of x.

(True/False)
4.8/5
(29)

Since you cannot take the square root of a negative number, you might use which of the following instructions to find the square root of the variable x?

(Multiple Choice)
4.8/5
(42)

Use the following class definition to answer the questions below. public class Questions1_4 { public static void main(String[ ] args) { System.out.print("Here"); System.out.println("There " + "Everywhere"); System.out.println("But not" + "in Texas"); } } -The program will print the word "Here" and then print

(Multiple Choice)
4.8/5
(30)

Which library package would you import to use NumberFormat and DecimalFormat?

(Multiple Choice)
4.9/5
(38)

Provide an example of how you might use a boolean, a float, a char, a String, and an int.

(Essay)
4.9/5
(45)

Consider the following paint method and answer the questions below: public void paint(Graphics page) { page.setColor(Color.blue); page.fillRect(50, 50, 100, 100); page.setColor(Color.white); page.drawLine(50, 50, 150, 150); page.drawLine(50, 150, 150, 50); page.setColor(Color.black); page.drawString("A nice box", 50, 170); } -You specify the shape of an oval in a Java applet by defining the oval's

(Multiple Choice)
4.8/5
(38)

In order to generate a random number, you must use Math.random( ).

(True/False)
4.7/5
(37)

Unlike the String class where you must pass a message to an object (instance) of the class, as in x.length( ), in order to use either the Scanner or Math classes, you pass messages directly to the class name, as in Math.abs( ) or scan.nextInt( ).

(True/False)
4.8/5
(33)

Assume that x, y, and z are all integers (int) equal to 50, 20, and 6 respectively. What is the result of x / y / z?

(Multiple Choice)
4.9/5
(43)

If x is an int and y is a float, all of the following are legal except which assignment statement?

(Multiple Choice)
4.9/5
(38)

The Java graphics coordinate system is similar to the coordinate system one finds in mathematics in every respect.

(True/False)
4.8/5
(41)
Showing 61 - 77 of 77
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)