免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
應(yīng)聘Java筆試時可能出現(xiàn)問題及其答案 (二)

應(yīng)聘Java筆試時可能出現(xiàn)問題及其答案 (二)

作者:itzealot 來源:賽迪博客 http://www.csai.cn 2006年10月8日

  9、介紹JAVA中的Collection FrameWork(包括如何寫自己的數(shù)據(jù)結(jié)構(gòu))?

  答:Collection FrameWork如下:
  Collection
  ├List
  │├LinkedList
  │├ArrayList
  │└Vector
  │ └Stack
  └Set
  Map
  ├Hashtable
  ├HashMap
  └WeakHashMap
  Collection是最基本的集合接口,一個Collection代表一組Object,即Collection的元素(Elements)
  Map提供key到value的映射

  10、Java中異常處理機(jī)制,事件機(jī)制?

  11、JAVA中的多形與繼承?

  12、抽象類與接口?

  答:抽象類與接口都用于抽象,但是抽象類(JAVA中)可以有自己的部分實現(xiàn),而接口則完全是一個標(biāo)識(同時有多重繼承的功能)。

  13、Java 的通信編程,編程題(或問答),用JAVA SOCKET編程,讀服務(wù)器幾個字符,再寫入本地顯示?

  答: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實現(xiàn)一種排序,JAVA類實現(xiàn)序列化的方法(二種)? 如在COLLECTION框架中,實現(xiàn)比較要實現(xiàn)什么樣的接口?

  答:用插入法進(jìn)行排序代碼如下
  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) 
    {
     al.add(new Integer(Math.abs(rand.nextInt()) % mod + 1));
     System.out.println("al["+i+"]="+al.get(i));
    }
   }
   public void SortIt()
   {
    nteger tempInt;
    int MaxSize=1;
    for(int i=1;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)    
      {
       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) 
    {
     System.out.println("al["+i+"]="+al.get(i));
    }
   }
   public static void main(String[] args)
   {
    InsertSort is = new InsertSort(10,100);
    is.SortIt();
   }
  }

  JAVA類實現(xiàn)序例化的方法是實現(xiàn)java.io.Serializable接口
  Collection框架中實現(xiàn)比較要實現(xiàn)Comparable 接口和 Comparator 接口

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
java socket 實現(xiàn)服務(wù)端與客戶端
JAVA printWriter中write()和println()區(qū)別
簡單聊天程序java socket
面向套接字(Socket)Java編程(單線程+多線程)
代碼量統(tǒng)計,可以統(tǒng)計去掉注釋和空行的代碼量
JAVA網(wǎng)絡(luò)編程,基本概念與開發(fā)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服