电话:0731-83595998
导航

JAVA模拟题:TestoftheJavaSkill(1)

来源: 2017-12-19 10:40

 百度广告

  Question 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)

编辑推荐:

下载Word文档

温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)

网络课程 新人注册送三重礼

已有 22658 名学员学习以下课程通过考试

网友评论(共0条评论)

请自觉遵守互联网相关政策法规,评论内容只代表网友观点!

最新评论

点击加载更多评论>>

精品课程

更多
10781人学习

免费试听更多

相关推荐
图书更多+
  • 电网书籍
  • 财会书籍
  • 其它工学书籍
拼团课程更多+
  • 电气拼团课程
  • 财会拼团课程
  • 其它工学拼团
热门排行

长理培训客户端 资讯,试题,视频一手掌握

去 App Store 免费下载 iOS 客户端