duvida se compila na linha int big = Integer.getInteger("7");
na execução da erro de:
e quais alterantivas corretas abaixo …eu pus a letra D
Exception in thread "main" java.lang.NullPointerException
at br.com.cert.scjp1.Ex06.main(Ex06.java:12)
Section 1: Declarations, Initialization and Scoping > Objective 1.3 > Question 6
Given the five declarations:
int a_really_really_really_long_variable_name = 5;
int _hi =6;
int big = Integer.getInteger("7");
int $dollars = 8;
int %percent = 9;
How many will compile?
A 1 B 2 C 3 D 4 E 5
minha duvida abaixo é a seguinte qdo segundo if
do ++z==44 ele não foi contado mais um essa é minha duvida
para o resultado …
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean x = true;
boolean y = false;
short z = 42;
if((x == true) && (y = true)) {
System.out.println("passo1");
z++;
}
if((y == true) || (++z == 44)){
System.out.println("passo2");
z++;
}
System.out.println("z = " + z);
}
}
tenho duvida refrente assert pois nunca consegui rodar
e testar esses casos
Section 2: Flow Control > Objective 2.3 > Question 18
Given:
1. class MoreAsserts {
2. static int x = 5;
3. public static void main(String [] args) {
4. assert(doStuff(42));
5. if(x < 40) ;
6. else assert(false);
7. }
8. public static boolean doStuff(int arg) {
9. assert(arg < x++);
10. return false;
11. }
12. }
Which is true?
A None of the assert statements are appropriate.
B The assert statement on line 4 is appropriate.
C The assert statement on line 6 is appropriate.
D The assert statement on line 9 is appropriate.
E All three of the assert statements are appropriate.
outra duvida abaixo qdo usar throw new XXXXXXXX() na linha abaixo a esse comando não posso
usar nenhum comando é isso ???
public class Ex21 {
public static void main(String [] args) {
try {
System.out.print("before ");
throw new FlowException();
// System.out.print("after ");
} catch (FlowException fe) {
System.out.print("catch ");
}
System.out.println("done ");
}
}
class FlowException extends Exception { }
essa não entendi ::::
fui na opção A
Section 3: API Contents > Objective 3.2 > Question 28
Given:
31. String s = "write a line to a file";
32. w.print(s + "\n");
Which is true?
A w can be of either type PrintWriter or BufferedWriter.
B w can be of NEITHER type PrintWriter nor BufferedWriter.
C w can be of type PrintWriter, but NOT of type BufferedWriter.
D w can be of type BufferedWriter, but NOT of type PrintWriter
tb não entendi a pergunta ???
poia resposta é a letra A
Given:
11. class Ford extends Car implements Serializable {
12. Ford() { System.out.print("new Ford "); }
13. }
14.
15. class Car {
16. Car() { System.out.print("new Car "); }
17. }
If you attempt to deserialize a properly serialized instance of Ford, what is the result?
A new Car
B new Ford
C new Car new Ford
D new Ford new Car
E Compilation fails.
F An exception is thrown at runtime.
--------------------------------------------------------------------------------------------------------
