24.用break; return 方法。
23. class Cat{}
class Dog extern Cat{}
Dog adog = new Dog();
if (adod instanceof Cat) {}
if (Cat.isinstance(adog)) {}
22.ArrayList 和vector extern AbstractList. ArrayList 为固定容量,不能含有基本型别,可快速随即访问,为non-synchronized。Vector可自行扩张容量,为-synchronized。
21.List list = new ArrayList();
for(int i = 0; i <10; i++)
{ list.add(new Integer(i));}
Iterator e= list.iterator();
while(e.hasNest())
e.next.print();
20.List 以特定次序来持有元素,可有重复元素。Set 无法拥有重复元素,内部排序。Map 保存key-value值,value可多值。
19.Clone 有缺省行为,super.clone();他负责产生正确大小的空间,并逐位复制。
18.不可以,如果其中包含对象的method();不能保证对象初始化.
16.static i = 10; //常量
class A a; a.i =10;//可变
15.InputStream \ OutputStream;
14.overloading 用参数来辨别调用同名的函数,在多态中用到;overridding 重新更改其实现。在继承中用到。
13.后期绑定.
12.会。如:int i,i2; return (i-i2); //when i为足够大的正数,i2为足够大的负数。结果会造成溢位,导致错误。
11.访问reference 形成的网络,找出存活的对象。完成之后,释放不复存活的对象。
可以。System.gc();
7.可以,
6.可以。必须只有一个类名与文件名相同。
5.System.gc();
23. class Cat{}
class Dog extern Cat{}
Dog adog = new Dog();
if (adod instanceof Cat) {}
if (Cat.isinstance(adog)) {}
22.ArrayList 和vector extern AbstractList. ArrayList 为固定容量,不能含有基本型别,可快速随即访问,为non-synchronized。Vector可自行扩张容量,为-synchronized。
21.List list = new ArrayList();
for(int i = 0; i <10; i++)
{ list.add(new Integer(i));}
Iterator e= list.iterator();
while(e.hasNest())
e.next.print();
20.List 以特定次序来持有元素,可有重复元素。Set 无法拥有重复元素,内部排序。Map 保存key-value值,value可多值。
19.Clone 有缺省行为,super.clone();他负责产生正确大小的空间,并逐位复制。
18.不可以,如果其中包含对象的method();不能保证对象初始化.
16.static i = 10; //常量
class A a; a.i =10;//可变
15.InputStream \ OutputStream;
14.overloading 用参数来辨别调用同名的函数,在多态中用到;overridding 重新更改其实现。在继承中用到。
13.后期绑定.
12.会。如:int i,i2; return (i-i2); //when i为足够大的正数,i2为足够大的负数。结果会造成溢位,导致错误。
11.访问reference 形成的网络,找出存活的对象。完成之后,释放不复存活的对象。
可以。System.gc();
7.可以,
6.可以。必须只有一个类名与文件名相同。
5.System.gc();
解决方案 »
- 链接数据库
- struts2与spring整合后struts.xml的action中class通配符如何设置?
- 如何把时间写入数据库,时间格式是:年-月-日 时:分:秒
- 用xfire 开发web service 方法中的参数是集合类型怎么办?在线等
- QBC查询
- 请问高手一个页面中能否创建两次CONNECTION对象
- 请这里的高手能介绍能用IDEA来开发Struts,hibernate,JSF,Sping,WebWork等框架的开发方面的资料.有没有这方面的plug-in等等.谢谢!up有分.
- 我想用LOG4J往数据库中写数据,但是有2个参数,怎么办?
- 200分寻求《Java Development with Ant》
- 急:有关cmp的问题(再线等待)?
- 求助啊!!请高手帮忙看下 Weblogic 的错误信息?郁闷了很多天了,谢谢谢谢
- 怎样把JDBC查询出来的ResultSet 转为 Collection 啊?
• Variable: Begin with character set [‘a’ – ‘z’, ‘_’], variable can contain char set [‘a’ – ‘z’, ‘_’, ‘0’ – ‘9’]. Sensitive Case.
• Constant: Only contain the char set [‘0’ – ‘9’], and range is 0 to 2147483647.
• Assignment Expression:
o Assign constant to variable
For example:
A1 = 1;
o Assign variable to variable
For example:
A1 = 1;
A2 = 2;
A1 = A2;
o Assignment : ‘=’
o Assignment separator: ‘;’
• Error (the point ed by * is optional implementation)
o Number format error
For example:
A1 = 1a12;
o Variable format error
For example:
1A1 = 112;
o Assignment expression format error
For example:
A1 == 1a12;
A1 = A2 = 112;o * Assignment separator expected
For example:
A1 = 112
o *Variable expected
For example:
= 112;
o *Constant expected
For example:
A1 = ;
o Assign error
 No initial value
For example:
A1 = 1;
A3 = A2;
 Modify Constant
For example:
1 = A1;
Input:
A text file contains a set of assignment expressions.
For example:
A1 = 1;
A2 = 2;
A3 = 3;
A2 = A3;
A1 = 3;Output
List all the variables that have the same value and list with their value together.
For example:
After process the above expressions, you need output the result like this:
[A1, A2, A3] = 3;
Requirement:
• Design document (English only) is required. This document should write before you write any code.
• Code should be consistent with java code convention.
• Program can identify and handle all the errors in definition part.
Test point:
• Correctness
o Identify all error in expression
o Treat expressions correctly
o Output correct result• Reliability
o Processing can not be interrupted by incorrect input or other reason
o Heap will not overflow when big amount of expressions are processed• Performance
o Amount of the expressions can be treated in 1 second• Memory
o Memory occupied when 100000 correct expressions are treated
Constant: Only contain the char set [‘0’ – ‘9’], and range is 0 to 2147483647.
Assignment Expression:
Assign constant to variable
For example:A1 = 1;o Assign variable to variableFor example:A1 = 1;A2 = 2;A1 = A2;Assignment : ‘=’
Assignment separator: ‘;’
Error (the point ed by * is optional implementation)
Number format error
For example: A1 = 1a12;Variable format error
For example: 1A1 = 112;Assignment expression format error
For example: A1 == 1a12; A1 = A2 = 112; * Assignment separator expected
For example: A1 = 112*Variable expected
For example: = 112;*Constant expected
For example: A1 = ;Assign error
No initial value
For example: A1 = 1; A3 = A2;Modify Constant
For example: 1 = A1;Input: A text file contains a set of assignment expressions. For example: A1 = 1; A2 = 2; A3 = 3; A2 = A3; A1 = 3; Output
List all the variables that have the same value and list with their value together. For example: After process the above expressions, you need output the result like this: [A1, A2, A3] = 3; Requirement:Design document (English only) is required. This document should write before you write any code.
Code should be consistent with java code convention.
Program can identify and handle all the errors in definition part.
Test point:Correctness
Identify all error in expression
Treat expressions correctly
Output correct result
Reliability
Processing can not be interrupted by incorrect input or other reason
Heap will not overflow when big amount of expressions are processed
Performance
Amount of the expressions can be treated in 1 second
Memory
Memory occupied when 100000 correct expressions are treated.
import java.io.*;
import java.util.*;public class Logon implements Serializable
{ private Date date = new Date();
private String username;
private transient String password; Logon (String name, String pwd)
{
username = name;
password = pwd;
}
public String toString()
{
String pwd = (password == null) ? "(n/a)" : password;
return "logon info: \n " + "username: " + username + "\n date: " + date + "\n password: " + pwd;
} public static void main(String[] args) throws IOException, ClassNotFoundException
{
Logon a = new Logon("Morgan", "morgan83");
System.out.println( "logon a =\n" + a);
ObjectOutputStream o = new ObjectOutputStream(new FileOutputStream("Logon.out"));
o.writeObject(a);
o.close();
System.out.println("=========================================");
int seconds = 5;
long t = System.currentTimeMillis() + seconds * 1000;
while(System.currentTimeMillis() < t);
ObjectInputStream in = new ObjectInputStream( new FileInputStream("Logon.out"));
System.out.println( "Recovering object at " + new Date());
a = (Logon)in.readObject();
System.out.println("logon a =\n" + a); System.out.println(a.password);
}
}
A1=2;
2A=343;
A2=3;
A5=2
...
的赋值表达输入文件,要求你找出其中的错误,并且说明错误原因,最后将结果相同的输出
形式如下
[A1,A2...]=3
麻烦你再做一下.不胜感激!
高手也有低级错误的时候吗?
static final int i = 10;//拥有无法改变的存储空间。
/**
* Increases the capacity of this <tt>ArrayList</tt> instance, if
* necessary, to ensure that it can hold at least the number of elements
* specified by the minimum capacity argument.
*
* @param minCapacity the desired minimum capacity.
*/
public void ensureCapacity(int minCapacity) {
modCount++;
int oldCapacity = elementData.length;
if (minCapacity > oldCapacity) {
Object oldData[] = elementData;
int newCapacity = (oldCapacity * 3)/2 + 1;
if (newCapacity < minCapacity)
newCapacity = minCapacity;
elementData = new Object[newCapacity];
System.arraycopy(oldData, 0, elementData, 0, size);
}
}