Public Class Int: "Hello"
Public Class Int: "Hello"
1 שאלה
.א
public class A {
int n1;
String s1;
.ב
2 שאלה
.א
public Student(String name, String id)
{
this.name=name;
this.id=id;
}
.ב
public String ToString() {
return ("name:"+name+" id: "+id);
}
.ג
public Exam(Exam ref)
{
subject=ref.subject;
professor=ref.professor;
studList=ref.studList;
}
.ד
void toString2() {
System.out.println("subject:"+subject);
System.out.println("professor: "+professor);
for (int i=0;i<studList.length;i++) {
System.out.println(studList[i].toString());
}
}
.ה
3 שאלה
public String[] shita(String str,int num) {
String[] arr = new String[num];
for (int i=0;i<arr.length;i++)
arr[i]=str+i;
return arr;
}
4 שאלה
public class Exam_grades extends Exam {
double[] grades_arr;
public Exam_grades(String sub,String prof,Student[] stud)
{
super(sub,prof,stud);
grades_arr = new double[studList.length];
for (int i=0;i<studList.length;i++)
{
grades_arr[i]=0;
}
}
void input_grades() {
Scanner scan = new Scanner(System.in);
for (int i = 0; i < studList.length; i++)
{
System.out.println("Enter grade for student:
"+studList[i].toString());
grades_arr[i] = scan.nextDouble();
}
}
}
5 שאלה
.א
Volume: 1.0 The Box is Empty
Zero constructor
Volume: 6.0 The Box contains Money
Volume: 6.0 The Box contains Money
Copy constructor
Volume: 1.0 The Box is Empty(null wrap)
Zero constructor
Volume: 1.0 The Box contains Dress(White wrap)
B1
Box
X=1
Y=1
Z=1
Inside="Empty"
B3
Box
x=1 B2
y=2 Box
z=3 x=1
inside="Money" y=2
z=3
P1 "Inside="Money
present
X=1
Y=1
Z=1
Inside="Empty""Dress"
Wrap_color="White"
B4
.ב
) (לא הצבעה כפולהnew – אובייקט שנוצר הוא אובייקט שלצורך יצירתו השתמשנו ב
:ולכן
.ג