精品一区二区中文在线,无遮挡h肉动漫在线观看,国产99视频精品免视看9,成全免费高清大全

時間:2024-07-28 17:11:54 資料大全 我要投稿
  • 相關推薦

富士康企業集團招聘Java題目筆試題目

  編程題:

富士康企業集團招聘Java題目筆試題目

  1、繼承時候類的執行順序問題,一般都是選擇題,問你將會打印出什么?

  答:父類:

  package test;

  public class FatherClass

  {

  public FatherClass()

  {

  System.out.println(“FatherClass Create”);

  }

  }

  子類:

  package test;

  import test.FatherClass;

  public class ChildClass extends FatherClass

  {

  public ChildClass()

  {

  System.out.println(“ChildClass Create”);

  }

  public static void main(String[] args)

  {

  FatherClass fc = new FatherClass();

  ChildClass cc = new ChildClass();

  }

  }

  輸出結果:

  C:>java test.ChildClass

  FatherClass Create

  FatherClass Create

  ChildClass Create

  2、內部類的實現方式?

  答:示例代碼如下:

  package test;

  public class OuterClass

  {

  private class InterClass

  {

  public InterClass()

  {

  System.out.println(“InterClass Create”);

  }

  }

  public OuterClass()

  {

  InterClass ic = new InterClass();

  System.out.println(“OuterClass Create”);

  }

  public static void main(String[] args)

  {

  OuterClass oc = new OuterClass();

  }

  }

  輸出結果:

  C:>java test/OuterClass

  InterClass Create

  OuterClass Create

  再一個例題:

  public class OuterClass {

  private double d1 = 1.0;

  //insert code here

  }

  You need to insert an inner class declaration at line 3. Which two inner class declarations are

  valid?(Choose two.)

  A. class InnerOne{

  public static double methoda() {return d1;}

  }

  B. public class InnerOne{

  static double methoda() {return d1;}

  }

  C. private class InnerOne{

  double methoda() {return d1;}

  }

  D. static class InnerOne{

  protected double methoda() {return d1;}

  }

  E. abstract class InnerOne{

  public abstract double methoda();

  }

  說明如下:

  一.靜態內部類可以有靜態成員,而非靜態內部類則不能有靜態成員,

富士康企業集團招聘Java題目筆試題目

資料共享平臺

富士康企業集團招聘Java題目筆試題目》(http://salifelink.com)。

  故 A、B 錯

  二.靜態內部類的非靜態成員可以訪問外部類的靜態變量,而不可訪問外部類的非靜態變量;return d1 出錯。

  故 D 錯

  三.非靜態內部類的非靜態成員可以訪問外部類的非靜態變量。

  故 C 正確

  四.答案為C、E

  3、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

【】相關文章:

小學感恩節活動方案06-20

公司離職證明范文5篇07-11

職場人士勵志故事10-21

河南全國教師信息采集08-30

搞笑的新婚祝福語大全10-26

工作勵志格言精選08-22

服裝市場調查報告10-18

三年級蜜蜂教學反思10-25

解決問題教學反思10-29

幼兒園讀書的倡議書06-23