单选题Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given:  import java.io.*;  class Food {Food() { System.out.print(”1”); } }  class Fruit extends Food implements Serializable {  Fruit() 

题目
单选题
Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given:  import java.io.*;  class Food {Food() { System.out.print(”1”); } }  class Fruit extends Food implements Serializable {  Fruit() { System.out.print(”2”); } }  public class Banana2 extends Fruit { int size = 42;  public static void main(String [] args) {  Banana2 b = new Banana2();  b.serializeBanana2(b); // assume correct serialization  b = b.deserializeBanana2(b); // assume correct  System.out.println(” restored “+ b.size + “ “); }  // more Banana2 methods  }  What is the result?()
A

 Compilation fails.

B

 1 restored 42

C

 12 restored 42

D

 121 restored 42

E

 1212 restored 42

F

 An exception is thrown at runtime.


相似考题
参考答案和解析
正确答案: C
解析: 暂无解析
更多“单选题Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given:  import java.io.*;  class Food {Food() { System.out.print(”1”); } }  class Fruit extends Food implements Serializable {  Fruit() ”相关问题
  • 第1题:

    Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo()method, which two statements are true?()

    A.The class implements java.lang.Comparable.

    B.The class implements java.util.Comparator.

    C.The interface used to implement sorting allows this class to define only one sort sequence.

    D.The interface used to implement sorting allows this class to define many different sort sequences.


    参考答案:A, C

  • 第2题:

    下列( )选项的java源文件代码片段是不正确的。

    A.package testpackage; publicClass Test{}

    B.import java.io.*; package testpackage: publicClass Test{}

    C.import java.io.*; Class Person{} publicClass Test{}

    D.import java.io.*; import java.awt.*; publicClass Test{}


    正确答案:B

  • 第3题:

    下列哪个选项的java源文件程序段是不正确的? ( )

    A.package testpackage; public class Test{ }

    B.import java.io.*; package testpackage; public class Test{ }

    C.import java.i.*; class Person{} public class Test{ }

    D.import java.io.*; import java.awt.*; public class Test { }


    正确答案:B

  • 第4题:

    Given a file GrizzlyBear.java:  1. package animals.mammals;  2.  3. public class GrizzlyBear extends Bear {  4. void hunt() {  5. Salmon s = findSalmon();  6. s.consume();  7. }  8. }  and another file, Salmon.java:  1. package animals.fish; 2.  3. public class Salmon extends Fish {  4. void consume() { /* do stuff */ }  5. }  Assume both classes are defined in the correct directories for theft packages, and that the Mammal class correctly defines the findSalmon() method. Which two changes allow this code to compile correctly?()

    • A、 add public to the start of line 4 in Salmon.java
    • B、 add public to the start of line 4 in GrizzlyBear.java
    • C、 add import animals.mammals.*; at line 2 in Salmon.java
    • D、 add import animals.fish.*; at line 2 in GrizzlyBear.java
    • E、 add import animals.fish.Salmon.*; at line 2 in GrizzlyBear.java
    • F、 add import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.java

    正确答案:A,D

  • 第5题:

    Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given:  import java.io.*;  class Food {Food() { System.out.print(”1”); } }  class Fruit extends Food implements Serializable {  Fruit() { System.out.print(”2”); } }  public class Banana2 extends Fruit { int size = 42;  public static void main(String [] args) {  Banana2 b = new Banana2();  b.serializeBanana2(b); // assume correct serialization  b = b.deserializeBanana2(b); // assume correct  System.out.println(” restored “+ b.size + “ “); }  // more Banana2 methods  }  What is the result?() 

    • A、 Compilation fails.
    • B、 1 restored 42
    • C、 12 restored 42
    • D、 121 restored 42
    • E、 1212 restored 42
    • F、 An exception is thrown at runtime.

    正确答案:D

  • 第6题:

    GivenafileGrizzlyBear.java: 1.package animals.mammals; 2. 3.public class GrizzlyBear extends Bear{ 4.voidhunt(){ 5.Salmons=findSalmon(); 6.s.consume(); 7.} 8.} and another file,Salmon.java: 1.packageanimals.fish; 2. 3.public class Salmon extends Fish{ 4.voidconsume(){/*dostuff*/} 5.} Assume both classes are defined in the correct directories for theft packages,and that the Mammal class correctly defines the findSalmon()method.Which two changes allow this code to compile correctly?()

    • A、add public to the start of line 4 in Salmon.java
    • B、add public to the start of line 4 in GrizzlyBear.java
    • C、add import animals.mammals.*;at line 2 in Salmon.java
    • D、add import animals.fish.*at line 2 in GrizzlyBear.java
    • E、add import animals.fish.Salmon.*;at line 2 in GrizzlyBear.java
    • F、add import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.java

    正确答案:A,D

  • 第7题:

    现有:  class Pet implements Serializable  {      Collar c= new Collar();      }  class Collar implements Serializable  {      collarPart cpl=new CollarPart ("handle");      CollarPart cp2=new CollarPart ("clip");      }     class CollarPart implements Serializable()  如果Pet实例被序列化,则多少对象将被序列化?()    

    • A、0
    • B、1
    • C、2
    • D、3
    • E、4
    • F、5

    正确答案:E

  • 第8题:

    import java.io.*;  public class Forest implements Serializable {  private Tree tree = new Tree();  public static void main(String [] args) {  Forest f= new Forest();  try {  FileOutputStream fs = new FileOutputStream(”Forest.ser”);  ObjectOutputStream os = new ObjectOutputStream(fs);  os.writeObject(f); os.close();  } catch (Exception ex) { ex.printStackTrace(); }  }  }  class Tree { }  What is the result?() 

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 An instance of Forest is serialized.
    • D、 A instance of Forest and an instance of Tree are both serialized.

    正确答案:B

  • 第9题:

    单选题
    141- Conversation 1 What does the man want?    
    A

    A free ticket to the lecture.

    B

    Information about the lunch meeting.

    C

    Favorite food and fruit.


    正确答案: B
    解析: 录音中男士的第一句话是I believe you have a lunch meeting this coming Wednesday. Could you give me some information about it?可见他想要知道的是关于会议的信息。

  • 第10题:

    单选题
    import java.io.*;  public class Forest implements Serializable {  private Tree tree = new Tree();  public static void main(String [] args) {  Forest f= new Forest();  try {  FileOutputStream fs = new FileOutputStream(”Forest.ser”);  ObjectOutputStream os = new ObjectOutputStream(fs);  os.writeObject(f); os.close();  } catch (Exception ex) { ex.printStackTrace(); }  }  }  class Tree { }  What is the result?()
    A

     Compilation fails.

    B

     An exception is thrown at runtime.

    C

     An instance of Forest is serialized.

    D

     A instance of Forest and an instance of Tree are both serialized.


    正确答案: B
    解析: 暂无解析

  • 第11题:

    单选题
    Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java serialization and given:  import java.io.*;  class Food implemertts Serializable {int good = 3;}  class Fruit externds Food {int juice = 5;}  public class Banana extends Fruit {  int yellow = 4;  public static void main(String [] args) {  Banana b = new Banana(); Banana b2 = new Banana();  b.serializeBanana(b); // assume correct serialization  b2 = b.deserializeBanana(); // assume correct  System.out.println(”restore “+b2.yellow+ b2.juice+b2.good);  }  // more Banana methods go here  }  What is the result?()
    A

     restore 400

    B

     restore 403

    C

     restore 453

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


    正确答案: B
    解析: 暂无解析

  • 第12题:

    单选题
    现有:  class Pet implements Serializable  {      Collar c= new Collar();      }  class Collar implements Serializable  {      collarPart cpl=new CollarPart ("handle");      CollarPart cp2=new CollarPart ("clip");      }     class CollarPart implements Serializable()  如果Pet实例被序列化,则多少对象将被序列化?()
    A

    0

    B

    1

    C

    2

    D

    3

    E

    4

    F

    5


    正确答案: C
    解析: 暂无解析

  • 第13题:

    下列哪个选项的java源文件代码片段是不正确的?

    A.package testpackage; public class Test{ }

    B.import java. io. *; package testpaekage; public class Test { }

    C.import java.io.*; class Person { } public class Test { }

    D.import java.io.*; import java. awt.*; public class Test{ }


    正确答案:B
    解析:Java中的package语句必须是源文件中除去说明以外的第一条语句,导入包语句可以有几个,但是必须位于package语句之后,其他类定义之前,一个源文件中可以有几个类,但最多只能有一个是public的,如果有,则源文件的文件名必须和该类的类名相同。

  • 第14题:

    下列代码的输出结果是( )。

    class parent

    {

    void printme()

    {

    System.out.println("parent");

    }

    }

    class child extends parent

    {

    void printme()

    {

    System. out.println("child");

    }

    void printall()

    {

    super, printme();

    this.printme();

    printme();

    }

    }

    public class test

    {

    public static void main(String args[])

    {

    child myc=new child();

    myc.printall();

    }

    }

    A.import java.awt.*;

    B.import java.applet.applet;

    C.import java.io.*;

    D.import java, awt.graphics;


    正确答案:A

  • 第15题:

    共用题干
    Drying Ways for Food

    1.Centuries ago,man discovered that removing moisture from food helps to preserve it,and that the easiest way to do this is to expose the food to sun and wind.In this way the North American Indians produce pemmican(dried meat ground into powder and made into cakes),the Scandinavians make stockfish and the Arabs dried dates and"apricot leather".
    2.All foods including water,cabbage and other leaf vegetables contain as much as 93%water, potatoes and other root vegetables 80%,lean meat 75%and fish,anything from 20%to 60%,depending on how fatty it is.If this water is removed,the activity of the bacteria which causes food to go bad is checked.
    3.Fruit is sun-dried in Asia Minor,Greece,Spain and other Mediterranean countries,and also in California,South Africa and Australia. The methods used vary, but in general,the fruit is spread out on trays in drying yards in the hot sun.In order to prevent darkening,pears,peaches and apricots are exposed to the fumes of burning sulfur before drying. Plums,for making prunes, and certain varieties of grapes for making raisins and currants,are dipped in an alkaline solution in order to crack the skins of the fruit slightly and remove their wax coating,so as to increase the rate of drying.
    4.Nowadays most foods are dried mechanically.The conventional method of such dehydration is to put food in chambers through which hot air is blown at temperatures of about 110℃at entry and to about 43℃at exit. This is the usual method for drying such things as vegetables,minced meat, and fish.
    5.Liquids such as milk,coffee,tea,soups and eggs may be dried by pouring them over a heated steel cylinder,by spraying them into a chamber through which a current of hot air passes.In the first case,the dried material is scraped off the roller as a thin film which is then broken up into small,though still relatively coarse flakes.In the second process,it falls to the bottom of the chamber as a fine powder. Where recognizable pieces of meat and vegetables are required,as in soup, the ingredients are dried separately and then mixed.
    6.Dried foods take up less room and weigh less than the same food packed in cans or frozen, and they do not need to be stored in special conditions.For these reasons they are invaluable to the climbers,explorers and soldiers in battle,who have little storage space.They are also popular with housewives because it takes so little time to cook them.Usually it is just a case of replacing the dried-out moisture with boiling water.

    Paragraph 4______
    A:Drying Fruit in the Traditional Way.
    B:Food Drying Histrory.
    C:Water in Food.
    D:Drying of Liquid Food.
    E:Advantages of Dry Food.
    F: Mechanical Food Dehydration.

    答案:F
    解析:
    本题考查的是对所读材料大意与主旨的掌握。由本段首句可知,本段中,心意思是所有的食物都含有水分。
    本题考查的是对所读材料大意与主旨的掌握。本段中心意思是传统的水果干制方法。
    本题考查的是对所读材料大意与主旨的掌握。本段中心意思是用机器干制食物的方法。
    本题考查的是对所读材料大意与主旨的掌握。本段中心意思是干燥流质食物的方法。
    本题考查的是对阐述文章的主旨事实与细节的了解。依据是第二段的第二句“If this water is removed , the activity of the bacteria which causes food to go bad is checked."
    本题考查的是对阐述文章的主旨事实与细节的了解。依据是第三段的第一句“Fruit is sun-dried in Asia Minor , Greece , Spain and other Mediterranean countries , and also in California,South Africa and Australia."
    本题考查的是对阐述文章的主旨事实与细节的了解。依据是第三段的第四句“Plums , for making prunes , and certain varieties of grapes for making raisins and currants , are dipped in an alkaline solution in order to crack the skins of the fruit slightly and remove their wax coating,so as to increase the rate of drying."
    本题考查的是对阐述文章的主旨事实与细节的了解。依据是第五段的第二句“In the first case , the dried material is scraped off the roller as a thin film which is then broken up into small,though still relatively coarse flakes."

  • 第16题:

    interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() 

    • A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }
    • B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }
    • C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
    • D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
    • E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
    • F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

    正确答案:A

  • 第17题:

    现自:  1.  interface Color {  }      2. interface Weight  {  }      3.  //insert code here    和以下足六个声明:  class Boat extends Color, extends Weight  {  }     class Boat extends Color and Weight  {  }      class Boat extends Color, Weight  {  }  class Boat implements Color,  implements Weight  {  }     class Boat implements Color and Weight  {  }      class Boat implements Color, Weight  {  }    分别插入到第3行,有多少行可以编译? () 

    • A、  0
    • B、  1
    • C、  2
    • D、  3

    正确答案:B

  • 第18题:

    Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()

    • A、The class implements java.lang.Comparable.
    • B、The class implements java.util.Comparator.
    • C、The interface used to implement sorting allows this class to define only one sort sequence.
    • D、The interface used to implement sorting allows this class to define many different sort sequences.

    正确答案:A,C

  • 第19题:

    Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java serialization and given:  import java.io.*;  class Food implemertts Serializable {int good = 3;}  class Fruit externds Food {int juice = 5;}  public class Banana extends Fruit {  int yellow = 4;  public static void main(String [] args) {  Banana b = new Banana(); Banana b2 = new Banana();  b.serializeBanana(b); // assume correct serialization  b2 = b.deserializeBanana(); // assume correct  System.out.println(”restore “+b2.yellow+ b2.juice+b2.good);  }  // more Banana methods go here  }  What is the result?() 

    • A、 restore 400
    • B、 restore 403
    • C、 restore 453
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:C

  • 第20题:

    public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()

    • A、 public class Circle implements Shape { private int radius; }
    • B、 public abstract class Circle extends Shape { private int radius; }
    • C、 public class Circle extends Shape { private int radius; public void draw(); }
    • D、 public abstract class Circle implements Shape { private int radius; public void draw(); }
    • E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
    • F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

    正确答案:B,E

  • 第21题:

    单选题
    Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given:  import java.io.*;  class Food {Food() { System.out.print(”1”); } }  class Fruit extends Food implements Serializable {  Fruit() { System.out.print(”2”); } }  public class Banana2 extends Fruit { int size = 42;  public static void main(String [] args) {  Banana2 b = new Banana2();  b.serializeBanana2(b); // assume correct serialization  b = b.deserializeBanana2(b); // assume correct  System.out.println(” restored “+ b.size + “ “); }  // more Banana2 methods  }  What is the result?()
    A

     Compilation fails.

    B

     1 restored 42

    C

     12 restored 42

    D

     121 restored 42

    E

     1212 restored 42

    F

     An exception is thrown at runtime.


    正确答案: F
    解析: 暂无解析

  • 第22题:

    单选题
    现自:  1.  interface Color {  }      2. interface Weight  {  }      3.  //insert code here    和以下足六个声明:  class Boat extends Color, extends Weight  {  }     class Boat extends Color and Weight  {  }      class Boat extends Color, Weight  {  }  class Boat implements Color,  implements Weight  {  }     class Boat implements Color and Weight  {  }      class Boat implements Color, Weight  {  }    分别插入到第3行,有多少行可以编译? ()
    A

      0

    B

      1

    C

      2

    D

      3


    正确答案: A
    解析: 暂无解析

  • 第23题:

    单选题
    interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?()
    A

     public class Employee extends Info implements Data { public void load() { /*do something*/ } }

    B

     public class Employee implements Info extends Data { public void load() { /*do something*/ } }

    C

     public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }

    D

     public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }

    E

     public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }

    F

     public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }


    正确答案: B
    解析: 暂无解析

  • 第24题:

    单选题
    Which is the best one for preserving food in the following methods?
    A

    Put the food in a cold place.

    B

    Cook the food well.

    C

    Dry the food by sun.

    D

    It is not told.


    正确答案: A
    解析:
    本题问下列哪种保存食物的方法是最好的。这是一篇说明文,作者并没有加入自己的观点和评价,所以答案应该选D项“没有提及”。