Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve these questions please Read the following questions and choose the best answer. 1. objects are immutable. a. Array b. String c. StringBuilder d. a

solve these questions please image text in transcribedimage text in transcribedimage text in transcribed

Read the following questions and choose the best answer. 1. objects are immutable. a. Array b. String c. StringBuilder d. a and c e. none of the above 2. Which of the following exceptions is an example of unchecked exception? a. MalformedURLException b. FileNotFoundException c. ArithmeticException d. EOFException e. none of the above 3. cannot be instantiated. a. Concrete classes b. Abstract classes c. Interfaces d. b and c e. none of the above 4. In the statement: System.out.println(); out is considered to be a. class variable b. class method c. instance variable d. instance method e. none of the above 5. The method moves the thread from the initial state to the runnable state. a. run() b. start () c. yield() d. notify() e. wait() PART 2: Short Answer Questions [35 Marks] Question 1: [13 marks] What does the following method return for s= "same"? (Show your working steps in details) Question 2: [12 marks] Given the following class diagram, which of the following statements is valid (or corr For invalid (or incorrect) ones, explain the reason. M251-M257 / Final-KSA Page 2 of 4 AOU A Arab Open University Individual ind = new Individual(); 1. Individual ind = new Trainee(); 2. There is a composition relationship between Center and Trainee 3. Class Individual should have at least one abstract method 4. Class Trainee is a subclass of class Individual 5. The default value for an instance variable of type Trainee is 0 Question 3: [10 marks] Assume that you have a map called flights which includes flights' numbers and number of passengers for each flight. It is required to complete the following code to compute the average number of passengers per flight, and print the result. public static void averagepass (........................... flights) I PART 3: Problem Solving Questions [50 Marks] Question 1: [40 marks] 1. Write the class Trainee which includes: a) 3 attributes: Trainee ID (which is unique), name and age. b) a zero-arg constructor and a mutli-arg constructor. c) getters for name and age attributes. d) toString() method which overrides the Object's toString() method. e) equals() method which overrides the Object's equals() method. 2. Write the class Center which includes: a) 2 attributes: center name and ArrayList of Trainees. b) one-arg constructor that accepts the center name as an argument, and create a new empty ArrayList of Trainees. c) method addTrainee() that accepts a Trainee object as an argument and add it to the ArrayList with a confirmation message. It is not allowed to add the same Trainee twice and in this case an error message should be displayed. d) method oldestTrainee() which returns name of the oldest Trainee in the Center (whose age is the maximum). e) method savelntoFile() which accepts a file name as an argument. It stores the center name and information of all Trainees in this file (each Trainee in a different line). 3. Write a code to test your classes by performing the following tasks: a) create a Center object called myCenter where the center name is "M251 Center". b) create 2 Trainees and add them to myCenter using the method addrainee() c) print name of the oldest Trainee in the Center by calling the method oldestTrainee() d) call the method savelntofile() to save the required information. Question 2: [10 marks] Based on the classes of Part 3 - Question 1, Given the following code which displays the following GUI application: public void start(Stage primarystage) 1 //Missing code (1): Initialization Center myCenter = ............... Label idL = Label nameL = Label ageL =.. Trainee ID TextField idTF =.. Name TextField nameTF = TextField agetF =.. Button addB =.. Add Trainee GridPane pane = primarystage. settitle (.................); pane. addColumn (0,idL, nameL, agel, addB); pane. addColumn (1, idTF, nameTF, ageTF); Scene scene = new Scene (pane) ; primarystage. setscene (scene) ; primarystage.show() //Missing Code (2): Clicking on the button 1. Complete the first missing code to initialize the UI controls. 2. Complete the second missing code such that when the user fills the required information and clicd on the button "Add Trainee", a Trainee will be added to the object myCenter. End of Questions M251-M257 / Final-KSA 22/2023 Fall

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

More Books

Students also viewed these Databases questions