已知函数getStudent()定义为public Student getStudent(int ID),下列四个选项中可以与getStudent构成重载的方法是
A: private Student getStudent(int ID)
B: public String getStudent(int ID)
C: Student getStudent(String name)
D: public Student get(int ID)
A: private Student getStudent(int ID)
B: public String getStudent(int ID)
C: Student getStudent(String name)
D: public Student get(int ID)
举一反三
- 【填空题】阅读程序写结果 public class Student { private static int sid = 0; private String name; int id; Student(String name) { this.name = name; id = sid++; } public void info() { System.out.println("My name is "+name+" No."+id); } public static void infoSta() { System.out.println(sid); } public static void main(String arg[]) { Student.sid = 100; Student st1 = new Student("huahua"); st1.sid = 2000; Student st2 = new Student("meimei"); st1.info(); st2.info(); } }
- class Person{} class Student extends Person{ public int id; public int score; public String name; public int getScore() { return score; }
- 以下自定义数据类型的语句中,正确的是 A: A.Type student ID As String * 20 name As String * 10 age As Integer End student B: B.Type student ID As String * 20 name As String * 10 age As Integer End Type C: C.Type student ID As String name As String age As Integer End student D: C.Type ID As String * 20 name As String * 10 age As Integer End Type student
- 一. IO操作问题描述程序功能:在网络传输过程中,对象数据往往需要进行序列化操作,即将对象序列化为byte数组,同时也需要反序列化操作将byte数组转化为对象。下面程序中定义了一个Student类,在该类中已经实现了反序列化操作,请完成序列化的操作代码。程序结构如下:import java.io.*;class Student{int stuNo;//学号String name;//姓名String sex;//性别int age;//年龄String grade;//年级String classname;//班级public Student(int stuNo,String name,String sex,int age,String grade,String classname){this.stuNo=stuNo;this.name=name;this.sex=sex;this.age=age;this.grade=grade;this.classname=classname;}//反序列化操作public static Student GetStudent(byte[] byteStudent){try{ByteArrayInputStream bais=new ByteArrayInputStream(byteStudent);DataInputStream dis=new DataInputStream(bais);int stuNo=dis.readInt();String name=dis.readUTF();String sex=dis.readUTF();int age=dis.readInt();String grade=dis.readUTF();String classname=dis.readUTF():return new Student(stuNo,name,sex,age,grade,classname);}catch(Exception ex){return null;}//序列化操作,请完成public byte[] GetBytes(){... //补充此处代码}public class Exam2{public static void main(String args[]){Student stu=new Student(20090223,”jack”,”man”,21,”三年级”,”2班”);byte[] bytestu=stu.GetBytes();Student stu1=Student.GetStudent(bytestu);System.out.println(stu1.s5uNo);}程序要求1. 实现序列化代码
- 下面程序运行的结果是 struct Student { public int age; public string name; public Student(int age, string name) { this.age = age; this.name = name; } } class Program { static void Main(string[] args) { Student stu1 = new Student(18, "小方"); Student stu2 = new Student(24, "小刚"); stu2 = stu1; stu1.age = 30; stu1.name = "小燕"; Console.WriteLine("{1},{0}",stu2.age,stu2.name); } }