Which of the following statements it true about the following code:
public abstract final void goAndGetCertified() {}
The code will successfully compile and run.
The code will compile but not run.
A final method cannot be void, so the code will not compile.
A final method cannot be abstract, so the code will not compile.
A final method cannot be public, so the code will not compile.
A final method cannot be abstract, so the code will not compile.
############################
Which of the following statements it true about the following code:
public abstract void goAndGetCertified() {}
The code will successfully compile and run.
The code will compile but not run.
An abstract method cannot be void, so the code will not compile.
An abstract method cannot be public, so the code will not compile.
An abstract method cannot have a name, so the code will not compile.
An abstract method cannot have an implementation, so the code will not compile.
************************************
Which statement is true about the following code:
public class SCJP{
public static void main(String argv[]){
final int x = 10;
private short y = x ;
System.out.print(x);
System.out.println(y);
}
}
a) The code would compile but not run.
b) The code would compile, run, and print 1010 to the console.
c) The code will not compile as final variables are not allowed in static methods.
d) The code will not compiles as private variables are not allowed in static methods.
e) The code will not compile because an int value cannot be assigned to a short.
Option d) is correct.
#####################################
Which statement is true about the following code:
public class SCJP{
public static void main(String argv[]){
final int x = 10;
short y = x ;
System.out.print(x);
System.out.println(y);
}
}
a) The code would compile but not run.
b) The code would compile, run, and print 1010 to the console.
c) The code will not compile as final variables are not allowed in static methods.
d) The code will not compiles as private variables are not allowed in static methods.
e) The code will not compile because an int value cannot be assigned to a short.
Option b) is correct.
##########################################
Which statement is true about the following code:
public class SCJP{
public static void main(String argv[]){
final int x;
x = 10;
short y = x ;
System.out.print(x);
System.out.println(y);
}
}
a) The code would compile but not run.
b) The code would compile, run, and print 1010 to the console.
c) The code will not compile as final variables are not allowed in static methods.
d) The code will not compiles as private variables are not allowed in static methods.
e) The code will not compile because an int value cannot be assigned to a short.
Option e) is correct.
#############################################
Which statement is true about the following code:
public class SCJP6{
public static void main(String argv[]){
final int x = 35000;
short y = x ;
System.out.print(x);
System.out.println(y);
}
}
a) The code would compile but not run.
b) The code would compile, run, and print 1010 to the console.
c) The code will not compile as final variables are not allowed in static methods.
d) The code will not compiles as private variables are not allowed in static methods.
e) The code will not compile because an int value cannot be assigned to a short.
Optoin e) is correct.
This link on JavaRanch has some great info on this topic: JavaRanch thread.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment