King Saud University College of Computer and Information Sciences Computer Science Department

Similar documents
King Saud University College of Computer and Information Sciences Computer Science Department

King Saud University College of Computer and Information Sciences Computer Science Department

Student Name:.. Student ID... Course Code: CSC 227 Course Title: Semester: Fall Exercises Cover Sheet:

BS in Computer Science Outcome Set (CAC/ABET)

Introduction to the Java Basics: Control Flow Statements

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

CSET 3400 Unix System Administration (3 semester credit hours) IT Elective

Notes - Recursion. A geeky definition of recursion is as follows: Recursion see Recursion.

School of Engineering & Computational Sciences

CSCI 201L Syllabus Principles of Software Development Spring 2018

CSET 4150 Web System Administration (3 semester credit hours) IT Required

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007

ESC101 : Fundamental of Computing

AP Computer Science A Summer Assignment 2017

CRITERIA FOR ACCREDITING COMPUTING PROGRAMS

Ryerson University Vers HAL6891A-05 School of Computer Science CPS109 Midterm Test Fall 05 page 1 of 6

Washington State University School of EECS Computer Science Course Assessment Report

Object- Oriented Analysis, Design and Programming

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

COMPUTER SCIENCE (CSCI)

School of Engineering and Computational Sciences

Comp 170 Test 1 SAMPLE June 8, 2000

Loops. CSE 114, Computer Science 1 Stony Brook University

Instance Method Development Demo

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CSEN 202: Introduction to Computer Programming Spring term Final Exam

e) Implicit and Explicit Type Conversion Pg 328 j) Types of errors Pg 371

Page 1 / 3. Page 2 / 18. Page 3 / 8. Page 4 / 21. Page 5 / 15. Page 6 / 20. Page 7 / 15. Total / 100. Pledge:

ITE 205 Software Design and Programming I

Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue

10/30/2010. Introduction to Control Statements. The if and if-else Statements (cont.) Principal forms: JAVA CONTROL STATEMENTS SELECTION STATEMENTS

CS 101 Exam 2 Spring Id Name

Object-oriented Programming and Software Engineering CITS1001. Multiple-choice Mid-semester Test

COMPUTER SCIENCE AND ENGINEERING (CSEG)

Computer Science is...

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

Computer Programming, I. Laboratory Manual. Final Exam Solution

Objectives: Lab Exercise 1 Part 1. Sample Run. Part 2

Code Analysis Sample Questions

Release Date:!4/12/1434 H (Wed 9/10/2013) Due Date:!! 18/12/1434 H (Wed 23/10/2013)

CS 177 Week 5 Recitation Slides. Loops

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam

Academic Program Plan for Assessment of Student Learning Outcomes The University of New Mexico

Principles of Object Oriented Programming. Lecture 4

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

COS 126 Midterm 1 Written Exam Fall 2011

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

CSE 1223: Exam II Autumn 2016

Principles of Computer Science

Repe$$on CSC 121 Fall 2015 Howard Rosenthal

i.e.: n! = n (n 1)

1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005

Lab Exercise 1. Objectives: Part 1. Introduction

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

CIS 110 Introduction to Computer Programming Fall 2017 Midterm. Recitation ROOM :

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2013

PELLISSIPPI STATE COMMUNITY COLLEGE MASTER SYLLABUS ROUTING/SWITCH CONFIGURATION CSIT 2750

المملكة العربية السعودية وزارة التعليم العالى

CAT.woa/wa/assignments/eclipse

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

CSCI 6312 Advanced Internet Programming

Loops and Expression Types

CSCI 212 Practice Final Exam Summer Instructor: Krishna Mahavadi

CS 177 Spring 2010 Exam I

COMP 401 Fall 2014 Midterm 2

ITEC1620 Object-Based Programming. Lecture 13

Department of Networks College of Bardarash Technical Institute DUHOK Polytechnic University Subject: Programming Fundamental by JAVA Course Book

Claremont McKenna College Computer Science

COS 126 Midterm 1 Written Exam, Fall 2009

McGill University School of Computer Science COMP-202A Introduction to Computing 1

Web-CAT submission URL: CAT.woa/wa/assignments/eclipse

CSCI 1226 Sample Midterm Exam

SUN Upgrade for the Sun Certified Java Programmer. SE 6.0. Download Full Version :

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

Name:... ID:... class A { public A() { System.out.println( "The default constructor of A is invoked"); } }

PASS4TEST IT 인증시험덤프전문사이트

CS 177 Spring 2009 Exam I

Repe$$on CSC 121 Spring 2017 Howard Rosenthal

CSE 11 Midterm Fall 2008

6 COMPUTER PROGRAMMING

COE 212 Engineering Programming. Welcome to the Final Exam Tuesday December 15, 2015

Control Structures: if and while A C S L E C T U R E 4

BSc (Hons) Computer Science with Network Security/ BSc (Hons) Software Engineering/ BSc (Hons) Web Technologies. Examinations for 2016 Semester 1

STUDENT LESSON A12 Iterations

Question: Total Points: Score:

CSci 1113 Midterm 1. Name: Student ID:

TA office hours are over after this week, but Dan and Maja will still be around for the next month

COE 212 Engineering Programming. Welcome to Exam II Thursday April 21, Instructors: Dr. Salim Haddad Dr. Joe Tekli Dr. Wissam F.

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

COMP 401 Fall 2014 Midterm 2

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions

BSc. (Hons.) Software Engineering. Examinations for / Semester 2

SULTAN QABOOS UNIVERSITY COURSE OUTLINE PROGRAM: B.Sc. in Computer Science. Laboratory (Practical) Field or Work Placement

CS 170 Exam 2. Version: A Spring Name (as in OPUS) (print): Instructions:

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

CS100B: Prelim 3 Solutions November 16, :30 PM 9:00 PM

Question: Total Points: Score:

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

Transcription:

King Saud University College of Computer and Information Sciences Computer Science Department Course Code: CSC 111 Course Title: Introduction to Programming Semester: Fall 2015 Exercises Cov er Sheet: Mid 2 Exam - A Duration: 90 min Student Name: Student ID: Student Section No. Tick the Relev ant Computer Science B.Sc. Program ABET Student Outcomes Question No. Relevant Is Hyperlinked Cov ering % a) Apply knowledge of computing and mathematics appropriate to the discipline; 1 50% b) Analyze a problem, and identify and define the computing requirements appropriate to its solution; c) Design, implement and evaluate a computer-based system, process, component, or program to meet desired needs; d) Function effectively on teams to accomplish a common goal; e) Understanding of professional, ethical, legal, security, and social issues and responsibilities; f) Communicate effectively with a range of audiences; g) Analyze the local and global impact of computing on individuals, organizations and society; h) Recognition of the need for, and an ability to engage in, continuing professional development; i) Use current techniques, skills, and tools necessary for computing practices. 2,3 50% j) Apply mathematical foundations, algorithmic principles, and computer science theory in the modeling and design of computer-based systems in a way that demonstrates comprehension of the tradeoffs involved in design choices; k) Apply design and development principles in the construction of software systems of varying complexity;

Important Notes: - Cheating is prohibited! Looking at your colleague s paper will get you an F in the course immediately! - Turn OFF your Phone/s. If you take out your phone for ANY reason, you will get an F in the course immediately! مالحظات هامة الغش ممنوع! عند النظر إلى ورقة زميلك سترسب في المادة مباشرة! - أغلق كان جوالك / جواالتك!عند إخراجك سترسب في المادة مباشرة سبب ألي للجوال

Q uestion 1 (3 Marks) Put your answer of the question 1 (multiple choice questions) in the following table. Note: Student is allowed 2 wrong choices with no penalty. After that, for each wrong choice he loses half a point: Question Answer 1 2 3 4 5 6 1. (0.5 mark) What is the output of the following code segment, if any? int result = 0; for(int i = 0; i < 3; i++) for(int j = 3; j > 0; j--) result = result + i*j; System.out.println(result); A. 18 B. 24 C. 36 D. There is a compilation error. E. Infinite loop.

2. (0.5 mark) Assume that you have the following class: public class Test { public int number; public void writeoutput() { int number = 3; number = this.number - number * this.number; System.out.println(number); Now, assume that you defined an object of the class above and used it in your program, as such: public class TestMain { public static void main(string[] args) { Test t1 = new Test(); t1.number = 10; t1.writeoutput(); What is the output of the program? A. 3 B. 10 C. -6 D. -20 E. -90 3. (0.5 mark) What is the output of this code fragment, if any? int x = 10; do{ int y = x / 2; if(y + 10 > x) x = x + 10; while(x < 50) System.out.println(" x = " + x); A. x = 10 B. x = 60 C. x = 100 D. There is a compilation error. E. Infinite loop. 4. (0.5 mark) What is the output of this code fragment, if any? int n = 0; /* Line 1*/ while(n < 3) /* Line 3*/ { int m = 1; if((n - m) % 2 == 0) n+=1;m-=1; /* Line 6*/ System.out.println("n=" + n + ",m=" + m); /* Line 8*/ A. n=3,m=-4 B. n=3,m=-3 C. Infinite loop. D. There is a compilation error in line 6. E. There is a compilation error in line 8.

5. (0.5 mark) Assume that you have the following cl ass: public class Test { public int i; public boolean b; public String st; Now, assume that you defined an object of the class above and used it in your program, as such: public class TestMain { public static void main(string args[]) { Test t = new Test(); System.out.println( i= + t.i); System.out.println( b= + t.b); System.out.println( string= + t.st); What is the output of the program? A. There is a compilation error. B. i=0, b=false, string=null C. i=0, b=0, string=0 D. i=none, b=none string=none E. There is a run time error. 6. (0.5 mark) You read the following statement in a Java program that compiles and executes. customer.buy(intvariable); What can you say for sure? A. intvariable must be an int. B. buy must be the name of an instance variable. C. buy must be a method. D. customer must be the name of a class. E. customer must be a method.

Q uestion 2 (2 marks) Assuming that a year has 12 months and each month has exactly 30 days, complete the following two methods increment() and decrement() in class Date such that they increment/decrement the date by one day note1: year, month and day cannot have a value of zero. If this happens, the object should return to its original state (i.e., you cancel or rollback the change to the date object). note2: Each blank should have only ONE java statement or expression. public class Date { private int day; private int month; private int year; public void increment(){ day++; if( ){ month++; if(month>12){ public void decrement(){ if(day!=1) else{ day--; day = if( ) else{ month--; if(year==0){ System.out.println("Error!!!");

Question 3 (5 Marks) Given the following class answer the questions below: class Q2 { private int a; private int b; private int c; public void seta(int a){this.a = a; public void setb(int b){this.b = b; public void setc(int c){this.c = c; public int geta(){return a; public int getb(){return b; public int getc(){return c; public int m1(int a, int b){ for (int i = 0; i < 5; i++){ a++; b++; return a + b; public boolean m2(int x, int y){ a = x + 1; b = y / 2; return m1(a, b) + x + y - a - b < c; A- (1 mark) Suppose we run the code: Q2 obj = new Q2(); obj.seta(1); obj.setb(2); obj.setc(3); int x = obj.m1(1,1); what will be the value of x, obj.a, obj.b, obj.c? x:... obj.a:... obj.b:... obj.c:... B- (1 mark) Suppose we run the code: Q2 obj = new Q2(); obj.seta(1); obj.setb(2); obj.setc(3); boolean b = obj.m2(1,1); what will be the value of b, obj.a, obj.b, obj.c? b:... obj.a:... obj.b:... obj.c:...

C- (3 marks) What is the output of the main method in the following class TestQ2? public class TestQ2 { public static void main(string args[]){ Q2 obj1 = new Q2(); Q2 obj2 = new Q2(); obj1.seta(0); obj1.setb(0); obj1.setc(10); obj2 = obj1; obj2.seta(4); obj2.setb(5); obj2.setc(-1); while(!obj1.m2(1, 3)){ System.out.println("obj1.a = " + obj1.geta()); System.out.println("obj1.b = " + obj1.getb()); System.out.println("obj1.c = " + obj1.getc()); obj2.setc(obj2.getc() + 10); System.out.println("obj2.a = " + obj2.geta()); System.out.println("obj2.b = " + obj2.getb()); System.out.println("obj2.c = " + obj2.getc());

Result Question No. Relevant Student Outcome SO is Covered by % Full Mark Student Mark Assessor s Feedback 1 a 30 3 2 i 20 2 3 i 50 5 Totals 100% 10 I certify that the work contained within this assignment is all my own work and referenced where required. Feedback Received: Student Signature: Date: Student Signature: Date: