2月上海java面试题

更新时间:2023-07-23 03:56:55 阅读: 评论:0

2月上海java面试题
一:选择题
1.有一个utf-8格式的文件,内容为“中国”两个汉字,如
果将这个文本文件读入string对象,该对象占几个字节?
C 标准的utf-8应该4个字节,但后来扩展为6个字节
a)1
b)4
c)6
d)8
2.jsp页面中包含的taglib标签是在何时被解析成html文本
的?D
a)客户端浏览器刷新页面时解析标签并和actionForm配
b)标签由tomcat服务器解析成html,浏览器负责将标签
和actionForm配对
c)tomcat服务器负责全部工作
d)自定义taglib标签由tomcat解析,jstl标签由客户端浏
览器解析
3.Junit包中testCa类中的个test方法按何种顺序执行?A
台风位置
a)按方法定义的先后顺序
b)方法名字母顺序
c)无一定顺序
d)用户可以指定执行顺序
4.It is desirable that a certain method within a certain class can
情侣英文
only be accesd by class that are defined within the same epackage as th class of the method .How can such restrictions be enforced? (d)
a)Mark the method with the keyword public
b)Mark the method with the keyword protected
c)Mark the method with the keyword private
heland)Mark the method with the keyword package
5.Consider the following code sample
Class tree{}
象人
Class Pine extends Tree{}
Class Oak extends Tree{}
{ public static void main (String [] args)
{ Tree tree = new Pine();
If( tree instanceof pine)
System.out.println( “Pine”);
If( tree instanceof Tree)
System.out.println( “Tree”);
If( tree instanceof Oak)
System.out.println( “Oak” );
el System.out.println( “Oops”);
}
}
Select all choices that will be printed: ---- B
a)Pine
b)Tree
c)Forest
d)Oops
e)(nothing printed)
6.Which two can be ud to create a new Thread?(Choo Two)鲜花怎么养时间比较久
a d
a)/doc/9a11515570.html,ng.Thread and override the run method.
b)/doc/9a11515570.html,ng.Runnable and override the start
method.
c)/doc/9a11515570.html,ng.Thread and implement the run
method.
d)/doc/9a11515570.html,ng.Runnable and implement the run
摩羯男和摩羯女
method.
e)/doc/9a11515570.html,ng.Thread and implement the start
水浒传中method.
7.Which method below can change a String object,s? d
a)equals(s)
b)substring(s)
c)concat(s)
d)toUpperCa(s)
e)none of the above will change s
二:阅读
The java programming language provides three kinds of throwables :checked exceptions, runtime exceptions, and errors. There is some confusion among proguammers as to when it is appropriate to u each kind of throwable .While the decision is not always clear-cut ,there are some general rules that provide strong guidance.
The cardinal rule in deciding whether to u a checked or an unckecked Exception is this :u checked Exceptions for conditions from which the caller can reasonably be expected to recover . By throwing a checked exception , you force the caller to handle the exception in catch or to propagate it outward . Each checked exception that a method is declared to throw is therefore a potent indication to the API ur that associated condition is a possible outcome of invoking the method.
By confronting the API ur with a checked exception ,the API designer prents a mandate to recover from the condition . The ur can disregard the mandate by catching the exception and ignoring it ,but this is usually a bad ider(item 65).
There are two kinds of unchecked throwables :runtime
exceptions and errors.
They are identical in their behavior : both are throwables that needn’t ,and generally shouldn’t ,be caught. If a program throws an ucheched exception or an error, it is generally the ca that recovery is impossible and continued execution would do more than good . If a program does not catch such a throwable , it will cau the current thread to halt with an appropriate error message.
问:
1.文章建议在何种情况下抛出Checked Exception?为什
师德师风反思
么?
2.你认为errors为何定义为unchecked throwables 类型?
三:自由回答:
列出对你影响最大,最值得阅读的编程技术书籍。

本文发布于:2023-07-23 03:56:55,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1112046.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:标签   解析   顺序   对象   字节   情况   内容   值得
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图