急救:明天去华为面试,请问谁有那边的面试题目呀?麻烦贴出来看一下。 moke33 刚笔试三关通过。看看《数据结构和算法》。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 10、Java中异常处理机制,事件机制? 11、JAVA中的多形与继承? 希望大家补上,谢谢 12、抽象类与接口? 答:抽象类与接口都用于抽象,但是抽象类(JAVA中)可以有自己的部分实现,而接口则完全是一个标识(同时有多重继承的功能)。 13、Java 的通信编程,编程题(或问答),用JAVA SOCKET编程,读服务器几个字符,再写入本地显示? 答:Server端程序: package test; import java.net.*; import java.io.*; public class Server { private ServerSocket ss; private Socket socket; private BufferedReader in; private PrintWriter out; public Server() { try { ss=new ServerSocket(10000); while(true) { socket = ss.accept(); String RemoteIP = socket.getInetAddress().getHostAddress(); String RemotePort = ":"+socket.getLocalPort(); System.out.println("A client come in!IP:"+RemoteIP+RemotePort); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String line = in.readLine(); System.out.println("Cleint send is :" + line); out = new PrintWriter(socket.getOutputStream(),true); out.println("Your Message Received!"); out.close(); in.close(); socket.close(); } }catch (IOException e) { out.println("wrong"); } } public static void main(String[] args) { new Server(); } }; Client端程序: package test; import java.io.*; import java.net.*; public class Client { Socket socket; BufferedReader in; PrintWriter out; public Client() { try { System.out.println("Try to Connect to 127.0.0.1:10000"); socket = new Socket("127.0.0.1",10000); System.out.println("The Server Connected!"); System.out.println("Please enter some Character:"); BufferedReader line = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(socket.getOutputStream(),true); out.println(line.readLine()); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); System.out.println(in.readLine()); out.close(); in.close(); socket.close(); }catch(IOException e) { out.println("Wrong"); } } public static void main(String[] args) { new Client(); } }; 14、用JAVA实现一种排序,JAVA类实现序列化的方法(二种)? 如在COLLECTION框架中,实现比较要实现什么样的接口? 答:用插入法进行排序代码如下 package test; import java.util.*; class InsertSort { ArrayList al; public InsertSort(int num,int mod) { al = new ArrayList(num); Random rand = new Random(); System.out.println("The ArrayList Sort Before:"); for (int i=0;i<num ;i++ ) { al.add(new Integer(Math.abs(rand.nextInt()) % mod + 1)); System.out.println("al["+i+"]="+al.get(i)); } } public void SortIt() { Integer tempInt; int MaxSize=1; for(int i=1;i<al.size();i++) { tempInt = (Integer)al.remove(i); if(tempInt.intValue()>=((Integer)al.get(MaxSize-1)).intValue()) { al.add(MaxSize,tempInt); MaxSize++; System.out.println(al.toString()); } else { for (int j=0;j<MaxSize ;j++ ) { if (((Integer)al.get(j)).intValue()>=tempInt.intValue()) { al.add(j,tempInt); MaxSize++; System.out.println(al.toString()); break; } } } } System.out.println("The ArrayList Sort After:"); for(int i=0;i<al.size();i++) { System.out.println("al["+i+"]="+al.get(i)); } } public static void main(String[] args) { InsertSort is = new InsertSort(10,100); is.SortIt(); } } JAVA类实现序例化的方法是实现java.io.Serializable接口 Collection框架中实现比较要实现Comparable 接口和 Comparator 接口 配置多个数据源 带工资管理的HR源码有没 谁能写一个简单的线程死锁出来 导入节点xml 出现中文乱码问题,在后台控制台打印能正常显示 一个有关Struts如何接收并处理表单中File类型的问题 ejb部署出问题了。 请教,tomcat 4 搭配soap 2 的安装问题 急,在线等待。。。 如何运行有计算功能的一串String? 哪位解释一下jboss的目录结构啊 weblogic 与 jbuilder8 与jsp 150 分(不够另开) 吐血求救 java excel api 的.jar JDBC连接SQL2000数据库问题?????????????
希望大家补上,谢谢 12、抽象类与接口?
答:抽象类与接口都用于抽象,但是抽象类(JAVA中)可以有自己的部分实现,而接口则完全是一个标识(同时有多重继承的功能)。 13、Java 的通信编程,编程题(或问答),用JAVA SOCKET编程,读服务器几个字符,再写入本地显示?
答:Server端程序:
package test;
import java.net.*;
import java.io.*; public class Server
{
private ServerSocket ss;
private Socket socket;
private BufferedReader in;
private PrintWriter out;
public Server()
{
try
{
ss=new ServerSocket(10000);
while(true)
{
socket = ss.accept();
String RemoteIP = socket.getInetAddress().getHostAddress();
String RemotePort = ":"+socket.getLocalPort();
System.out.println("A client come in!IP:"+RemoteIP+RemotePort);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String line = in.readLine();
System.out.println("Cleint send is :" + line);
out = new PrintWriter(socket.getOutputStream(),true);
out.println("Your Message Received!");
out.close();
in.close();
socket.close();
}
}catch (IOException e)
{
out.println("wrong");
}
}
public static void main(String[] args)
{
new Server();
}
};
Client端程序:
package test;
import java.io.*;
import java.net.*; public class Client
{
Socket socket;
BufferedReader in;
PrintWriter out;
public Client()
{
try
{
System.out.println("Try to Connect to 127.0.0.1:10000");
socket = new Socket("127.0.0.1",10000);
System.out.println("The Server Connected!");
System.out.println("Please enter some Character:");
BufferedReader line = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(socket.getOutputStream(),true);
out.println(line.readLine());
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
System.out.println(in.readLine());
out.close();
in.close();
socket.close();
}catch(IOException e)
{
out.println("Wrong");
}
}
public static void main(String[] args)
{
new Client();
}
}; 14、用JAVA实现一种排序,JAVA类实现序列化的方法(二种)? 如在COLLECTION框架中,实现比较要实现什么样的接口?
答:用插入法进行排序代码如下
package test;
import java.util.*;
class InsertSort
{
ArrayList al;
public InsertSort(int num,int mod)
{
al = new ArrayList(num);
Random rand = new Random();
System.out.println("The ArrayList Sort Before:");
for (int i=0;i<num ;i++ )
{
al.add(new Integer(Math.abs(rand.nextInt()) % mod + 1));
System.out.println("al["+i+"]="+al.get(i));
}
}
public void SortIt()
{
Integer tempInt;
int MaxSize=1;
for(int i=1;i<al.size();i++)
{
tempInt = (Integer)al.remove(i);
if(tempInt.intValue()>=((Integer)al.get(MaxSize-1)).intValue())
{
al.add(MaxSize,tempInt);
MaxSize++;
System.out.println(al.toString());
} else {
for (int j=0;j<MaxSize ;j++ )
{
if (((Integer)al.get(j)).intValue()>=tempInt.intValue())
{
al.add(j,tempInt);
MaxSize++;
System.out.println(al.toString());
break;
}
}
}
}
System.out.println("The ArrayList Sort After:");
for(int i=0;i<al.size();i++)
{
System.out.println("al["+i+"]="+al.get(i));
}
}
public static void main(String[] args)
{
InsertSort is = new InsertSort(10,100);
is.SortIt();
}
}
JAVA类实现序例化的方法是实现java.io.Serializable接口
Collection框架中实现比较要实现Comparable 接口和 Comparator 接口