Given:
int myChar = 97; int yourChar = 98; System.out.print((char)myChar + (char)yourChar); int age = 20; System.out.print(" "); System.out.print((float)age);What is the output?
- 195 20.0
- 195 20
- ab 20.0
- ab 20
- Compilation error
- Runtime exception
Which of the options are correct for the following code?
public class Prim { // line 1 public static void main(String[] args) { // line 2 char a = 'a'; // line 3 char b = -10; // line 4 char c = '1'; // line 5 integer d = 1000; // line 6 System.out.println(++a + b++ * c - d); // line 7 } // line 8 } // line 9
- Code at line 4 fails to compile.
- Code at line 5 fails to compile.
- Code at line 6 fails to compile.
- Code at line 7 fails to compile.
What is the output of the following code?
public class Foo { public static void main(String[] args) { int a = 10; long b = 20; short c = 30; System.out.println(++a + b++ * c); } }
- 611
- 641
- 930
- 960
Given:
Boolean buy = new Boolean(true); Boolean sell = new Boolean(true); System.out.print(buy == sell); boolean buyPrim = buy.booleanValue(); System.out.print(!buyPrim); System.out.print(buy && sell);What is the output?
- falsefalsefalse
- truefalsetrue
- falsetruetrue
- falsefalsetrue
- Compilation error
- Runtime exception
Which of the following options contain correct code to declare and initialize variables to store whole numbers?
- bit a = 0;
- integer a2 = 7;
- long a3 = 0x10C;
- short a4 = 0512;
- double a5 = 10;
- byte a7 = -0;
- long a8 = 123456789;
Select the options that, when inserted at // INSERT CODE HERE, will make the following code output a value of 11:
public class IncrementNum { public static void main(String[] args) { int ctr = 50; // INSERT CODE HERE System.out.println(ctr % 20); } }
- ctr += 1;
- ctr =+ 1;
- ++ctr;
- ctr = 1;
What is the output of the following code?
int a = 10; int b = 20; int c = (a * (b + 2)) - 10-4 * ((2*2) - 6; System.out.println(c);
- 218
- 232
- 246
- Compilation error
What is true about the following lines of code?
boolean b = false; int i = 90; System.out.println(i >= b);
- Code prints true
- Code prints false
- Code prints 90 >= false
- Compilation error
Examine the following code and select the correct options:
public class Prim { // line 1 public static void main(String[] args) { // line 2 int num1 = 12; // line 3 float num2 = 17.8f; // line 4 boolean eJavaResult = true; // line 5 boolean returnVal = num1 >= 12 && num2 < 4.567 // line 6 || eJavaResult == true; System.out.println(returnVal); // line 7 } // line 8 } // line 9
- Code prints false
- Code prints true
- Code will print true if code on line 6 is modified to the following:
boolean returnVal = (num1 >= 12 && num2 < 4.567) || eJavaResult == true;- Code will print true if code on line 6 is modified to the following:
boolean returnVal = num1 >= 12 && (num2 < 4.567 || eJavaResult == false);
Given:
boolean myBool = false; // line 1 int yourInt = 10; // line 2 float hisFloat = 19.54f; // line 3 System.out.println(hisFloat = yourInt); // line 4 System.out.println(yourInt > 10); // line 5 System.out.println(myBool = false); // line 6What is the result?
true true false
10.0 false false
false false false- Compilation error
3.22.61.218