What is the output of the following code fragment? Assume all the variables are declared. somenumber = 100;if(somenumber > 50) { System.out.print(“first “); System.out.print(“second “); System.out.print(“third”);}
Blog
&& is evaluated before !.
&& is evaluated before !.
Consider the following code segment. boolean x = true; b…
Consider the following code segment. boolean x = true; boolean y = false; System.out.print((x == !y) != false); What is printed as a result of executing this code segment?
Consider the following code segment. String oldStr = “ABCD…
Consider the following code segment. String oldStr = “ABCDEF”;String newStr = oldStr.substring(1, 3) + oldStr.substring(4);System.out.println(newStr); What is printed as a result of executing the code segment?
What keyword is used with class methods?
What keyword is used with class methods?
Consider the following code segment. int num = /* initial va…
Consider the following code segment. int num = /* initial value not shown */;boolean b1 = true;if (num > 0){ if (num >= 100) { b1 = false; }}else{ if (num >= -100) { b1 = false; }} Which of the following statements assigns the same value to b2 as the code segment assigns to b1 for all values of num?
Consider the following code segment. double regularPrice = 1…
Consider the following code segment. double regularPrice = 100; boolean onClearance = true; boolean hasCoupon = false; double finalPrice = regularPrice; if(onClearance) { finalPrice -= finalPrice * 0.25; } if(hasCoupon) { finalPrice -= 5.0; } System.out.println(finalPrice); What is printed as a result of executing the code segment?
Which of the following code segments produces the output “98…
Which of the following code segments produces the output “987654321” ?
What does String substring(int from, int to) return?
What does String substring(int from, int to) return?
Which statement generates random numbers in the range from 0…
Which statement generates random numbers in the range from 0 through 100?