6. Show to calculate merge complexity? how the sort time Part 3 (140 points, 10
ID: 3885595 • Letter: 6
Question
6. Show to calculate merge complexity? how the sort time Part 3 (140 points, 10 each) Consider the code below, which is missing some variable declarartions: (From Java: The Complete Reference by Herbert Schildt) 1 class House t 2 House(String newAddress) f this.address = this.roommates newAddress; = new Hashset«Person>(); 4 6 7 String getAddress() ( return address; 9 void addRoommate(Person newRoommate) 10 roommates.add (newRoommate); if (roommates.size() MAXIMUM_OCCUPANCY) ( roommates.remove(newRoommate); throw new TooManyPeopleException(); 12 13 14 15 16 17 18 void getMaximumoccupancy() ( return MAXIMUM OCCUPANCY; 19)Explanation / Answer
1)
Ans: Line 10
Line 13.
Void addRoommate(person newREoommate)
{
roommates.add(newRoommate);
if(roommates.size()) > MAXIMUM_OCCUPANCY)
{
roommates.remove(nhewRoommate);
throw new TooManyPeopleException();
}
}
2)
Ans:
final Set<Person>roommates;
3)
Ans: Line 2-19
address variable is declared in main class and scope of that variable is till the end of class.
4)
Ans:final int MAXIMUM_OCCUPANCY = 8;
5)
public class Grammer{
public static void English(String s){
System.out.println("String");
}
public static void English(Object o){
System.out.println("Object");
}
public static void main(String [] args){
English(null);
}
}
Ans:
It'll compile and output will be: String
6)
Ans:
No, it'll get error because,both method English(String)and method English(Integer) match
7)
public class Math{
public static void main(String args []){
short s=0;
int x=07;
int y=07;
int z=123456;
s+=z;
System.out.println("" + x + y + s);
}
}
Ans: It will execute and answer is 77-7616
8)
a) Ans: 32;
b) e
c)System.out.println(bellah.charAt(4));
10) a) computer
b) x,y
13) Ans: vowel2[0]='x';
14)Ans: vowel3[0]='x';
vowel4[0]='x';
vowel5[0]='z';
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.