Test of the Java Skill(1)
2008-01-05 20:29:25 来源:WEB开发网
Question 1:
What will happen when you attempt to compile and run this code?
class Base{
public final void amethod(){
System.out.PRintln(“amethod”);
}
}
public class Fin extends Base{
public static void main(String argv[]){
Base b = new Base();
b.amethod();
}
}
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:
Given the following code what will be output?
public class Pass{
static int j = 20;
public static void main(String argv[]){
int i=10;
Pass p = new Pass();
p.amethod(i);
System.out.println(i);
System.out.println(j);
}
public void amethod(int x){
x=x*2;
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:
What happens when you attempt to compile and run these two files in the same Directory?
// File P1.java
package MyPackage;
class P1{
void afancymethod(){
System.out.println(“what a fancy method”);
}
}
// File P2.java
public class P2 extends P1{
afancymethod();
}
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:
Which statement declares a variable a which is suitable for
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:
Given the following declaration
String s = "Example";
Which are legal code?
A. s >>> = 3;
- ››office默认输入法设置
- ››Office2010操作小技巧:使用Excel聊天
- ››Office2010操作技巧:Excel自动读取单元格内容
- ››Office2007新文件格式的优点
- ››Office 2010 新特性:Outlook 2010
- ››Office 2010 新特性:PowerPoint 2010
- ››Office 2010 新特性: Excle 2010
- ››Office中Word十技巧 受益终身
- ››Office 2010宝典 word之利用文档导航窗格控制文档...
- ››Office 2010宝典 word之(2)利用文档导航窗格搜索文...
- ››Office 2010宝典 word之(3)可以朗读的屏幕取词翻译...
- ››Office 2010宝典 word之(4)多语言翻译
赞助商链接