JAVA模拟题:TestoftheJavaSkill(1)
百度广告
class Base{
System.out.println("amethod");
}
public class Fin extends Base{
Base b = new Base();
}
A. Compile time error indicating that a class with any final methods must be declared final itself
B. Compile time error indicating that you cannot inherit from a class with final methods
C. Run time error indicating that Base is not defined as final
D. Success in compilation and output of "amethod" at run time
Question 2:
public class Pass{
public static void main(String argv){
Pass p = new Pass();
p.amethod(i);
System.out.println(j);
public void amethod(int x){
j=j*2;
}
A. Error: amethod parameter does not match variable
B. 20 and 40
C. 10 and 40
D. 10 and 20
Question 3:
// File P1.java
package MyPackage;
void afancymethod(){
}
// File P2.java
public class P2 extends P1{
}
A. Both compile and P2 outputs "what a fancy method" when run
B. Neither will compile
C. Both compile but P2 has an error at run time
D. P1 compiles cleanly but P2 has an error at compile time |||
Question 4:
referring to an array of 50 string objects?
A. char a;
B. String a;
C. String a;
D. Object a[50];
E. String a[50];
Question 5:
String s = "Example";
A. s >>> = 3;
B. s >> = 2;
C. int i = s.length();
D. String t = "For " + s;
Question 6:
public class Scope{
public static void main(String argv){
s.amethod();
public static void amethod(){
}
A. A value of 0 will be printed out
B. Nothing will be printed out
C. A compile time error
D. A compile time error complaining of the scope of the variable i
Question 7:
public class Outer{
public static void main(String argv){
i.showName();
private class Inner{
void showName(){
}
}
A. Compile and run with output of "Outer"
B. Compile and run with output of "Inner"
C. Compile time error because Inner is declared as private
D. Compile time error because of the line creating the instance of Inner
Question 8:
public class Conv{
Conv c = new Conv();
c.amethod(s);
public void amethod(String s){
c+=s;
}
A. Compilation and output the String "Hello"
B. Compilation and output the String "ello"
C. Compilation and output the String "elloH"
D. Compile time error(CN-JAVA)
编辑推荐:
温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)
点击加载更多评论>>