SlideShare a Scribd company logo
Imam University | CCIS |Doc. No. 006-01-20141026
Page 1 of 10
Al Imam Mohammad Ibn Saud Islamic University
College of Computer and Information Sciences
Computer Science Department
Course Title: Programming II
Course Code: CS141
Course
Instructor:
Dr Abdulrahman Albarrak Dr. Qaisar Abbas,
Dr Ashraf Shahin
Exam: Midterm
Semester: Fall 2016
Date: 22th Nov 2016
Duration: 90 Minutes
Marks: 20
Privileges: ☐ Open Book
☐ Calculator
Permitted
☐ Open Notes
☐ Laptop Permitted
Student Name (in
English):
Student ID:
Section No.:
Instructions:
1.Answer all questions; there are 4 questions in 7 pages.
2.Write your name on each page of the exam paper.
3.Write your answers directly on the question sheets. Use the ends of the question
pages for rough work or if you need extra space for your answer.
4.If information appears to be missing from a question, make a reasonable
assumption, state your assumption, and proceed.
5.No questions will be answered by the invigilator(s) during the exam period.
Official Use Only
Question Student Marks Question Marks
1 4
2 3
3 3
4 10
Imam University | CCIS |Doc. No. 006-01-20141026
Page 2 of 10
Total
Student Name (in
English):
__________________________________________ Student
ID:
_____________________________
Question 1: To be answered in ( ___ ) Minutes [ ] / 4 Marks
Select one or more appropriate options from multiple choice questions and try fill in
the following box with your choice for each point.
Note that if you did not find an appropriate answer then you can write your own
answer with some reasons.
Question 1 2 3 4 5 6 7 8
Answer
1. Which of the following is not true?
(a) An interface can extend another interface.
(b) A class which is implementing an interface must implement all the methods of
the interface.
(c) An interface can implement another interface.
(d) An interface is a solution for multiple inheritance in java.
(e) None of the above.
2. The fields in an interface are implicitly specified as,
(a) static only
(b) protected
(c) private
(d) both static and final
(e) none of the above.
3. To prevent any method from overriding, we declare the method as,
(a) static (b) const (c) final (d) abstract (e) none of the
above.
4. Which one of the following is not true?
(a) A class containing abstract methods is called an abstract class.
(b) Abstract methods should be implemented in the derived class.
(c) An abstract class cannot have non-abstract methods.
(d) A class must be qualified as ‘abstract’ class, if it contains one abstract method.
(e) None of the above.
5. Which statement is not true in java language?
Imam University | CCIS |Doc. No. 006-01-20141026
Page 3 of 10
(a) A public member of a class can be accessed in all the packages.
(b) A private member of a class cannot be accessed by the methods of the same
class.
(c) A private member of a class cannot be accessed from its derived class.
(d) A protected member of a class can be accessed from its derived class.
(e) None of the above.
6. Which of the following concepts means wrapping up of data and functions
together?
(a) Abstraction
(b) Encapsulation
(c) Inheritance
(d) Polymorphism
7. Which of the following is correct about function overloading?
(a) The types of arguments are different.
(b) The order of argument is different.
(c) The number of argument is same.
(d) Both A and B.
8. How many instances of an abstract class can be created?
(a) 1 (b) 5 (c) 13 (d) 0
Imam University | CCIS |Doc. No. 006-01-20141026
Page 4 of 10
Student Name (in
English):
__________________________________________ Student
ID:
_____________________________
Question 2: To be answered in ( ___ ) Minutes [ ] / 3 Marks
Let be the following code:
There are three mistakes in this code. Please find those mistakes and make the code
error free. Write the line number and clearly specify the problem.
Line No Error Correction
1. abstractclassEx {
2. static intx=2;
4. public abstractvoid set(inta);
5. public abstractvoid print();
6. public static intgetX()
7. {return this.x;}
8. }
9. class Ex1 extends Ex {
10. privateint y;
11. public Ex1()
12. { y=3; }
13. public void print()
14. { System.out.println(y); }
15. }
16. classEx2 extends Ex1 {
17. privateint z;
18. public Ex2()
19. { z=5; }
20. @Override
21. public void set(int a)
22. {z=a; }
23. public int get()
24. {return z; }
25. public void print()
26. {
27. super.print();
28. System.out.println(z);
29. }
30. }
31. classExRun {
32. public static void main (String[] args){
33. Ex a=new Ex1();
34. Ex b=new Ex2();
35. if( b instanceof Ex2)
36. { System.out.println( ((Ex2)b).get()); }
37. }
38. }
Imam University | CCIS |Doc. No. 006-01-20141026
Page 5 of 10
Student Name (in
English):
__________________________________________ Student
ID:
_____________________________
Question 3: To be answered in ( ___ ) Minutes [ ] / 3 Marks
Provide the output(s) of the following code segments and fill in the following box
with outputs for each point.
Question 1 2 3
outputs
(1)
class Test1 {
public inta;
public Test1()
{ a=5;
print();
}
public void print()
{System.out.println(a);}
}
class Testextends Test1{
public intb;
public Test()
{
b=3;
}
@Override
public void print()
{System.out.println( b);}
}
class RunTest{
public static void main (String[] args){
Test1 e=new Test() ;
}
}
(2)
class Test1 {
public static intcount=2;
int x=5;
public Test1()
{ x++;
Imam University | CCIS |Doc. No. 006-01-20141026
Page 6 of 10
count+=x;
}
public intgetCount()
{ return this.count; }
}
public classTest{
public static void main(String[] args) {
Test1 a;
Test1 b=new Test1();
Test1 c=new Test1();
System.out.println(b.getCount());
}
}
(3)
class Ex {
privateint x;
public Ex()
{ x=2;}
public void print()
{ System.out.println( x);}
}
class Ex1 extends Ex{
privateint y;
public Ex1()
{ y=5; }
@Override
public void print()
{ System.out.println( y);}
}
class ExRun {
public static void main (String[] args){
Ex a=new Ex1();
a.print();
}
}
Imam University | CCIS |Doc. No. 006-01-20141026
Page 7 of 10
Student Name (in
English):
__________________________________________ Student
ID:
_____________________________
Question 4: To be answered in ( ___ ) Minutes [ ] / 10 Marks
A new medical staff management system is created for a small hospital. In this system, the
medical staff are of three types: (i) doctor, (ii) nurse and (iii) therapist. Each medical staff has
the following attributes: a name (type String), joined Date (type Date), a social security
number (type int) and education (type String). These attributes are fixed once they added to
the system. For each doctor we need to consider the specialty (String), rank (String),
department(String). For each nurse, a ward number (type int), type(String), Skills (String),
role(String) are taken into consideration. For a therapist, treatment Type (String),
skills(String), function(String) are stored. We need to know the number of staff in the hospital
and we need to know the number of staff for each type.
(a) Write the needed abstract and concrete classes to represent the system. For each class
provide a toString method that returns a String representation of an object of the class with
its attributes and the attributes of its superclass (5 points).
(b) Declare the Test class that contains public static void main(String[] args). In the main take
the number of staff to be added to the system and for each staff allow the user to select the
type of staff (Doctor, Nurse, Therapist) to be add to the system (use switch). The program
should be implemented using polymorphism (demonstrating polymorphic behavior when
dealing with staff). Once you have added all the staff print the number of all staff and the
number of staff in each type. Write a loop to print all the staff information (call to String (5
points).
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
Imam University | CCIS |Doc. No. 006-01-20141026
Page 8 of 10
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
Imam University | CCIS |Doc. No. 006-01-20141026
Page 9 of 10
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
Imam University | CCIS |Doc. No. 006-01-20141026
Page 10 of 10
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................

More Related Content

What's hot

Working with logarithms
Working with logarithmsWorking with logarithms
Working with logarithms
RDija Ayop
 
Java căn bản - Chapter13
Java căn bản - Chapter13Java căn bản - Chapter13
Java căn bản - Chapter13Vince Vo
 
Mid1 cs141-1-17-1-final version
Mid1 cs141-1-17-1-final versionMid1 cs141-1-17-1-final version
Mid1 cs141-1-17-1-final version
Fahadaio
 
Mca 104
Mca 104Mca 104
Mca 104
smumbahelp
 
22222222222222222
2222222222222222222222222222222222
22222222222222222saud2015
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
sujatam8
 
Cbse ugc net paper First solved from july 2016 to June 2013
Cbse ugc net paper First solved from july 2016 to June 2013Cbse ugc net paper First solved from july 2016 to June 2013
Cbse ugc net paper First solved from july 2016 to June 2013
Knowledge Center Computer
 
Holistic Approach for Arabic Word Recognition
Holistic Approach for Arabic Word RecognitionHolistic Approach for Arabic Word Recognition
Holistic Approach for Arabic Word Recognition
Editor IJCATR
 
Summarize of CS course guidebook
Summarize of CS course guidebookSummarize of CS course guidebook
Summarize of CS course guidebookcsecUSM
 
IIT JEE Seat Allocation System
IIT JEE Seat Allocation System IIT JEE Seat Allocation System
IIT JEE Seat Allocation System
Priyatham Bollimpalli
 
banking Coaching Institute in Delhi, Janakpuri
banking Coaching Institute in Delhi, Janakpuribanking Coaching Institute in Delhi, Janakpuri
banking Coaching Institute in Delhi, Janakpuri
Competition Gurukul
 
An Automatic Question Paper Generation : Using Bloom's Taxonomy
An Automatic Question Paper Generation : Using Bloom's   TaxonomyAn Automatic Question Paper Generation : Using Bloom's   Taxonomy
An Automatic Question Paper Generation : Using Bloom's Taxonomy
IRJET Journal
 
Question Classification using Semantic, Syntactic and Lexical features
Question Classification using Semantic, Syntactic and Lexical featuresQuestion Classification using Semantic, Syntactic and Lexical features
Question Classification using Semantic, Syntactic and Lexical features
IJwest
 
Banking Exam coaching in Delhi, Janakpuri
Banking Exam coaching in Delhi, JanakpuriBanking Exam coaching in Delhi, Janakpuri
Banking Exam coaching in Delhi, Janakpuri
Competition Gurukul
 
5315Syll2015Fall
5315Syll2015Fall5315Syll2015Fall
5315Syll2015FallNeha Gupta
 
Apperson benchmark tm 3000
Apperson benchmark tm 3000Apperson benchmark tm 3000
Apperson benchmark tm 3000
qhenderson
 
ANALYZING THE EFFICIENT TEST ORDER FOR INTEGRATION TESTING
ANALYZING THE EFFICIENT TEST ORDER FOR INTEGRATION TESTINGANALYZING THE EFFICIENT TEST ORDER FOR INTEGRATION TESTING
ANALYZING THE EFFICIENT TEST ORDER FOR INTEGRATION TESTING
acijjournal
 

What's hot (19)

Working with logarithms
Working with logarithmsWorking with logarithms
Working with logarithms
 
Java căn bản - Chapter13
Java căn bản - Chapter13Java căn bản - Chapter13
Java căn bản - Chapter13
 
Mid1 cs141-1-17-1-final version
Mid1 cs141-1-17-1-final versionMid1 cs141-1-17-1-final version
Mid1 cs141-1-17-1-final version
 
Mca 104
Mca 104Mca 104
Mca 104
 
22222222222222222
2222222222222222222222222222222222
22222222222222222
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
 
Cbse ugc net paper First solved from july 2016 to June 2013
Cbse ugc net paper First solved from july 2016 to June 2013Cbse ugc net paper First solved from july 2016 to June 2013
Cbse ugc net paper First solved from july 2016 to June 2013
 
Holistic Approach for Arabic Word Recognition
Holistic Approach for Arabic Word RecognitionHolistic Approach for Arabic Word Recognition
Holistic Approach for Arabic Word Recognition
 
Summarize of CS course guidebook
Summarize of CS course guidebookSummarize of CS course guidebook
Summarize of CS course guidebook
 
Assign1
Assign1Assign1
Assign1
 
IIT JEE Seat Allocation System
IIT JEE Seat Allocation System IIT JEE Seat Allocation System
IIT JEE Seat Allocation System
 
banking Coaching Institute in Delhi, Janakpuri
banking Coaching Institute in Delhi, Janakpuribanking Coaching Institute in Delhi, Janakpuri
banking Coaching Institute in Delhi, Janakpuri
 
An Automatic Question Paper Generation : Using Bloom's Taxonomy
An Automatic Question Paper Generation : Using Bloom's   TaxonomyAn Automatic Question Paper Generation : Using Bloom's   Taxonomy
An Automatic Question Paper Generation : Using Bloom's Taxonomy
 
Question Classification using Semantic, Syntactic and Lexical features
Question Classification using Semantic, Syntactic and Lexical featuresQuestion Classification using Semantic, Syntactic and Lexical features
Question Classification using Semantic, Syntactic and Lexical features
 
Banking Exam coaching in Delhi, Janakpuri
Banking Exam coaching in Delhi, JanakpuriBanking Exam coaching in Delhi, Janakpuri
Banking Exam coaching in Delhi, Janakpuri
 
5315Syll2015Fall
5315Syll2015Fall5315Syll2015Fall
5315Syll2015Fall
 
Apperson benchmark tm 3000
Apperson benchmark tm 3000Apperson benchmark tm 3000
Apperson benchmark tm 3000
 
17515
1751517515
17515
 
ANALYZING THE EFFICIENT TEST ORDER FOR INTEGRATION TESTING
ANALYZING THE EFFICIENT TEST ORDER FOR INTEGRATION TESTINGANALYZING THE EFFICIENT TEST ORDER FOR INTEGRATION TESTING
ANALYZING THE EFFICIENT TEST ORDER FOR INTEGRATION TESTING
 

Similar to Cs141 mid termexam v1

Cs141 mid termexam2_fall2017_v1.1
Cs141 mid termexam2_fall2017_v1.1Cs141 mid termexam2_fall2017_v1.1
Cs141 mid termexam2_fall2017_v1.1
Fahadaio
 
Examf cs-cs141-2-17
Examf cs-cs141-2-17Examf cs-cs141-2-17
Examf cs-cs141-2-17
Fahadaio
 
Cs141 mid termexam2_v1answer
Cs141 mid termexam2_v1answerCs141 mid termexam2_v1answer
Cs141 mid termexam2_v1answer
Fahadaio
 
E3
E3E3
E3
lksoo
 
Cs141 mid termexam2_fall2017_v1.1_solution
Cs141 mid termexam2_fall2017_v1.1_solutionCs141 mid termexam2_fall2017_v1.1_solution
Cs141 mid termexam2_fall2017_v1.1_solution
Fahadaio
 
Oop december 2018
Oop december 2018Oop december 2018
Oop december 2018
ktuonlinenotes
 
Cpcs 203 -array-problems
Cpcs 203 -array-problemsCpcs 203 -array-problems
Cpcs 203 -array-problems
MaherAalQasim
 
Conceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a ObjetosConceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a Objetos
guest22a621
 
Questões de Certificação SCJP
Questões de Certificação SCJPQuestões de Certificação SCJP
Questões de Certificação SCJP
José Maria Silveira Neto
 
Sample prac exam2013
Sample prac exam2013Sample prac exam2013
Sample prac exam2013hccit
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docx
rosemarybdodson23141
 
T1
T1T1
T1
lksoo
 
Student Name CourseCIS339Session (month, year)032019.docx
Student Name CourseCIS339Session (month, year)032019.docxStudent Name CourseCIS339Session (month, year)032019.docx
Student Name CourseCIS339Session (month, year)032019.docx
cpatriciarpatricia
 
Student Name Daniel RosadoCourseCIS339Session (month, ye.docx
Student Name Daniel RosadoCourseCIS339Session (month, ye.docxStudent Name Daniel RosadoCourseCIS339Session (month, ye.docx
Student Name Daniel RosadoCourseCIS339Session (month, ye.docx
emelyvalg9
 
Model questions-b.sc .csit-6th-sem
Model questions-b.sc .csit-6th-semModel questions-b.sc .csit-6th-sem
Model questions-b.sc .csit-6th-sem
NayanBakhadyo
 
BISH CS Modle Exit Exam.doc
BISH CS Modle Exit Exam.docBISH CS Modle Exit Exam.doc
BISH CS Modle Exit Exam.doc
AnimutGeremew3
 
PART - 1 Cpp programming Solved MCQ
PART - 1 Cpp programming Solved MCQPART - 1 Cpp programming Solved MCQ
PART - 1 Cpp programming Solved MCQ
Knowledge Center Computer
 
Programming fundamentals using c++ question paper 2014 tutorialsduniya
Programming fundamentals using c++  question paper 2014   tutorialsduniyaProgramming fundamentals using c++  question paper 2014   tutorialsduniya
Programming fundamentals using c++ question paper 2014 tutorialsduniya
TutorialsDuniya.com
 
Kality CS Model_Exit_Exams_with_answer - Copy (2).doc
Kality CS Model_Exit_Exams_with_answer - Copy (2).docKality CS Model_Exit_Exams_with_answer - Copy (2).doc
Kality CS Model_Exit_Exams_with_answer - Copy (2).doc
AnimutGeremew3
 

Similar to Cs141 mid termexam v1 (20)

Cs141 mid termexam2_fall2017_v1.1
Cs141 mid termexam2_fall2017_v1.1Cs141 mid termexam2_fall2017_v1.1
Cs141 mid termexam2_fall2017_v1.1
 
Examf cs-cs141-2-17
Examf cs-cs141-2-17Examf cs-cs141-2-17
Examf cs-cs141-2-17
 
Cs141 mid termexam2_v1answer
Cs141 mid termexam2_v1answerCs141 mid termexam2_v1answer
Cs141 mid termexam2_v1answer
 
E3
E3E3
E3
 
Cs141 mid termexam2_fall2017_v1.1_solution
Cs141 mid termexam2_fall2017_v1.1_solutionCs141 mid termexam2_fall2017_v1.1_solution
Cs141 mid termexam2_fall2017_v1.1_solution
 
Oop december 2018
Oop december 2018Oop december 2018
Oop december 2018
 
Cpcs 203 -array-problems
Cpcs 203 -array-problemsCpcs 203 -array-problems
Cpcs 203 -array-problems
 
Conceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a ObjetosConceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a Objetos
 
Questões de Certificação SCJP
Questões de Certificação SCJPQuestões de Certificação SCJP
Questões de Certificação SCJP
 
Sample prac exam2013
Sample prac exam2013Sample prac exam2013
Sample prac exam2013
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docx
 
T1
T1T1
T1
 
Sad -sample_paper
Sad  -sample_paperSad  -sample_paper
Sad -sample_paper
 
Student Name CourseCIS339Session (month, year)032019.docx
Student Name CourseCIS339Session (month, year)032019.docxStudent Name CourseCIS339Session (month, year)032019.docx
Student Name CourseCIS339Session (month, year)032019.docx
 
Student Name Daniel RosadoCourseCIS339Session (month, ye.docx
Student Name Daniel RosadoCourseCIS339Session (month, ye.docxStudent Name Daniel RosadoCourseCIS339Session (month, ye.docx
Student Name Daniel RosadoCourseCIS339Session (month, ye.docx
 
Model questions-b.sc .csit-6th-sem
Model questions-b.sc .csit-6th-semModel questions-b.sc .csit-6th-sem
Model questions-b.sc .csit-6th-sem
 
BISH CS Modle Exit Exam.doc
BISH CS Modle Exit Exam.docBISH CS Modle Exit Exam.doc
BISH CS Modle Exit Exam.doc
 
PART - 1 Cpp programming Solved MCQ
PART - 1 Cpp programming Solved MCQPART - 1 Cpp programming Solved MCQ
PART - 1 Cpp programming Solved MCQ
 
Programming fundamentals using c++ question paper 2014 tutorialsduniya
Programming fundamentals using c++  question paper 2014   tutorialsduniyaProgramming fundamentals using c++  question paper 2014   tutorialsduniya
Programming fundamentals using c++ question paper 2014 tutorialsduniya
 
Kality CS Model_Exit_Exams_with_answer - Copy (2).doc
Kality CS Model_Exit_Exams_with_answer - Copy (2).docKality CS Model_Exit_Exams_with_answer - Copy (2).doc
Kality CS Model_Exit_Exams_with_answer - Copy (2).doc
 

More from Fahadaio

Quiz2 cs141-1-17
Quiz2 cs141-1-17Quiz2 cs141-1-17
Quiz2 cs141-1-17
Fahadaio
 
Quiz1 cs141-1-17
Quiz1 cs141-1-17Quiz1 cs141-1-17
Quiz1 cs141-1-17
Fahadaio
 
Cs141 mid1-2017-fall-solution2
Cs141 mid1-2017-fall-solution2Cs141 mid1-2017-fall-solution2
Cs141 mid1-2017-fall-solution2
Fahadaio
 
Cs141 mid1-2017-fall v2
Cs141 mid1-2017-fall v2Cs141 mid1-2017-fall v2
Cs141 mid1-2017-fall v2
Fahadaio
 
Cs141 mid termexam2_v1
Cs141 mid termexam2_v1Cs141 mid termexam2_v1
Cs141 mid termexam2_v1
Fahadaio
 
Cs141 term project
Cs141 term projectCs141 term project
Cs141 term project
Fahadaio
 
Cs141 mid termexam v5_solution
Cs141 mid termexam v5_solutionCs141 mid termexam v5_solution
Cs141 mid termexam v5_solution
Fahadaio
 

More from Fahadaio (7)

Quiz2 cs141-1-17
Quiz2 cs141-1-17Quiz2 cs141-1-17
Quiz2 cs141-1-17
 
Quiz1 cs141-1-17
Quiz1 cs141-1-17Quiz1 cs141-1-17
Quiz1 cs141-1-17
 
Cs141 mid1-2017-fall-solution2
Cs141 mid1-2017-fall-solution2Cs141 mid1-2017-fall-solution2
Cs141 mid1-2017-fall-solution2
 
Cs141 mid1-2017-fall v2
Cs141 mid1-2017-fall v2Cs141 mid1-2017-fall v2
Cs141 mid1-2017-fall v2
 
Cs141 mid termexam2_v1
Cs141 mid termexam2_v1Cs141 mid termexam2_v1
Cs141 mid termexam2_v1
 
Cs141 term project
Cs141 term projectCs141 term project
Cs141 term project
 
Cs141 mid termexam v5_solution
Cs141 mid termexam v5_solutionCs141 mid termexam v5_solution
Cs141 mid termexam v5_solution
 

Recently uploaded

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 

Recently uploaded (20)

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 

Cs141 mid termexam v1

  • 1. Imam University | CCIS |Doc. No. 006-01-20141026 Page 1 of 10 Al Imam Mohammad Ibn Saud Islamic University College of Computer and Information Sciences Computer Science Department Course Title: Programming II Course Code: CS141 Course Instructor: Dr Abdulrahman Albarrak Dr. Qaisar Abbas, Dr Ashraf Shahin Exam: Midterm Semester: Fall 2016 Date: 22th Nov 2016 Duration: 90 Minutes Marks: 20 Privileges: ☐ Open Book ☐ Calculator Permitted ☐ Open Notes ☐ Laptop Permitted Student Name (in English): Student ID: Section No.: Instructions: 1.Answer all questions; there are 4 questions in 7 pages. 2.Write your name on each page of the exam paper. 3.Write your answers directly on the question sheets. Use the ends of the question pages for rough work or if you need extra space for your answer. 4.If information appears to be missing from a question, make a reasonable assumption, state your assumption, and proceed. 5.No questions will be answered by the invigilator(s) during the exam period. Official Use Only Question Student Marks Question Marks 1 4 2 3 3 3 4 10
  • 2. Imam University | CCIS |Doc. No. 006-01-20141026 Page 2 of 10 Total Student Name (in English): __________________________________________ Student ID: _____________________________ Question 1: To be answered in ( ___ ) Minutes [ ] / 4 Marks Select one or more appropriate options from multiple choice questions and try fill in the following box with your choice for each point. Note that if you did not find an appropriate answer then you can write your own answer with some reasons. Question 1 2 3 4 5 6 7 8 Answer 1. Which of the following is not true? (a) An interface can extend another interface. (b) A class which is implementing an interface must implement all the methods of the interface. (c) An interface can implement another interface. (d) An interface is a solution for multiple inheritance in java. (e) None of the above. 2. The fields in an interface are implicitly specified as, (a) static only (b) protected (c) private (d) both static and final (e) none of the above. 3. To prevent any method from overriding, we declare the method as, (a) static (b) const (c) final (d) abstract (e) none of the above. 4. Which one of the following is not true? (a) A class containing abstract methods is called an abstract class. (b) Abstract methods should be implemented in the derived class. (c) An abstract class cannot have non-abstract methods. (d) A class must be qualified as ‘abstract’ class, if it contains one abstract method. (e) None of the above. 5. Which statement is not true in java language?
  • 3. Imam University | CCIS |Doc. No. 006-01-20141026 Page 3 of 10 (a) A public member of a class can be accessed in all the packages. (b) A private member of a class cannot be accessed by the methods of the same class. (c) A private member of a class cannot be accessed from its derived class. (d) A protected member of a class can be accessed from its derived class. (e) None of the above. 6. Which of the following concepts means wrapping up of data and functions together? (a) Abstraction (b) Encapsulation (c) Inheritance (d) Polymorphism 7. Which of the following is correct about function overloading? (a) The types of arguments are different. (b) The order of argument is different. (c) The number of argument is same. (d) Both A and B. 8. How many instances of an abstract class can be created? (a) 1 (b) 5 (c) 13 (d) 0
  • 4. Imam University | CCIS |Doc. No. 006-01-20141026 Page 4 of 10 Student Name (in English): __________________________________________ Student ID: _____________________________ Question 2: To be answered in ( ___ ) Minutes [ ] / 3 Marks Let be the following code: There are three mistakes in this code. Please find those mistakes and make the code error free. Write the line number and clearly specify the problem. Line No Error Correction 1. abstractclassEx { 2. static intx=2; 4. public abstractvoid set(inta); 5. public abstractvoid print(); 6. public static intgetX() 7. {return this.x;} 8. } 9. class Ex1 extends Ex { 10. privateint y; 11. public Ex1() 12. { y=3; } 13. public void print() 14. { System.out.println(y); } 15. } 16. classEx2 extends Ex1 { 17. privateint z; 18. public Ex2() 19. { z=5; } 20. @Override 21. public void set(int a) 22. {z=a; } 23. public int get() 24. {return z; } 25. public void print() 26. { 27. super.print(); 28. System.out.println(z); 29. } 30. } 31. classExRun { 32. public static void main (String[] args){ 33. Ex a=new Ex1(); 34. Ex b=new Ex2(); 35. if( b instanceof Ex2) 36. { System.out.println( ((Ex2)b).get()); } 37. } 38. }
  • 5. Imam University | CCIS |Doc. No. 006-01-20141026 Page 5 of 10 Student Name (in English): __________________________________________ Student ID: _____________________________ Question 3: To be answered in ( ___ ) Minutes [ ] / 3 Marks Provide the output(s) of the following code segments and fill in the following box with outputs for each point. Question 1 2 3 outputs (1) class Test1 { public inta; public Test1() { a=5; print(); } public void print() {System.out.println(a);} } class Testextends Test1{ public intb; public Test() { b=3; } @Override public void print() {System.out.println( b);} } class RunTest{ public static void main (String[] args){ Test1 e=new Test() ; } } (2) class Test1 { public static intcount=2; int x=5; public Test1() { x++;
  • 6. Imam University | CCIS |Doc. No. 006-01-20141026 Page 6 of 10 count+=x; } public intgetCount() { return this.count; } } public classTest{ public static void main(String[] args) { Test1 a; Test1 b=new Test1(); Test1 c=new Test1(); System.out.println(b.getCount()); } } (3) class Ex { privateint x; public Ex() { x=2;} public void print() { System.out.println( x);} } class Ex1 extends Ex{ privateint y; public Ex1() { y=5; } @Override public void print() { System.out.println( y);} } class ExRun { public static void main (String[] args){ Ex a=new Ex1(); a.print(); } }
  • 7. Imam University | CCIS |Doc. No. 006-01-20141026 Page 7 of 10 Student Name (in English): __________________________________________ Student ID: _____________________________ Question 4: To be answered in ( ___ ) Minutes [ ] / 10 Marks A new medical staff management system is created for a small hospital. In this system, the medical staff are of three types: (i) doctor, (ii) nurse and (iii) therapist. Each medical staff has the following attributes: a name (type String), joined Date (type Date), a social security number (type int) and education (type String). These attributes are fixed once they added to the system. For each doctor we need to consider the specialty (String), rank (String), department(String). For each nurse, a ward number (type int), type(String), Skills (String), role(String) are taken into consideration. For a therapist, treatment Type (String), skills(String), function(String) are stored. We need to know the number of staff in the hospital and we need to know the number of staff for each type. (a) Write the needed abstract and concrete classes to represent the system. For each class provide a toString method that returns a String representation of an object of the class with its attributes and the attributes of its superclass (5 points). (b) Declare the Test class that contains public static void main(String[] args). In the main take the number of staff to be added to the system and for each staff allow the user to select the type of staff (Doctor, Nurse, Therapist) to be add to the system (use switch). The program should be implemented using polymorphism (demonstrating polymorphic behavior when dealing with staff). Once you have added all the staff print the number of all staff and the number of staff in each type. Write a loop to print all the staff information (call to String (5 points). .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... ..........................................................................................................................................
  • 8. Imam University | CCIS |Doc. No. 006-01-20141026 Page 8 of 10 .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... ..........................................................................................................................................
  • 9. Imam University | CCIS |Doc. No. 006-01-20141026 Page 9 of 10 .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... .......................................................................................................................................... ..........................................................................................................................................
  • 10. Imam University | CCIS |Doc. No. 006-01-20141026 Page 10 of 10 .......................................................................................................................................... .......................................................................................................................................... ..........................................................................................................................................