How many objects can you create from a class?
Blog
What is a method in programming?
What is a method in programming?
Consider the following method. public void test(int x){ i…
Consider the following method. public void test(int x){ int y; if (x % 2 == 0) y = 3; else if (x > 9) y = 5; else y = 1; System.out.println(“y = ” + y);} Which of the following test data sets would test each possible output for the method?
What is the output of the following code fragment? Assume al…
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”);}
&& 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?