Do not turn over this examination paper until instructed to do so. Answer all questions.

Similar documents
Do not turn over this examination paper until instructed to do so. Answer all questions.

Darrell Bethea June 6, 2011

JAVA MOCK TEST JAVA MOCK TEST II

Distributed Systems Recitation 1. Tamim Jabban

University of Massachusetts Amherst, Electrical and Computer Engineering

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

CMSC 132: Object-Oriented Programming II. Inheritance

Distributed Systems Recitation 1. Tamim Jabban

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. CMPUT 102: Inheritance Dr. Osmar R. Zaïane. University of Alberta 4

An OBJECT contains VARIABLES = PROPERTIES and METHODS = BEHAVIORS. Outline the general nature of an object.

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

COMP1008 Object-Oriented Programming 2005 Exam 2.5 Hours

1) Consider the following code segment, applied to list, an ArrayList of Integer values.

Objects as a programming concept

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010

Classes and Objects. CGS 3416 Spring 2018

Programming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017

Object Oriented Programming with Java

APCS Semester #1 Final Exam Practice Problems

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 1

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance

Lecture 15: Inheritance II

CS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012

Create a Java project named week10

C08: Inheritance and Polymorphism

Announcements. Final exam. Course evaluations. Saturday Dec 15 10:20 am -- 12:20 pm Room: TBA

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ June Exam

Abstract class & Interface

CS 61B, Spring 1999 MT3 Professor M. Clancy

Comp Intermediate Programming EXAM #1 February 16, 2004 Rice University - Instructors: Cox & Nguyen

Introduction to Programming Using Java (98-388)

CS 2102 Exam 2 D-Term 2013

Week 11: Class Design

CMSC 341 Lecture 7 Lists

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University

Informatik II. Tutorial 6. Mihai Bâce Mihai Bâce. April 5,

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015

UML IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

1B1b Classes in Java Part I

PROGRESS BOOK PARENT ACCESS NAVIGATION

Computer Science First Exams Pseudocode Standard Data Structures Examples of Pseudocode

Python Class Definition. Java Class Definition. Python Class Use public class Student { Java Class Use. Python Class Definition 10/6/2016

Pittsburgh Public Schools

Informatik II Tutorial 6. Subho Shankar Basu

Comp151. Inheritance: Introduction

MYBATIS - ANNOTATIONS

WES-CS GROUP MEETING #9

IUE Faculty of Engineering and Computer Sciences Spring Semester

Tutorial 6 CSC 201. Java Programming Concepts مبادئ الربجمة باستخدام اجلافا

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

PowerTeacher Classroom Management Tool Quick Reference Card

Last Name: Circle One: OCW Non-OCW

Tutorial 12. Exercise 1: Exercise 2: CSC111 Computer Programming I

Chapter 4 Defining Classes I

CIS 110: Introduction to computer programming

a) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable.

Inheritance, and Polymorphism.

Chapter 13. Inheritance and Polymorphism. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Csci 102: Sample Exam

Scheduling Process for Elementary Schools PowerSchool Student Information System

Sample Examination Paper Programming and Software Development

1.00/1.001 Introduction to Computers and Engineering Problem Solving. Final Exam

SYSC Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

C08: Inheritance and Polymorphism

CSE 131 Introduction to Computer Science Fall Exam I

Parent. Access. Manual

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

Multiple Inheritance and Object Layout in C++

CIS 110 Introduction to Computer Programming Summer 2018 Final. Recitation # (e.g., 201):

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Week 5-1: ADT Design

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Goals for Today. CSE1030 Introduction to Computer Science II. CSE1030 Lecture #9. Review is-a versus has-a. Lecture #9 Inheritance I

CS 1316 Exam 1 Summer 2009

BEng (Hons) Electronic Engineering. BEng (Hons) Telecommunications. Examinations for / Semester 2

16. Give a detailed algorithm for making a peanut butter and jelly sandwich.

CSC207 Quiz 1 Solutions Monday 6 February 2017, 12:15 PM. 1. (A) (B) (C) (D) (E) 7. Nothing, does not run true false

Programming II (CS300)

Inheritance: Single level inheritance:

CIS3023: Programming Fundamentals for CIS Majors II Summer 2010

Instructions PLEASE READ (notice bold and underlined phrases)

Informatik II (D-ITET) Tutorial 6

Midterm Exam 2 CS 455, Spring 2011

Model Solutions. COMP 103: Test May, 2013

York University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes

Programming II (CS300)

TREES. Tree Overview 9/28/16. Prelim 1 tonight! Important Announcements. Tree terminology. Binary trees were in A1!

Exam Duration: 2hrs and 30min Software Design

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Inheritance and Interfaces

Creating a Parent Portal Account

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

EXAMINATION FOR THE DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 2

Classes. Brahm Capoor

Topic 7: Inheritance. Reading: JBD Sections CMPS 12A Winter 2009 UCSC

CO Java SE 8: Fundamentals

Highlights of Last Week

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming

Java Software Solutions for AP Computer Science 3rd Edition, Lewis et al. 2011

ONLINE CLASSROOM

Transcription:

IB Computer Science SL Paper 2 - Mock Exam - Dec 2013 (1/6) COMPUTER SCIENCE STANDARD LEVEL PAPER 2 MOCK EXAM 1 hour INSTRUCTIONS TO CANDIDATES Do not turn over this examination paper until instructed to do so. Answer all questions.

IB Computer Science SL Paper 2 - Mock Exam - Dec 2013 (2/6) Option D - Java and Object Oriented Programming System Overview A school maintains a CONTACTS database of contact information. This is used to send e-mails and/or make phone calls to students, teachers and parents. By using this database, the school can do all of the following more efficiently: - send emails to large groups, like "all parents" or "all grade 12 students" or "Upper School teachers" - quickly look up a phone number to contact parents in an emergency like an injured child - teachers can contact students in their classes - students and their parents can contact specific teachers The database has a user-friendly GUI interface, allowing administrative staff to add and edit data, as well as allowing all users (parents, teachers and students) to look up contact information. Objects There are several objects in the CONTACTS database: Object Person Student Parent Teacher List LinkedList Description A base class for any person : name, phone, email address, ID (a unique integer) Any student enrolled at school : [Person] + grade, homeroom teacher Any parent of a student : [Person] + business phone, business email A teacher working at school : [Person] + class room phone, homeroom grade A list of Objects - could be a list of Students or Parents or Teachers or any mixture of these Objects Phone Numbers The phone field contains the home phone number, as a complete phone number like "603-1234". The business phone is also a complete phone number, e.g. "987-6543" The classroom phone is a 3 digit internal extension, like "276" - this only works inside the school.

IB Computer Science SL Paper 2 - Mock Exam - Dec 2013 (3/6) Code Part of the code for each Class is shown below. The code may be incomplete in places where the information is not needed for this exam, or where the code must be completed as part of the exam. public class Person private String name = ""; private String phone = ""; private String email = ""; private int ID = 0; public Person() public Person(String n, String p, String e, int i) setname(n); setphone(p); setemail(e); setid(i); public void setname(string n) name = n; public void setphone(string p) phone = p; public void setemail(string e) if(checkemail(e) == true) email = e; else email = ""; public void setid(int i) ID = i; public String getname() return name; public String getphone() return phone; public String getemail() return email; public int getid() return ID; public boolean checkemail(string e) if( e.indexof('@') > 0 ) return true; else return false; // find @ sign

IB Computer Science SL Paper 2 - Mock Exam - Dec 2013 (4/6) public class Student extends Person private int grade = 0; private String homeroom = ""; public Student(String n, String e, String p, int i, int g, String h) setname(n); setemail(e); setphone(p); setid(i); setgrade(g); sethomeroom(h); public void setgrade(int g) if(g > 0 && g < 13) grade = g; public void sethomeroom(string h) homeroom = h; public int getgrade() return grade; public String gethomeroom() return homeroom; public class Teacher extends Person private int grade = 0; private String homeroomphone = ""; public Teacher(String n, String e, String p, int i, int g, String hp) setname(n); setemail(e); setphone(p); setid(i); setgrade(g); sethomeroomphone(hp); public void setgrade(int g) if(g > 0 && g < 13) grade = g; public void sethomeroomphone(string hp) homeroomphone = hp; public int getgrade() return grade; public String gethomeroom() return homeroomphone;

IB Computer Science SL Paper 2 - Mock Exam - Dec 2013 (5/6) #1 (a) Explain what a constructor method is, including a specific example chosen from the code on the previous pages, as well as a brief explanation of how and when the constructor functions. (b) Explain what data validation code is, and state a specific example that occurs in the code on the previous pages. (c) Explain the term encapsulation, making specific reference to the sample code on the previous pages. Include an explanation of the connection between private data members and set methods. (d) Construct the Parent class, written in Java, including all appropriate get methods, set methods, and properties (variables). You do NOT need to write any validation code. [3 marks] [2 marks] [4 marks] [6 marks] ===================================================== The diagram above shows the QuickMessage interface. It contains a list with the names of all the Students in the school, a list with all the Parents, and a list with all the Teachers. The user can click on Students, Parents and/or Teachers, thus copying the names (and the corresponding Objects) into the SEND TO box. When the user clicks the [Send] button, an email is sent automatically to all the people in the SEND TO box. Here is some of the code in the QuickMessage classk (this code is incomplete): public QuickMessage() students = load("students"); parents = load("parents"); teachers = load("teachers"); display(students); display(parents); display(teachers); // loads Student objects into students LinkedList // loads Parent objects into parents LinkedList // loads Teacher objects into teachers LinkedList // displays the LinkedLists into GUI List boxes // == The "load" and "display" methods are not shown here, but appear below ==//

IB Computer Science SL Paper 2 - Mock Exam - Dec 2013 (6/6) When the user clicks the [Send] button, the following method sends emails: //== before running sendemails, the LinkedList sendto must contain ==/ //== numerous Person, Student, Parent and/or Teacher Objects ==/ //== and message must contain text to be sent in the email ==/ public void sendemails(linkedlist sendto, String message) Iterator it = sendto.iterator(); while(it.hasnext()) Person p = (Person)it.next(); sendmail( p, message); //== The sendmail method appears below, but is not shown here ==// #2 (a) Outline two major differences between a LinkedList and an Array in Java. (b) Construct a method that searches through the students LinkedList, finds a specific name, and outputs the corresponding email address. You must write your solution in Java. [3 marks] [5 marks] (c) Construct a method that searches through the students LinkedList for all the students who are in grade 12. Whenever it finds a grade 12 student, it adds that object to the sendto LinkedList. Write your solution in Java. [7 marks] ========================================================= #3 (a) Explain what the term inheritance means in Object Oriented Programming, including a specific example where inheritance is used in the CONTACTS system. (b) Outline how the use of inheritance makes it easier when programmers are expanding an application to add more features. [3 marks] [2 marks] (c) The Person class contains error-prevention code in the checkemail method. This prevents accidental errors when entering an email address. This method is actually too simple. It should also check more rules. Every email address must: - contain exactly one '@' sign - after the '@' sign, there must be exactly one period '.' - there must be at least 2 characters between the '@' and the '.' period. - there must be at least 3 characters after the '.' period - there must be at least 3 characters before the '@' sign Using standard Java String methods, construct an improved checkemail method that checks all the rules stated above. [10 marks]