首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

下海张江笔试题

2012-09-19 
上海张江笔试题1.run result:falsefalsetruetrueresult:121218result is:126result is:66result is:128res

上海张江笔试题

1.

run result:
false
false
true
true
result:12
12
18
result is:126
result is:66
result is:128
result is:-128
result is:132
result is:-124


f==d incompatible operand types Float and Double
System.out.println("result is:" + 6 +++ 6); invalid argument to operation ++/--
2.
抽象类不能是final
抽象方法也不能是final,在接口中报显示:Illegal modifier for the interface method getMethod; only public & abstract are permitted
在抽象类中显示:The abstract method getMethod in type AbstractTest can only set a visibility modifier, one of public or protected
抽象方法不可以是private
抽象方法不可以是static,在抽象类中显示:The abstract method getMethod in type AbstractTest can only set a visibility modifier, one of public or protected.在接口中显示Remove invalid parameters
抽象方法只能放在抽象类中是错误的,还可以放在接口中
抽象方法在接口和类中都可以抛出异常,但子类或实现类要对异常进行处理
public abstract class AbstractTest {
public abstract int getMethod()throws Exception;
public abstract int getInt();
}
public interface InterfaceTest {
public int getMethod()throws Exception;
}
map and hashmap difference
map是接口,不能用new出对象
hashmap是继承map接口的实现类,可以new出对象,HashMap实现了接口Map,就是说HashMap实现了Map所有的方法

具体介绍
Map提供key到value的映射。一个Map中不能包含相同的key,每个key只能映射一个 value。HashMap是实现了Map接口的具体类.HashMap是采用key的hashCode分组而实现的一种Map。
HashMap的特点是查找速度快,缺点是不能保证迭代的顺序
3.
look at the following code, one variable "x" given, write a code segment;if the result is that x equals an even number,javaScript code will hide following HTML table
<div id="testVisiblitity">
<table border="1">
<tr>
<td>row 1,cell 1</td>
<td>row 2,cell 2</td>
</tr>
</table>
</div>

answer:
<script src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
if(x % 2 == 1){
$("#testVisiblitity").hide();
}else{
$("#testVisiblitity").show();
}
});
</script>

?

4.look at the following snippet,write code to perform the following 3 validations

make sure these two fields are required ,otherwise alert user message and stop

make sure these two fields are date format(such as'mm/dd/yyyy"), otherwise alert user message and stop

make sure "to_date" is larger than "from_date"

<html>
<form method="POST" name="form1" action="action1">
From Date <input type="text" name="from_date" size="10"/></br>
To Date <input type="text" name="to_date" size="10"/></br>
</form>
</html>

?

the second dont know how to validate, others validate as follow, any issue, please inform me

<script type="text/javascript src="jquery-1.7.2.min.js"/>
<script type="text/javascript">
$(document).ready(function(){
var fromDateParam = document.getElementById("from_date");
var fromDate = $.trim(fromDateParam.value);
var toDateParam = document.getElementById("to_date");
var toDate = $.trim(toDateParam.value);
if(fromDate==null||fromDate==''){
alert("input from date is null");
return;
}
if(toDate==null||toDate==''){
alert("input to date is null");
return;
}
Pattern pattern = new Pattern();
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("MM/dd/yyyy");
Date fromDateFormat = dateFormat.parse(form.get("from_date"));
Date toDateFormat = dateFormat.parse(form.get("to_date"));
Boolean isNotPastDate = toDateFormat.compareTo(fromDateFormat)>=0;
if(!isNotPastDate){
alert("to date must be larger than from date, please full it again");
return;
}
});
</script>

?

5.InputStream in = new InputStream(); wrong, because Cannot instantiate the type InputStream

6.float a1 =1.0f;
double a2=1.0;

float a3=1.0;编译出错Type mismatch: cannot convert from double to float

Float a4= new Float(1.0);

热点排行