Exam 2: Fundamental Data Types

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

What is the output of the following code snippet? Public static void main(String[] args){ { String str1; Str1 = "I LOVE MY COUNTRY"; String str2 = str1.substring(4, 9); System.out.println(str2); }

(Multiple Choice)
4.8/5
(29)

What does the following statement sequence print? String str = "Harry"; Int n = str.length(); String mystery = str.substring(0, 1) + str.substring(n - 2, n); System.out.println(mystery);

(Multiple Choice)
4.8/5
(33)

Which of the following statements is correct about constants?

(Multiple Choice)
4.8/5
(51)

What is the output of the following code snippet? String firstname = "William"; String lastname; System.out.println("First: " + first); System.out.println("Last: " + lastname);

(Multiple Choice)
4.9/5
(31)

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

(Multiple Choice)
4.8/5
(26)

How do you extract the first 5 characters from the string str?

(Multiple Choice)
4.8/5
(32)

What does the following statement sequence print? String str = "Hello"; Int n = str.length(); String mystery = str.substring(0, 1) + str.substring(n - 2, n + 1); System.out.println(mystery);

(Multiple Choice)
4.9/5
(32)

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 "); Int myInt = in.nextInt(); MyInt += 456; System.out.println(myInt); }

(Multiple Choice)
4.8/5
(42)

Which of the following statements with comments is(are) valid? I. int cnt = 0; /* Set count to 0 II. int cnt = 0; /* Set count to 0 */ III. int cnt = 0; // Set count to 0

(Multiple Choice)
4.8/5
(41)

Which one of the following statements displays the output as 54321.00?

(Multiple Choice)
4.8/5
(40)

What is the output of the following code snippet? Public static void main(String[] args) { Int num1 = 10; Int num2 = 5; Int num3 = 200; Num3 = num3 % (num1 * num2); System.out.println(num3); }

(Multiple Choice)
4.8/5
(37)

What is the output of this code snippet? Double average; Int grade1 = 87; Int grade2 = 94; // System.out.print("The average is " + (grade1 + grade2) / 2.0); System.out.print("The average is " + average);

(Multiple Choice)
4.8/5
(35)

Which one of the following is a correct representation of the given mathematical expression in Java? Which one of the following is a correct representation of the given mathematical expression in Java?

(Multiple Choice)
5.0/5
(37)

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

(Multiple Choice)
4.8/5
(37)

The assignment operator

(Multiple Choice)
4.7/5
(34)

What is the correct way to invoke methods on variables in Java that are strings?

(Multiple Choice)
4.9/5
(47)

Which one of the following statements displays the output as +00321.00?

(Multiple Choice)
4.9/5
(34)

What is the output of the following code snippet? Public static void main(String[] args) { Int s; Double f = 365.25; S = f / 10; System.out.println(s); }

(Multiple Choice)
4.8/5
(43)

Suppose a phone number, stored as a ten-character string (of digits only) called phoneNumber, must be converted into a string that has parentheses around the area code. Which statement below will do that?

(Multiple Choice)
4.9/5
(37)

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

(Multiple Choice)
4.7/5
(36)
Showing 41 - 60 of 103
close modal

Filters

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