Depois da execução do fragmento de código abaixo, quais são os valores das variaveis 'x', 'a', e 'b'?
int x, a = 6, b =7; x = a++ + b++;
1.a. | x = 15, a = 7, b = 8; |
1.b. | x = 15; a = 6, b = 7; |
1.c. | x = 13; a = 7; b = 8; |
1.d. | x = 13, a = 6; b = 7; |
Quais das seguintes Expressões são legais? (escolha uma ou mais)
2.a. | int x = 6; x = !x; |
2.b. | int x = 6; if (!(x > 3)) {} |
2.c. | int x = 6; x = ~x; |
Quais das seguintes expressões resultam um valor positivo em x? (escolha uma)
3.a. | int x = -1; x = x >>> 5; |
3.b. | int x = -1; x = x >>> 32; |
3.c. | byte x = -1; x = x >>> 5; |
3.d. | int x = -1; x = x >> 5; |
Quais das seguintes expressões são legais?
4.a. | String x = “Hello"; int y = 9; x += y; |
4.b. | String x = “Hello"; int y = 9; if (x == y) {} |
4.c. | String x = “Hello"; int y = 9; x = x + y; |
4.d. | String x = “Hello"; int y = 9; y = y + x; |
4.e. | String x = null; int y = (x != null) && (x.length() > 0) ? x.length() : 0; |
Quais dos seguintes fragmentos de código será compilado com sucesso e imprimirá na execução a palavra “Equal"? (escolha uma ou mais)
5.a. | int x = 100; float y = 100.OF; if (x == y) {System.out.println(“Equal");} |
5.b. | int x = 100; Integer y = new Integer(100); if (x == y) {System.out.println(“Equal");} |
5.c. | Integer x = new Integer(100); Integer y = new Integer(100); if (x == y) {System.out.println(“Equal");} |
5.d. | String x = new String(“100");String y = new String(“100"); if (x == y) { System.out.println(“Equal");} |
5.e. | String x = “100"; String y = “100"; if (x == y) {System.out.println(“Equal");} |
Quais os resultados da execução do seguinte código?
1. public class short { 2. public static void main(String args[]) { 3. StringBuffer s = new StringBuffer(“Hello"); 4. if ((s.length() > 5) && 5. (s.append(“ there‿).equals(“False"))) 6. ; // do nothing 7. System.out.println(“value is “ + s); 8. } 9. }
6.a. | A saída é: Hello |
6.b. | A saída é: Hello there |
6.c. | Erro de compilação na linha 4 ou 5 |
6.d. | Nenhuma saída |
6.e. | Ocorre uma NullPointerException |
Qual resultado da execução do seguinte código?
1. public class Xor{ 2. public static void main(String args[]) { 3. byte b = 10; // 0001010 binary 4. byte c = 15; // 00001111 binary 5. b = (byte)(b ^c); 6. System.out.println(“b contains “ + b); 7. } 8. }
7.a. | Saída: b contains 10; |
7.b. | Saída: b contains 5; |
7.c. | Saída: b contains 250; |
7.d. | Saída: b contains 245; |
Qual o resultado da tentativa de compilar e executar o seguinte código?
1. public class Ternary { 2. public static void main(String args[]) { 3. int x = 4; 4. System.out.println(“value is “ + 5. ((x > 4) ? 99.99 : 9)); 6. } 7. }
8.a. | Saída: value is 99.99 |
8.b. | Saída: value is 9 |
8.c. | Saída: value is 9.0 |
8.d. | Erro de compilação na linha 5 |
Qual é a saída deste fragmento de código?
1. int x = 3; int y = 10; 2. System.out.println(y % x);
9.a. | 0 |
9.b. | 1 |
9.c. | 2 |
9.d. | 3 |
Copyright © 1998-2009 Dilvan Moreira