资源描述
东南融通J2EE面试试题
网龙笔试题:
1、实现链表的创立,删除和逆序等。
#include<iostream>
#include<assert.h>
using namespace std;
typedef struct stu
{
int data;
struct stu *next;
}node, list;
node* creatlist(int n)
{
node *h, *p, *s;
h = new node;
h->next = NULL;
p = h;
cout << “please input 〞 << n << 〞 numbers.〞;
for(int i = 0; i < n; i++)
{
s= new node;
cin >> s->data;
s->next = NULL;
p->next = s;
p = s;
}
return h;
}
void deletelist (node *s, int a)
{
node *p;
while(s->data != a)
{
p = s;
s = s->next;
}
if(s == NULL)
{
cout << “no a〞;
}
else
{
p->next = s->next;
delete s;
}
}
void display(node *h)
{
h = h->next;
while(h != NULL)
{
cout << h->data << ends;
h = h->next;
}
cout << endl;
}
node* reverse(node* h)
{
node *p, *q, *s;
p = h->next;
q = p->next;
while(q->next != NULL)
{
s = q->next;
q->next = p;
p = q;
q = s;
}
q->next = p;
h->next->next = NULL;
h->next = q;
return h;
}
int main()
{
int n;
node *h;
cout << “please input the number:〞;
cin >> n;
h= creatlist(n);
display(h);
cout << “delete ?〞;
cin >> n;
deletelist(h, n);
display(h);
h = reverse(h);
display(h);
return 0;
}
2、字符串逆序
输入文件是in.txt,内容例如如下:
hello, everyone.
my name is shen, he.
ni, ne?
那么倒序之后为:
everyone. hello,
he. shen, is name my
ne? ni,
源程序,自己实现的,算法是别人的。呵呵
#include<iostream>
#include<fstream>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
char *fName;
string::size_type b,e;
char ch;
string line;
vector<string> svec;
inFile.open(〞in.txt〞);
while(getline(inFile, line)) //先获取每一行字符,并存入容器中
{
svec.push_back(line);
}
inFile.close();
outFile.open(〞out.txt〞);
vector<string>::iterator iter = svec.begin();
while(iter != svec.end())
{
b = 0;
e = (*iter).size() – 1;
while( b < e) //将该行字符整体翻转
{
ch = (*iter)[b];
(*iter)[b] = (*iter)[e];
(*iter)[e] = ch;
b++;
e–;
}
b = 0;
e = 0;
string::size_type i = 0;
while( (*iter)[i] )
{
if((*iter)[i] != ‘ ‘) //找到一行的一个单词
{
b = i;
while((*iter)[i] != ‘ ‘ && (*iter)[i])
i++;
i–;
e = i;
}
while (b < e) //将这个单词翻转
{
ch = (*iter)[b];
(*iter)[b] = (*iter)[e];
(*iter)[e] = ch;
b++;
e–;
}
i++;
}
outFile << *iter << endl;
++iter;
}
return 0;
}
新大陆面试题:
(一)技术面试
struts如何表现MVC模式的?
Tomcat的部署?
UML有哪些图?
Struts框架的好处(优点)?
答:1、是开源软件,使开发者能更深入的了解其内部实现机制。
2、Taglib是Struts的标记库,灵活动用,能大大提高开发效率;通过一个配置文件,即可把握整个系统各局部之间的联系,这对于后期的维护有着莫大的好处。尤其是当另一批开发者接手这个工程时,这种优势表达得更加明显。
4. 提供Exception处理机制 .
5. 数据库链接池管理
6. 支持I18N
Struts+Hibernate框架的优势?
答:这两种架构相结合很好地解决了系统的开发效率低、不易于维护、低耦合及可移植性差等问题.
介绍一下AJAX?
答:AJAX(Asynchronous JavaScript and XML)被赢得广泛的认可,其原因是由于它缩短了Web应用程序和桌面应用程序之间的差距,并在其中充分结合可实现的技术和丰富的用户体验。
AJAX是多种技术的综合,它打破了页面刷新的范式,使您的用户快速方便的与 Web 应用程序交互。
CVS配置与使用?
POJO是什么?
答:简单的Java对象〔Plain Old Java Objects〕,POJO对象有时也被称为Data对象,大量应用于表现现实中的对象。
概要设计与详细设计等文档的主要包含内容?
(二)笔试内容
SQL方面:SQL全称.查询语句. Group by .having.update set
JSP方面:静态include与动态include
第一局部: Java 根底知识
1.
What will happen when you attempt to compile and run the following code?
public class Test {
static {
int x = 5;
}
static int x, y;
public static void main(String args[]) {
x--;
myMethod();
System.out.println(x + y + ++x);
}
public static void myMethod() {
y = x++ + ++x;
}
}
A. compiletime error
B. prints: 1
C. prints: 2
D. prints: 3
E. prints: 7
F. prints: 8
2.
Which of the following collection classes from java.util package are Thread safe? (Choose two)
A. Vector
B. ArrayList
C. HashMap
D. Hashtable
3.
Which of the following types is primitive java type?(Choose two)
A String
B int
C char
D Short
4.
Which two demonstrate a "has a" relationship? (Choose two)
A. public interface Person { }
public class Employee extends Person{ }
B. public interface Shape { }
public interface Rectandle extends Shape { }
C. public interface Colorable { }
public class Shape implements Colorable { }
D. public class Species{ }
public class Animal{private Species species;}
E. interface Component{ }
class Container implements Component{
private Component[] children;
}
5. What is the result when you compile and run the following code?
public class ThrowsDemo {
static void throwMethod() {
System.out.println("Inside throwMethod.");
throw new IllegalAccessException("demo");
}
public static void main(String args[]) {
try {
throwMethod();
} catch (IllegalAccessException e) {
System.out.println("Caught " + e);
}
}
}
A. compile error
B. runtime error
C. compile successfully, nothing is printed.
D. inside throwMethod followed by caught: java.lang.IllegalAccessException: demo
6.
Which two statements are true for the class java.util.TreeSet? (Choose two)
A. The elements in the collection are ordered.
B. The collection is guaranteed to be immutable.
C. The elements in the collection are guaranteed to be unique.
D. The elements in the collection are accessed using a unique key.
E. The elements in the collection are guaranteed to be synchronized
点评:TreeSet类实现了Set接口。Set的特点是其中的元素惟一,选项C正确。由于采用了树形存储方式,将元素有序地组织起来,所以选项A也正确。
7. What will be printed when you execute the following code?
class X {
Y b = new Y();
X() {
System.out.print("X");
}
}
class Y {
Y() {
System.out.print("Y");
}
}
public class Z extends X {
Y y = new Y();
Z() {
System.out.print("Z");
}
public static void main(String[] args) {
new Z();
}
}
A. Z
B. YZ
C. XYZ
D. YXYZ
8. which two declaretions prevent the overriding of a method?
A. final void methoda(){}
B. void final methoda(){}
C. static void methoda(){}
D. static final void methoda(){}
E. final abstract void methoda(){}
9. You want a class to have access to members of another class in the same package which is the most restrictive access modifier that will accomplish this objective?
A. public
B. private
C. protected
D. transient
E. No access modifier is required
10. which two interfaces provide the capability to store objects using a key-value pair?
A. java.util.Map
B. java.util.Set
C. java.util.List
D. java.util.SortedSet
E. java.util.SortedMap
F. java.util.Collection
11.
1) class Super{
2) public float getNum(){return ;}
3) }
4)
5) public class Sub extends Super{
6)
7) }
which method, placed at line 6, will cause a compiler error?
A. public float getNum(){return ;}
B. public void getNum(){}
C. public void getNum(double d){}
D. public double getNum(float d){return 4.0d;}
注意这道题主要考的是方法的overload和override。对于overload,只有参数列表不同,才做为标准,而返回值和访问控制关键字不能做为标准,所以B错在方法名相同,但只有返回值不同,这是错的。C和D是正确的overload。对于override,那么访问控制关键字只能更加公有化,异常只能是超类方法抛出的异常的子类,也可以不抛出。返回类型,参数列表必须精确匹配。所以A是正确的override。
12.
which gets the name of the parent directory of file "file.txt"?
A. String name=File.getParentName("file.txt");
B. String name=(new File("file.txt")).getParent();
C.Stringname=(new File("file.txt")).getParentName();
D.Stringname=(new File("file.txt")).getParentFile();
E.Diretorydir=(new File("file.txt")).getParentDir();
String name=dir.getName();
13.
What happens when you try to compile and run the following application? Choose all correct options.
1. public class Z {
2. public static void main(String[] args) {
3. new Z();
4. }
5.
6. Z() {
7. Z alias1 = this;
8. Z alias2 = this;
9. synchronized(alias1) {
10. try {
11. alias2.wait();
12. System.out.println(“DONE WAITING〞);
13. }
14. catch (InterruptedException e) {
15. System.out.println(“INTERR UPTED〞);
16. }
17. catch (Exception e) {
18. System.out.println(“OTHER EXCEPTION〞);
19. }
20. finally {
21. System.out.println (“FINALLY〞);
22. }
23. }
24. System.out.println(“ALL DONE〞);
25. }
26. }
A. The application compiles but doesn't print anything.
B. The application compiles and print “DONE WAITING〞
C. The application compiles and print “FINALLY〞
D. The application compiles and print “ALL DONE〞
E. The application compiles and print “INTERRUPTED〞
点评:在Java中,每一个对象都有锁。任何时候,该锁都至多由一个线程控制。由于alias1与alias2指向同一对象Z,在执行第11行前,线程拥有对象Z的锁。在执行完第11行以后,该线程释放了对象Z的锁,进入等待池。但此后没有线程调用对象Z的notify()和notifyAll()方法,所以该进程一直处于等待状态,没有输出。
14. What results from attempting to compile and run the following code?
public class Ternary{
public static void main(String args[]){
int a = 5;
System.out.println("Value is - " + ((a < 5) ? 9.9 : 9));
}
}
A. print:Value is -9
B. print:Value is -5
C. Compilation error
D. None of these
第二局部: JSP & Servlet
15. Which is the correct code segment?
A <%@ include file="included.jsp" %>
B <%@ include page ="included.jsp" %>
C <jsp:include page="included.jsp" />
D <jsp:include file ="included.jsp" />
16. which code segment make the servlet engine use the singleThreadModel interface ?
A. <%@ page isThreadSafe="false"%>
B. <%@ page isThreadSafe="true"%>
C. <%@ page setThreadSafe="false"%>
D. <%@ page setThreadSafe ="true"%>
17. 在servlet和EJB之间传递的valueObject对象类要继承什么接口
Serializable
18. 我们在web应用开发过程中经常遇到输出某种编码的字符,如iso-8859-1等,如何用getBytes输出一个某种编码的字符串?
(1)请写出使用getBytes方法进行编码转换的代码〔一句例如即可〕
strvalue.getBytes("ISO8859_1")
(2)在处理servlet的中文问题时,除上面的方法外,是否有别的常用方法
request.setCharacterEncoding("GB2312");,
19. EJB分为几种哪三种EJB,其中的两种又可各细分成另外两种,写出7种分类
Session Bean,Entity Bean,MessageDriven Bean
Session bean: Stateful session bean, Stateless session bean
Entity Bean: Bean-Managed Persistence Container-Managed Persistence
20. 简述forward 和redirect的区别
第三局部: 系统设计
21. UML中,通常意义上的静态图,交互图 分别包含以下哪些图(多项选择)
A 用例图
B 类图
C 对象图
D 行为图
E 顺序图
F 合作图
G 实现图
H 包图
静态图〔 ABC 〕
交互图〔 DEFG 〕
22. 写一种单体类(Singleton)实现实例
23.写一种Factory的实现实例。
保密 12/12
展开阅读全文