Pessoal tô com uma dúvida cruel,
Alguém poderia me explicar porquê na questão 25 é impresso o valor 100, e na questão 26 é gerada uma exceção... pra mim, era pra serem geradas exceções em ambas as questões. Não seria necessário um cast explícito, tipo (int) i?
Q25.What will be the outcome of executing following code.
class MyClass
{
public static void main(String []args)
{
final int i = 100;
byte b = i;
System.out.println(b);
}
}
Will give compilation error
Will compile and print 100
Will throw an exception
SKIP THE QUESTION
Q26.What will be the outcome of executing following code.
class MyClass
{
public static void main(String []args)
{
int i = 100;
byte b = i;
System.out.println(b);
}
}
Will give compilation error
Will compile and print 100
Will throw an exception
SKIP THE QUESTION
[]'s Tone