Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






F An exception is thrown at runtime.

A 51

B 52

C 53

D 81

E 82

F 83

G 102

H 103

 

9. Given:

class Titanic {

public static void main(String[] args) {

boolean b1 = true;

boolean b2 = false;

boolean b3 = true;

if((b1 & b2) | (b2 & b3) & b3)

System.out.print("alpha ");

if((b1 = false) | (b1 & b3) | (b1 | b2))

System.out.print("beta "); } }

What is the result?

A beta

B alpha

C alpha beta

D Compilation fails.

E No output is produced.

F An exception is thrown at runtime.

 

10. Given:

 

1. class Maybe {

2. public static void main(String[] args) {

3. boolean b1 = true;

4. boolean b2 = false;

5. System.out.print(!false ^ false);

6. System.out.print(" " + (!b1 & (b2 = true)));

7. System.out.println(" " + (b2 ^ b1));
8. }

9. }

Which are true?

 

A Line 5 produces true.

B Line 5 produces false.

C Line 6 produces true.

D Line 6 produces false.

E Line 7 produces true

F Line 7 produces false.

11. Given:

 

class Sixties {

public static void main(String[] args) {

int x = 5;

int y = 7;

System.out.print(((y * 2) % x));

System.out.print(" " + (y % x));

}

}

What is the result?

A 1 1

B 1 2

C 21

D 22

E 41

F 42

G Compilation fails.

H An exception is thrown at runtime.

 

12. Given:

public class OrtegorumFunction {

public static void main(String [] args){

int r = 1, x = 11;

r += x;

if((x>4)&&(x<10)){

r += 2 * x;

} else if (x <= 4) {

r += 3 * x;

} else {

r += 4 * x;

}

r += 5 * x;

System.out.println(r);

}

}

What is the result?

A 45

B 56

C 89

D 111

E Compilation fails.

F An exception is thrown at runtime.

13.Given:

public class FreeRange {
public static void main(String[] args) {
int x = 7, y = 8;
if(x < y)
if(x+2 > y)
if(y < x) ;
else if(!false)
System.out.print("inner ");
else if(true)
System.out.print("middle ");
}
}

What is the result?

A. inner

B. middle

C. inner middle

D. middle inner

E. Compilation fails

F. An exception is thrown at runtime

14.Given:


class Test4 {
public static void main(String [] args) {
boolean x = true;
boolean y = false;
int z = 42;

if((z++ == 42) && (y = true)) z++;
if((x = false) || (++z == 45)) z++;

System.out.println("z = " + z);
}
}


What is the result?

 

A. z = 42

B. z = 44

C. z = 45

D. z = 46

E. Compilation fails

F. An exception is thrown at runtime



var textReference = getValue("textReference"); if (textReference.length > 0) { document.writeln("

" + textReference + "

"); } // if var code = getValue("codeReference"); if (code.length > 0) { document.writeln("" + code + ""); } // if var imagePath = getValue("image"); if (imagePath.length > 0) { document.writeln(""); } // if

15.What is the value of x after the following operation is performed?

 

x = 23 % 4;

 

A. 23

B. 4

C. 5.3

D. 3

E. 5

 

 

16.What is the value of x after the following line is executed?

 

x = 32 * (31 - 10 * 3);

 

A. 32

B. 31

C. 3

D. 704

E. None of the above

 

 

  17. Is this a complete and legal comment? /* // */ Select the one correct answer. a. No, the block comment (/* ... */) is not ended since the single-line comment (// ...) comments out the closing part. b. It is a completely valid comment. The // part is ignored by the compiler. c. This combination of comments is illegal and the compiler will reject it.    
18. What will be the result of attempting to compile and run the following class? public class Assignment { public static void main(String[] args) { int a, b, c; b = 10; a = b = c = 20; System.out.println(a); } } Select the one correct answer. a. The code will fail to compile, since the compiler will recognize that the variable c in the assignment statement a = b = c = 20; has not been initialized. b. The code will fail to compile because the assignment statement a = b = c = 20; is illegal. c. The code will compile correctly and will display 10 when run. d. The code will compile correctly and will display 20 when run.
19. What is the value of the expression (1 / 2 + 3 / 2 + 0.1)? Select the one correct answer. a. 1 b. 1.1 c. 1.6 d. 2 e. 2.1
20. What is the value of evaluating the following expression (- -1-3 * 10 / 5-1)? Select the one correct answer. a. –8 b. –6 c. 7 d. 8 e. 10 f. None of the above.  
21. What happens when you try to compile and run the following program? public class Prog1 { public static void main(String[] args) { int k = 1; int i = ++k + k++ + + k; System.out.println(i); } } Select the one correct answer. a. The program will not compile. The compiler will complain about the expression ++k + k++ + + k. b. The program will compile and will print the value 3 when run. c. The program will compile and will print the value 4 when run. d. The program will compile and will print the value 7 when run. e. The program will compile and will print the value 8 when run.  
22. What will the following program print when run? public class EvaluationOrder { public static void main(String[] args) { int[] array = { 4, 8, 16 }; int i=1; array[++i] = --i; System.out.println(array[0] + array[1] + array[2]); } } Select the one correct answer. a. 13 b. 14 c. 20 d. 21 e. 24
23. Which statements are true? Select the three correct answers. a. The result of the expression (1 + 2 + "3") would be the string "33". b. The result of the expression ("1" + 2 + 3) would be the string "15". c. The result of the expression (4 + 1.0f) would be the float value 5.0f. d. The result of the expression (10/9) would be the int value 1. e. The result of the expression ('a' + 1) would be the char value 'b'.
24. Which statements are true? Select the two correct answers. a. The remainder operator % can only be used with integral operands. b. Identifiers in Java are case insensitive. c. The arithmetic operators *, /, and % have the same level of precedence. d. (+15) is a legal expression. 25. Which of the following operators can be used both as an integer bitwise operator and a boolean logical operator? Select the three correct answers. a. ^ b. ! c. & d. | e. ~  
26. Which statements are true about the output of the following program? public class Logic { public static void main(String[] args) { int i = 0; int j = 0; boolean t = true; boolean r; r = (t & 0<(i+=1)); r = (t && 0<(i+=2)); r = (t | 0<(j+=1)); r = (t || 0<(j+=2)); System.out.println(i + " " + j); } } Select the two correct answers. a. The first digit printed is 1. b. The first digit printed is 2. c. The first digit printed is 3. d. The second digit printed is 1. e. The second digit printed is 2. f. The second digit printed is 3.
27. What will be the result of attempting to compile and run the following class? Select the one correct answer. public class IfTest { public static void main(String[] args) { if (true) if (false) System.out.println("a"); else System.out.println("b"); } } a. The code will fail to compile because the syntax of the if statement is incorrect. b. The code will fail to compile because the compiler will not be able to determine which if statement the else clause belongs to. c. The code will compile correctly and display the letter a when run. d. The code will compile correctly and display the letter b when run. e. The code will compile correctly, but will not display any output.
28. Which statements are true? Select the three correct answers. a. The conditional expression in an if statement can have method calls. b. If a and b are of type boolean, the expression (a = b) can be the conditional expression of an if statement. c. An if statement can have either an if clause or an else clause. d. The statement if (false) ; else ; is illegal. e. Only expressions which evaluate to a boolean value can be used as the condition in an if statement.
 
29.What will be the output when running the following program? public class MyClass { public static void main(String[] args) { int i=0; int j; for (j=0; j<10; ++j) { i++; } System.out.println(i + " " + j); } } Select the two correct answers. a. The first number printed will be 9. b. The first number printed will be 10. c. The first number printed will be 11. d. The second number printed will be 9. e. The second number printed will be 10. f. The second number printed will be 11.
30. Which one of these for statements is valid? Select the one correct answer. a. int j=10; for (int i=0, j+=90; i<j; i++) { j--; } b. for (int i=10; i=0; i--) {} c. for (int i=0, j=100; i<j; i++, --j) {;} d. int i, j; for (j=100; i<j; j--) { i += 2; } e. int i=100; for ((i>0); i--) {}

Date: 2015-12-11; view: 1205


<== previous page | next page ==>
Understand the marketplace | PRONUNCIATION VARIETIES OF ENGLISH
doclecture.net - lectures - 2014-2024 year. Copyright infringement or personal data (0.01 sec.)