AP/ITEC 1620 3.0 – Object-Based Programming - IT Assignment Help

Download Solution Order New Solution
Assignment Task:

Task:

PART A1: FIND OUTPUT OF JAVA CODE FRAGMENTS [20 marks]
1. What is the output of the following Java code fragment? [2 marks]
int i1, i2, i3;
double r1, r2;
i1 = 50;
r1 = 13;
r2 = 2.5 * --r1;
i2 = 2 * (i1 %= 8);
i3 = i2 * (int)r2;
System.out.println(r1+r2);
System.out.println(i3);
Answer:

42.0 1 mark
120 1 mark
2. What is the output of the following Java code fragment? [3 marks]
int x = 63;
int y = 100;
int k;
for(k = 0; x > 0; k++){
y -= x % 8;
x = ++x / 10;
}
System.out.println(k);
System.out.println(y);

Answer:

2 1 mark
87 2 mark

3. What is the output of the following Java code fragment? [3 marks]
String s1 = "100";
String s2 = "2022";
System.out.println(s1 + s2 + 30);
System.out.println(9 / 2 + 40 + s1 + s2);

Answer:

100202230 1 mark
441002022 2 marks

 

4. What is the output of the following Java code fragment? [3 marks]
for(int i = 5; i >= 3; i--){
for(int j = 0; j < i; j++)
System.out.print(i);
if (i%2 ==0)
System.out.println();
}
Answer:

555554444 2 mark
333 1 mark

 

5. What is the output of the following Java code fragment? [5 marks]
String s = "University of Toronto";
int i = 3;
int j = 15;
int p = s.indexOf("n");
int q = s.substring(++i, j--).indexOf("o");
System.out.println(p + " " + i);
System.out.println(q + " " + j);

Answer:

1 4 2 marks
7 14 2+1 marks

6. What is the output of the following Java code fragment? [4 marks]
String s = "Toronto";
int k = s.length() - 4;
System.out.println(s.substring(k, s.length() - 1));
boolean b = s.substring(5) == "to";
System.out.println(b);

Part A2. Multiple Choice Questions. [9 marks]
Circle the correct answers. Each question has only one correct answer unless specifically
stated otherwise. Each question is worth 1 mark.
1. Method overloading refers to:
A) Several methods with the same name and the same parameters
B) Several methods with different names but the same parameters
C) Several methods with the same name, but different parameters
D) Several methods with different return types

2. A static variable _________________________
A) has different values for different instances of the class
B) has no values
C) has the same value for all instances of the class
D) cannot be modified

 

3. An aggregation relationship is also called a ____________
A) “uses a” relationship
B) “is a” relationship
C) “has a” relationship
D) None of the above

4. A static method __________________
A) belongs to a class
B) can be invoked using the class name
C) cannot reference instance variables
D) all of the above

5. When a method is invoked, which of the following statements is true?
A) The values of the arguments are assigned to the corresponding parameters
B) If the argument and parameter are object references, they become aliases of each other
C) The number and types of arguments must match exactly the number and types of the parameters
D) All of the above

6. The range of valid indexes in an array of 25 items is ________
A) 1 to 25
B) 0 to 25
C) 0 to 24
D) 1 to 24

7. Considering the three types of loops (while, do and for) which of the following statement is correct?
A) They are functionally equivalent (i.e., any type of loop can be re-written as a loop of the other two types).
B) All three types of loop will execute the statements in their body at least once.
C) How many times the body of a loop will be executed can be easily calculated for all three types of loops.
D) All of the above

8. Which of the following applies to both an array and an ArrayList?
A) Their elements are stored in consecutive memory locations
B) When declaring them you must know how many elements they have
C) In a program one can increase their size
D) None of the above

AP/ITEC 1620 3.0: Object-Based Programming Fall 2018

6

PART B: PROGRAMMING QUESTIONS [72 marks]
1) [17 marks]
An application uses 2 classes: Card and Dealer.
API for Class Card
public Card(int faceValue, int suit); // constructor
public String toString();
You have to write the Dealer class which creates an array of 52 Card objects called deck. Note that you also have to create the 52 Cards, knowing that a Card can have 13 face values: 2, 3,.. 10, J=11, Q=12, K=13, A=14 and 4 suits: clubs, diamonds, hearts, spades.

 

2) [22 Marks]
Write the class Bank which allows the user to enter 100 customers data into an array of objects. The API of the Customer class is shown below.
The data for each customer is entered from the keyboard in the following order:
(i) an integer corresponding to the customer number,
(ii) a String corresponding to the customer name,
(iii) a double corresponding to the balance of that bank account
After entering this data create an object of Customer type. This object will be part of an array of 100 Customer objects.
Next use bubble sort to rearrange the array to have the customer names in alphabetic order and display all the customer information for those customers who have over $100,000.

 

This IT Assignment has been solved by our IT Experts at onlineassignmentbank. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment Experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

 

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.