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

(CSE231) Spring - 2022

This document outlines the exam details for the Advanced Computer Programming course at Ain Shams University, including rules against cheating and the structure of the exam consisting of three questions. The questions cover various programming concepts, Java class structures, and object-oriented programming principles. The exam is scheduled for June 10, 2023, and has a total of 40 marks.

Uploaded by

omar.ahmed.nes6
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)
7 views4 pages

(CSE231) Spring - 2022

This document outlines the exam details for the Advanced Computer Programming course at Ain Shams University, including rules against cheating and the structure of the exam consisting of three questions. The questions cover various programming concepts, Java class structures, and object-oriented programming principles. The exam is scheduled for June 10, 2023, and has a total of 40 marks.

Uploaded by

omar.ahmed.nes6
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

AIN SHAMS UNIVERSITY

FACULTY OF ENGINEERING
Computer Engineering and Software Systems Program
Spring, 2022/2023 Course Code: CSE 231, CSE126 Time allowed: 2 Hrs.
Advanced Computer Programming
The Exam Consists of Three Questions in Four Pages. Maximum Marks: 40 Marks 1/4
Important Rules: ‫ﻌﻠﻴﻤﺎت ﺎﻣﺔ‬
 Having a (mobile -Smart Watch- earphones) inside the ‫ ﺳﻤﺎﻋﺔ اﻷذن( داﺧﻞ‬- ‫ اﻟﺴﺎﻋﺎت اﻟﺬﻛﻴﺔ‬-‫ ﺣﻴﺎزة )ا ﻤﻮل‬
examination hall is forbidden and is considered as a . ‫ﻨﺔ اﻻﻣﺘﺤﺎن ﻌﺘ ﺣﺎﻟﺔ ﻏﺶ ﺴﺘﻮﺟﺐ اﻟﻌﻘﺎب‬
cheating behavior. ‫ ﻻ ﺴﻤﺢ ﺑﺪﺧﻮل أي ﻛﺘﺐ أو ﻣﻼزم أو أوراق داﺧﻞ اﻟ ﻨﺔ‬
 It is forbidden to have any references, notes, books, or .‫وا ﺎﻟﻔﺔ ﻌﺘ ﺣﺎﻟﺔ ﻏﺶ‬
any other materials even if it is not related to the exam
content with you in the examination hall.
Question (1): 15 (MARKS)

Answer the following:


1) (Complete) …………………. used to enable a constructor to invoke another
constructor in the same class while …………………. used to invoke parent
classes’ data fields.
2) Can a Java source file have more than one class?
3) What does “interned strings” mean?
4) Can the advantage of reusability be achieved by applying the concept of
encapsulation?
5) Which keyword is used to acquire a lock on any object when executing a block of
the code in a method.
6) When “finally” block is executed in try-catch statement?
7) What is the Java compiled file named “Test$3.class” means ?
8) How to make creating a large number of threads takes smaller time during the run
time?
9) Can the interface have no members? Give an example.
10) How to make a class member shared by all the instances of this class
AIN SHAMS UNIVERSITY, FACULTY OF ENGINEERING
Computer Engineering and Software Systems Program
Spring, 2022/2023 Course Code: CSE 231, CSE126 Time Allowed: 2 Hrs.
Advanced Computer Programming
The Exam Consists of Three Questions in Four Pages 2/4

Question (2): 12 (MARKS)

(a)
public class Test extends Exam {
public static void main(String[] args) {
System.out.println(new Test());
}
public Test() {
System.out.print("t");
}

class Exam {
private static int counter;
public Exam(){
this("r");
System.out.print("c");
}
public Exam(String s){
System.out.print("Co" + s + s);
System.out.print(this);
}
public String toString(){
String retVal;
if (counter == 0) {
counter++;
retVal = "e";
} else {
retVal = " A";
}
return retVal;
}
}

1- What is the output of the previous code?

2- Complete the missing: The “Exam” Class inherits the Class …………. and it is
…………………the “toString” Method.

2
AIN SHAMS UNIVERSITY, FACULTY OF ENGINEERING
Computer Engineering and Software Systems Program
Spring, 2022/2023 Course Code: CSE 231, CSE126 Time Allowed: 2 Hrs.
Advanced Computer Programming
The Exam Consists of Three Questions in Four Pages 3/4

3- What would be the problem if the no-argument constructor of “Exam” Class


was not defined?

4- In which case the no-argument constructor is not created?

5- The keyword final has different meanings according to the usage, explain it is
meaning in case of usage with variables, classes and methods.

(b)
1 public class Test {
2 public static void main(String[] args) {
3 Exam f = new FinalExam();
4 if(f instanceof Exam)
5 {
6 System.out.println("1");
7 }
8 else if (f instanceof FinalExam) {
9 System.out.println("2");
10 }
11 else
12 {
13 System.out.println("3");
14 }
15 }
16
17 }
18 class Exam{}
19
20 class Midterm extends Exam{}
21
22 class FinalExam extends Exam {}

1- What is the expected output ?


2- Draw the UML Diagram.
3- Is it possible that we replace line 2 by line 3 ?

3
AIN SHAMS UNIVERSITY, FACULTY OF ENGINEERING
Computer Engineering and Software Systems Program
Spring, 2022/2023 Course Code: CSE 231, CSE126 Time Allowed: 2 Hrs.
Advanced Computer Programming
The Exam Consists of Three Questions in Four Pages 4/4

Question (3): 13 (MARKS)

Create three classes: Triangle, Square and Rectangle which have the following
properties:

- You can create one array that has objects of these class.
- You can sort the objects in this array using “java.util.Arrays.sort” method based
on the area of these objects.
- These classes have a method “printData” that prints the data of their objects.
- An exception is thrown when invalid data is entered.
- An incremental method is used to increment the object data and this method runs
as a thread.
- You can compare between any 2 objects of these classes (based on their areas)
using the method “equals”.

Write a test class that has a main method to show the usage of the above features of
these classes.

END of Exam, Good Luck


Examination Committee: Prof. Mahmoud Khalil Exam. Date : 10 June, 2023

You might also like