10 QUESTIONS please choose the right one fast please im in a
10 QUESTIONS, please choose the right one. fast please, i\'m in a exam.
What is the output of the following code?
public class Test {
public static void main(String[] args) {
System.out.println(m(\"ABCDEFG\"));
}
public static String m(String s) {
return s.substring(0, 3) + s.substring(5);
}
}
Select one:
a. ABCEG
b. ABCFG
c. ABFG
d. ABCEFG
Next
Which of the following code displays the area of a circle if the radius is positive.
Select one:
a. if (radius <= 0) System.out.println(radius * radius * 3.14159);
b. if (radius > 0) System.out.println(radius * radius * 3.14159);
c. if (radius != 0) System.out.println(radius * radius * 3.14159);
d. if (radius >= 0) System.out.println(radius * radius * 3.14159);
To declare a constant MAX_LENGTH inside a method with value 99.98, you write
Select one:
a. final float MAX_LENGTH = 99.98;
b. double MAX_LENGTH = 99.98;
c. final MAX_LENGTH = 99.98;
d. final double MAX_LENGTH = 99.98;
Suppose
static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}
}
What is the printout of the call nPrint(\'a\', 4)?
Select one:
a. invalid call, because \'a\' is a character, not a string.
b. aaaa
c. aaaaa
d. aaa
What is x after evaluating
x = (2 > 3) ? 2 : 3;
Select one:
a. 4
b. 5
c. 3
d. 2
Next
Analyze the following code: public class Test { public static void main (String args[]) { int i = 0; for (i = 0; i < 10; i++); System.out.println(i + 4); } }
Select one:
a. The program compiles despite the semicolon (;) on the for loop line, and displays 14.
b. The program compiles despite the semicolon (;) on the for loop line, and displays 4.
c. The program has a runtime error because of the semicolon (;) on the for loop line.
d. The program has a compile error because of the semicolon (;) on the for loop line.
Which of the following expression yields an integer between 0 and 100, inclusive?
Select one:
a. (int)(Math.random() * 100) + 1
b. (int)(Math.random() * 101)
c. (int)(Math.random() * 100 + 1)
d. (int)(Math.random() * 100)
What is the output for y?
int y = 0;
for (int i = 0; i<10; ++i) {
y += i;
}
System.out.printlnYes;
Select one:
a. 11
b. 13
c. 45
d. 12
A Java statement ends with a __________.
Select one:
a. closing brace
b. semicolon (;)
c. period (.)
d. comma (,)
Assume that the ASCII code for character c is 99 and for a is 97. What is the printout of the following code?
System.out.println(\"AB\" + \'a\' + \'c\');
Select one:
a. AB9799
b. ABac
c. AB196
d. ABa99
Solution
Sorry you are saying its urgent .. i haven\'t explain the answers
1)
b) ABCFG
2)
b. if (radius > 0) System.out.println(radius * radius * 3.14159);
3)
d. final double MAX_LENGTH = 99.98;
4)
b. aaaa
5)
c. 3
6)
a. The program compiles despite the semicolon (;) on the for loop line, and displays 14.
7)
b. (int)(Math.random() * 101)
8)
c. 45
9)
b. semicolon (;)
10)
b. ABac


