What does the following code output? System.out.print(“Java”); System.out.println(“Programming”);
Author: Anonymous
What is a comment in Java?
What is a comment in Java?
Consider the following code segment. int x = 2; i…
Consider the following code segment. int x = 2; int y = 1; int z = 0; if((y + 1) == x) { y++; z += y; } if(z == x) { x–; y = 5; } What are the values of x, y, and z after this code segment has been executed?
What happens when you use System.out.println() without any p…
What happens when you use System.out.println() without any parameters?
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”);}
Consider the following two code segments. Assume that the in…
Consider the following two code segments. Assume that the int variables m and n have been properly declared and initialized and are both greater than 0 . I.for (int i = 0; i < m * n; i++){ System.out.print("A");}II.for (int j = 1; j
Consider the following code segment. int num = 0;for (int i…
Consider the following code segment. int num = 0;for (int i = 0; i < 100; i++){num+=7;}System.out.println(num); What would be the output?
&& is evaluated before !.
&& is evaluated before !.
Consider the following code segment. String greet1 = “Good m…
Consider the following code segment. String greet1 = “Good morning!”;String greet2 = “Good afternoon!”;String greet3 = “Good evening”;int timeOfDay;if(timeOfDay >= 1700) { System.out.println(greet3);}else if(timeOfDay >= 1200) { System.out.println(greet2);}else { System.out.println(greet1);} What is printed as a result of executing the code segment if timeOfDay equals 1900?
Consider the following code segment. int num1 = 10;int num2…
Consider the following code segment. int num1 = 10;int num2 = 45;int num3 = 7;if(num1 > num2){ System.out.print((num1 + num2) % num3);}else{ System.out.print((num1 – num3) % num2);} What is printed as a result of executing the code segment?