0% found this document useful (0 votes)
40 views4 pages

CS244 Final Exam

This document outlines the final assessment details for the Advanced Programming Applications course (CS244) at the College of Computing & Information Technology. It includes instructions for students regarding submission, question formats, and specific programming tasks related to Java. The exam consists of multiple-choice questions, code analysis, and programming assignments, with a total of 40 marks available.

Uploaded by

abdo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

CS244 Final Exam

This document outlines the final assessment details for the Advanced Programming Applications course (CS244) at the College of Computing & Information Technology. It includes instructions for students regarding submission, question formats, and specific programming tasks related to Java. The exam consists of multiple-choice questions, code analysis, and programming assignments, with a total of 40 marks available.

Uploaded by

abdo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

COLLEGE OF COMPUTING & INFORMATION

TECHNOLOGY
Department: Computer Science
Lecturer: Dr. Omar Shalash
Course Title: Advanced Programming Applications
Course Code: CS244
Semester: Fall 2020/2021 Date: 30/01/2021 Marks: 40
Start Time: 12:30 PM Submission Time: 03:00 PM Max

FINAL ASSESSMENT –TIME LIMITED TAKE HOME EXAM


Notes for Students:

• Kindly start by writing your: Full name, Registration number, and department on your answer papers.
• Kindly attach a copy of your Student/ National ID to your submitted file.
• Carefully number your answer papers and write the question number you are answering.
• Exam deadline for submission is 03:00 PM 30/01/2021.
• The PDF file which include all your answer papers and ID scans should be renamed to [Your-Full-Name]-
[Your-Reg.Number]-CS244_Final_Answer (without square brackets).
• Submit (Turn in) the Exam on moodle
Answer all questions. Show your work so that partial credits may be assigned
Question #1 (10 Marks):
Circle whether the following statements are True or False, Correct False and
explain your answer in both cases:
T F 1. A subclass can add behavior that is not present in the superclass.

T F 2. If FileNotFoundException occurs when a program is executed, it means that the


program contains a bug.

T F 3. A final method can be overridden.

T F 4. Java methods are private by default, which means they cannot be called from
outside of that file.

T F 5. Instance variables should always be declared to be public.

T F 6. A protected datum or method can be accessed by any class in the same package.

T F 7. To be notified when a user clicks on a button, the program must add an event
handler to the button.

T F 8. To connect to a server running on the same machine with the client, "125.0.0.1"
can be used for the hostname.

Page 1 of 4 EDQMS 2/3


T F 9. You can invoke “socket.InetAddress()” on a Socket object, say socket, to obtain
an InetAddress object.
T F 10. A final method can be overridden.

Question #2 (10 Marks): (explain your answer in all following parts)


(5 points) Part a:
1. Consider the following code:
public class mySet {
List myElements = new ArrayList( );
public boolean add( Object o ) {
myElements.add( o );
}
public Object remove( ) {
if (myElements.isEmpty( ) == false)
return myElements.remove( 0 ); // removes & returns object at position 0
return null;
}
}

a. What may happen if an object of the class mySet is used by multiple threads calling
add( ) and remove( ) at the same time?

b. Change the add( ) and remove( ) methods so that the class mySet can be safely
used by multiple threads at once.

c. What is the difference between starting a thread using start() or run()?

2. Consider the following code:


public static void f( int y ) {
try { What will be printed for the
System.out.print(“A”); following method calls?
int x = 1 / y ; // generates ArithmeticException if y == 0
System.out.print(“B”); a. f(1)
}
catch (ArithmeticException e) {
System.out.print(“C”); b. f(0)
}
finally {
System.out.print(“D”);
}
}

Page 2 of 4 EDQMS 2/3


(5 points) Part b:
For each of the following code snippets, please indicate if the code shown would
a. fail to compile,
b. compile, but result in an error at runtime, or
c. execute without an error. In this case, indicate what output you would see.
public abstract class Plant {
i. Flower rose = new Flower();
public void smell() {
rose.smell(); System.out.println(“No smell”);
}
ii. Fruit orange = new Fruit(); }
orange.smell(); public class Flower extends Plant {
public void smell() {
System.out.println(“I smell good!”);
iii. Plant oakTree = new Plant();
}
oakTree.smell(); }
public class Fruit extends Plant {
iv. Plant banana = new Fruit(); public void smell() {
banana.smell(); System.out.println(“I smell yummy!”);
}
}
v. Plant violet = new Flower();
Flower myViolet = violet;
myViolet.smell();

vi. Flower jasmine = new Plant();


jasmine.smell();

Page 3 of 4 EDQMS 2/3


Question #3 (15 Marks):
Write a program that enables two users to chat. Implement one user as the server (see Figure
a) and the other as the client (see Figure b). The server has two text areas: one for entering
text, and the other (noneditable) for displaying text received from the client. When the user
presses the Enter key, the current line is sent to the client. The client has two text areas: one
(noneditable) for displaying text from the server and the other for entering text. When the
user presses the Enter key, the current line is sent to the server. Name the client
“[Your_First_Namr]_[Your_Registration_Number]” and the server “AAST”. The server should
be able to accept multiple clients. Set server address to 250.20.1.4 and port to 8080.
USE only JavaFX library for GUI design

Client 5 marks
Server 10 marks

Question #4 (5 Marks):
Write saveData(String Data[], String serverData[]) method that stores the client data from
previous question into a file named with client name+DateandTime.txt. the data in the file
should define the server data the saves the chat data. For example:
Line 1:AAST
Line 2:250.20.1.4:8080
Line 3:Student_2010010 Saturday, January 30, 2021 01:30:10 PM
Line 4:Hi Frank, How are you?
etc.

Good Luck
Page 4 of 4 EDQMS 2/3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy