Exam 4: Fundamental Data Types

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

Assume the following variables have been declared and given values as shown: Int i = 2345; Double m = 67.8; What will be printed by the statement below? System.out.printf ("Values are %10d and %7.2f", i, j);

(Multiple Choice)
5.0/5
(31)

Which one of the following statements can be used to get the fifth character from a string str?

(Multiple Choice)
4.9/5
(35)

What happens to the fractional part when a division is performed on two integer variables?

(Multiple Choice)
4.7/5
(37)

Which of the methods below are static methods? I. length II. substring III. pow IV. sqrt

(Multiple Choice)
4.8/5
(36)

When you purchase donuts, they come in boxes of 12, so 24 donuts take 2 boxes. All donuts need to be in a box, so if you buy 13 donuts, you'll get 2 boxes with 12 in the first box and 1 in the second. If the integer variable numberOfDonuts contains the positive number of donuts purchased, which of the following will correctly give the number of boxes needed?

(Multiple Choice)
4.8/5
(30)

What is the value of Math.abs(-2)?

(Multiple Choice)
5.0/5
(46)

What is the value of the following expression? -18 % 5

(Multiple Choice)
4.8/5
(36)

Which one of the following is a correct method for defining and initializing an integer variable with name value?

(Multiple Choice)
4.8/5
(38)

One way to avoid round-off errors is to use:

(Multiple Choice)
4.7/5
(44)

At what point in the problem-solving process should one write pseudocode?

(Multiple Choice)
4.9/5
(38)

) Which one of the following is an assignment statement?

(Multiple Choice)
4.8/5
(41)

What does the following statement sequence print if the user input is 123? public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a number: "); String str = in.next(); Str += 456; System.out.println(str); }

(Multiple Choice)
4.7/5
(32)

Which one of the following statements can be used to convert a string str to a double?

(Multiple Choice)
4.8/5
(34)

Which one of the following reserved words is used in Java to represent a value without a fractional part?

(Multiple Choice)
4.7/5
(44)

Which of the following options is valid with reference to the code snippet? public static void main(String[] args) { Double d = 45.326; Double r = d % 9.0; System.out.println(r); }

(Multiple Choice)
4.8/5
(36)

What is the output of the following code snippet? public static void main(String[] args) { Int value = 3; Value++; System.out.println(value); }

(Multiple Choice)
4.9/5
(37)

What is wrong with the following code snippet? Int average; Average = 78A;

(Multiple Choice)
4.9/5
(44)

Assume the following variables have been declared and given values as shown: String str = "0123456789"; String sub = str.substring(3, 4); Which is the value of sub?

(Multiple Choice)
4.9/5
(39)

Which one of the following statements can be used to extract the last five characters from any string variable str?

(Multiple Choice)
4.9/5
(32)

What is the value of Math.pow(3, 2)?

(Multiple Choice)
4.9/5
(29)
Showing 41 - 60 of 125
close modal

Filters

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