Mistakes Flashcards
Does it compile?
int num =0, num2=0;
Yes
public static void main(String[] args) {
String chair, table = "metal"; chair = chair+table; System.out.println(chair); }
DNC bc local variable is not initialzed and they dont have the default value.
double chair = 8.0f;
System.out.println(chair);
runs fine
public static String convert(Integer value) {
return value.toString();
}
public static String convert(int value) { return value.toString(); } public static String convert(Object value) { return value.toString(); }
yes
DNC
yes
What can you put to have d=0?
short, double, int, byte?
public static void main(String[] args) {
____ d;
System.out.println(d);
}
DNC because local variables does not have a default value
What can you put to have d=0?
double d;
public static void main(String[] args) {
System.out.println(d);
}
DNC
What will be the output?
public class Birthday {
double d;
public static void main(String[] args) {
Birthday d = new Birthday();
System.out.println(d.d);
}
0.0
finalize() method memorize how it may be called?
It may be callled zero or one times
int Integer =1;
int String = 1;
System.out.println(Integer);
1, compiles both cases.
Will this compile?
public static void main(String[] args) {
Double d = new Double(100);
double dd = new Double(100);
}
yes
you can convert a primitive to wrapper class object simply by assigning it.
Can you force garbage collection to occur at certain point?
never.
parseInt() is used with which primitive or reference?
primitive
valueOf() is used with which? primitive or reference?
reference
String message = 11>10? “Greagt”:false;
dnc
String a =null;
int b = 2;
System.out.println(a==b);
DNC