考试网 >> IT认证 >> JAVA >> JAVA题库 >> JAVA题库:格林模拟试题二(上)

JAVA题库:格林模拟试题二(上)

发布时间:2006-06-28 10:51     点击:
分页:[1] 2 3 4 5 6 7 8 9 10  下一页  后10页

Question 1)



What will happen when you attempt to compile and run this code?



abstract class Base{

abstract public void myfunc();

public void another(){

System.out.println("Another method");

}

}

public class Abs extends Base{

public static void main(String argv[]){

Abs a = new Abs();

a.amethod();

}

public void myfunc(){

System.out.println("My Func");

}

public void amethod(){

myfunc();

}

}



1) The code will compile and run, printing out the words "My Func"

2) The compiler will complain that the Base class has non abstract methods

3) The code will compile but complain at run time that the Base class has non abstract methods

4) The compiler will complain that the method myfunc in the base class has no body, nobody at all to looove it




Question 2)

What will happen when you attempt to compile and run this code?



public class MyMain{

public static void main(String argv){

System.out.println("Hello cruel world");

}

}



1) The compiler will complain that main is a reserved word and cannot be used for a class

2) The code will compile and when run will print out "Hello cruel world"

3) The code will compile but will complain at run time that no constructor is defined

4) The code will compile but will complain at run time that main is not correctly defined

分页:[1] 2 3 4 5 6 7 8 9 10  下一页  后10页
版权申明:未经书面授权请勿转载本站信息!!作品版权归所属媒体与作者所有!!
发表评论: 匿名发表 用户名: 查看评论
您将承担一切因您的行为、言论而直接或间接导致的民事或刑事法律责任
留言板管理人员有权保留或删除其管辖留言中的任意内容
本站提醒:不要进行人身攻击。谢谢配合。
在本站搜索相关信息
2003-2005 Ksw123.com All Rights Reserved. - TOP
Copyright © 2006 Ksw123.com. All rights reserved.中国考题网 版权所有