创原天地Java笔试题目.doc

上传人:xt****7 文档编号:125996719 上传时间:2020-03-21 格式:DOC 页数:8 大小:38KB
返回 下载 相关 举报
创原天地Java笔试题目.doc_第1页
第1页 / 共8页
创原天地Java笔试题目.doc_第2页
第2页 / 共8页
创原天地Java笔试题目.doc_第3页
第3页 / 共8页
创原天地Java笔试题目.doc_第4页
第4页 / 共8页
创原天地Java笔试题目.doc_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《创原天地Java笔试题目.doc》由会员分享,可在线阅读,更多相关《创原天地Java笔试题目.doc(8页珍藏版)》请在金锄头文库上搜索。

1、姓名:_ 日期:_创原天地Java笔试题目1. 下列结论不正确的是(5分)cdA call by value不会改变实际参数的数值B call by reference能改变实际参数的参考地址(reference)C call by reference不能改变实际参数的参考地址(reference)D call by reference能改变实际参数的内容2. 检查以下代码,并选择答案(5分)cpublic class Testpublic void printStr(final String str) str =str+”!”public static void main(String ar

2、gs)Test test=new Test();Test.printStr(“Hello world”); A:执行打印出”Hello world!”B: 执行期间抛出异常C:编译不通过D:以上答案都不是3. 下面关于变量及其范围的陈述哪些是不对的(5分)bA. 实例变量是类的成员变量。 B. 实例变量用关键字static声明。 C. 在方法中定义的局部变量在该方法被执行时创建 D. 局部变量在使用前必须被初始化4. 请写出如下代码的运行结果(5分)public class Test extends TT public static void main(String args) Test t

3、= new Test(Tom); public Test(String s) super(s); System.out.println(How do you do?); public Test() this(I am Tom); class TT public TT() System.out.println(What a pleasure!); public TT(String s) this(); System.out.println(I am +s); 5. 请写出如下代码的运行结果(5分)class Aclass void go() System.out.println(Aclass);

4、 public class Bclass extends Aclass void go System.out.println(Bclass); public static void main(String args) Aclass a=new Aclass(); Aclass a1=new Bclass(); a.go(); a1.go(); 6. 请写出如下代码的运行结果(5分)class Userful public void f() System.out.println(“Now in f method of super class”);public void g() System.ou

5、t.print(“Now in g method of super class”);class MoreUserfuld extends Userful pubic void f() System.out.println(“Now in f method of derived class”);pubic void g() System.out.println(“Now in g method of derived class”);public void u() System.out.println(“Now in u method of derived class”);public void

6、v() System.out.println(“Now in v method of derived class”);pubic void w() System.out.println(“Now in w method of derived class”);public class Test public static void main(String args) Userful x = new Userful(), new MoreUserful() ;x0.f(); x1.g(); (MoreUserful)x1).u();7. 请说明Java中访问修饰符public、protected、

7、private和缺省修饰符修饰数据成员和成员方法时所限定的访问范围(10分) 在同一类中 同一包中 不同包中 同一包的子类中 不同包子类中public yes yes yes yes yesprotected yes yes no yes yespackage yes yes no yes noprivate yes no no no no编写程序:创建一个链表(ArrayList或LinkedList),并把如下字符串(red,green,yellow,black,white,blue,cyan,grey)增加到链表中,然后用迭代子在控制台打印输出链表中的所有元素(20分)8. public

8、 class test public static void main(String args) throws ExceptionArrayList al= new ArrayList(); al.add(“red”);al.add(“green”);al.add(“yellow”);.Iterator it = al.iterator();while(it.hasNext() system.out.println(it.next();9. 请用Struts完成以下描述的功能(20分)用户从IE客户端输入字符串Hello,并提交给HellAction,在Action中给Hello转换成”hel

9、lo world!” 并显示给用户 下面为处理流程的配置文件HelloAction.javahello.jspSayhello.jspinputforward 表单HelloForm.javapublic Class HelloFormprivate String content;public String getContent()return this.content;public void setContent(String content)this.content = content;请实现hello.jsp 、HelloAction.java 、sayhello.jsp Hello.j

10、sp: Simple jsp page HelloAction.java:public class HelloWorld extends Action public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception String msg= servletRequest.getParameter(“msg”); If(msg

11、.equals(“Hello”)servletRequest.setAttribute(msg, hello World ); return actionMapping.findForward(SayHello ); Sayhello.jsp: Simple jsp page $msg 10. 现在有一名为UserTab.java的 POJO对象,请编程这个对象的数据写入到数据库对应的表USERTAB中(20分)表UERTAB的表结构如下 表 USERTAB USERID INTEGER PK USERNAME VARCHAR2(20) ADDRESS VARCHAR2(100)public class UserTabprivate java.lang.Integer userIDprivate String userName;privtae String address; public UserTab(java.lang.

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 试题/考题

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号