UNIVERSITY OF THE FREE STATE MAIN CAMPUS CSIS2614 DEPARTMENT: COMPUTER SCIENCE AND INFORMATICS CONTACT NUMBER:
|
|
- Brianne James
- 5 years ago
- Views:
Transcription
1 UNIVERSITY OF THE FREE STATE MAIN CAMPUS CSIS2614 DEPARTMENT: COMPUTER SCIENCE AND INFORMATICS CONTACT NUMBER: EXAMINATION: Additional Half Year Examination 2016 ASSESSORS: Prof. P.J. Blignaut MODERATOR: Dr. T. Beelders TIME: 4 hours MARKS: 100 (+ 3 bonus marks) This is an open-book test. You may use ONLY the text book by Nakov. No other sources are allowed. Internet access will not be available for the duration of the assessment. You may use the tools available in Visual Studio such as IntelliSense. No mobile computing devices may be active for the duration of the assessment (Mobile phones, tablets, etc). Question 1 (Operator overloading) Develop a class that can be used to encapsulate operations with hexadecimal numbers. (1) 1.1 The class must have a private string field for the hexadecimal number. (1) 1.2 The constructor will assign a value to the private data field through a parameter. (2) 1.3 Override the ToString method to return the private data field. (2) 1.4 Provide a public method that will return the equivalent integer value. A hexadecimal number can be converted to its integer equivalent through the method Convert.ToInt32(string value, int frombase). (2) 1.5 Provide a static method to return the hexadecimal equivalent of an integer value. An integer can be converted to hex through the ToString("X") method. (2) 1.6 Provide a static operation for the hexadecimal + operator. (6) [16] You may test your class with the following Main() method: static void Main(string[] args) Hex Number1 = new Hex("2F"); Console.WriteLine(Number1 + "h = " + Number1.ToInt().ToString()); int inumber2 = 35; Console.WriteLine(iNumber2 + " = " + Hex.IntToHex(iNumber2) + "h"); Hex h1 = new Hex("F"); Hex h2 = new Hex("20"); Hex h3 = h1 + h2; Console.WriteLine(h1 + " + " + h2 + " = " + h3); Console.Write("Press any key to exit..."); Console.ReadKey(); 1
2 Question 2 (Delegates and events) Consider the partial implementation of a console application to display the area and perimeter of circles with varying radius. //2.1 Declare delegate... //2.2.1 Method to calculate the area of a circle with radius r private static... return Math.PI * r * r; //2.2.2 Method to calculate the perimeter of a circle with radius r private static... return 2 * Math.PI * r; //2.4 Method to write the property, radius and value of the specified property private static void Write(... Console.WriteLine(sCaption + "\t" + x.tostring() + "\t" + String.Format("0,6:F2", F(x))); static void Main(string[] args) //2.3 Instantiate instances of the delegate delfunction A =... delfunction P =... double[] radii = 2, 3, 2.3, 4.5, 6.7 ; Console.WriteLine("Property r Value"); Console.WriteLine("======== === ====="); foreach (double r in radii) Write("Area ", A, r); Write("Perimeter", P, r); Console.WriteLine(); Console.Write("Press any key to exit..."); Console.ReadLine(); //Main 2.1 Declare a delegate to define the signature of a method that will take a double parameter and return a double value. (3) 2.2 Complete the headers of the two methods to calculate the area and perimeter of a circle, given the radius as parameter. (4) 2.3 Complete the code to instantiate two instances of the delegate one to calculate the area of the circle and the other to calculate the perimeter. (4) 2.4 Complete the signature of the Write method. (3) [14] 2
3 Question 3 (Lists, Stacks and Queues) Consider the following partial implementation of a linked stack data structure. public interface IContainer<T> void MakeEmpty(); bool IsEmpty(); int Size(); public interface IStack<T> : IContainer<T> void Push(T data); void Pop(); T Top(); class CStack<T> : IStack<T> //Internal class private class Node public T Data get; set; public Node Next get; set; public Node(T data) Data = data; //class Node // Fields private Node top; private int numberelements; //Implementation of method in IContainer public void MakeEmpty() top = null; //Implementation of method in IContainer public int Size() return numberelements; //Implementation of method in IContainer public bool IsEmpty() return numberelements == 0; //3.1 Implementation of method in IStack //3.2 Implementation of method in IStack //3.3 Implementation of method in IStack // class LinkedStack<T> 3
4 Complete the code for the 3.1 Push() (8) 3.2 Pop() and (8) 3.3 Top() methods. (6) [22] Test your program with the following Main() method: static void Main(string[] args) CStack<int> Stack = new CStack<int>(); Console.WriteLine("Pushing..."); for (int i = 0; i < 10; i++) Console.WriteLine(i.ToString()); Stack.Push(i); Console.WriteLine(""); Console.WriteLine("Popping..."); for (int i = 0; i < 10; i++) Console.WriteLine(Stack.Top().ToString()); Stack.Pop(); Console.WriteLine(""); Console.Write("Press any key to exit..."); Console.ReadKey(); Question 4 (Regular expressions) Develop a console application to enable the user to enter any string and then extract the date of birth of a person. The date of birth will be in the format dd MMMM yyyy as in: Long ago, on Sunday 31 July 1960, my mother had a boy. Use the following regular expression: \d1,2\s(january February March April May June July August September October November December)\s\d4 [8] Question 5 (Trees and Graphs) Consider the scenario of a security guard who has to patrol the university campus at nights. He has to visit specific points at regular intervals. You will be provided with a partial solution that includes the main method and a generic graph class. The point-to-point distances between the various inspection points are defined in the main method of the program as vertices with edges of specific weight. Complete the program to print all possible patrol routes that start at the control room and visit all inspection points. It is not necessary that the routes end at the control room again. The program should also identify the shortest possible patrol route. The last part of the expected output is shown below. [28] CSIS2614 Additional Half Year Examination 2016
5 5 Question 6 (Dictionaries and Hash tables) A user complained that built-in trigonometric functions in the Math class in.net are too slow for his purposes. A solution was then proposed that a large number of (angle, function value) pairs should be loaded beforehand into a dictionary so that the values are immediately available on request. An incomplete solution is provided that should allow the user to select a trigonometric function (sin, cos or tan) along with an angle in degrees. The program should then evaluate the selected function for the given angle. Complete the class Trig as indicated. [15]
6 6 MEMORANDUM Question 1 (16) class Hex private string Value; public Hex(string value) Value = value; public override string ToString() return Value; public int ToInt() return Convert.ToInt32(Value, 16); public static Hex IntToHex(int i) Hex h = new Hex(i.ToString("X")); return h; public static Hex operator +(Hex h1, Hex h2) int i = h1.toint() + h2.toint(); return IntToHex(i); //class
7 7 Question 2 (14) class Program 2.1 public delegate double delfunction(double r ); private static double Area(double r ) return Math.PI * r * r; private static double Perimeter(double r ) return 2 * Math.PI * r; 2.4 private static void Write(string scaption, delfunction F, double r ) Console.WriteLine(sCaption + "\t" + r.tostring() + "\t" + String.Format("0,6:F2", F(x))); static void Main(string[] args) 2.3 delfunction A = new delfunction(area); delfunction P = new delfunction(perimeter); double[] radii = 2, 3, 2.3, 4.5, 6.7 ; Console.WriteLine("Property r Value"); Console.WriteLine("======== === ====="); foreach (double r in radii) Write("Area ", A, r); Write("Perimeter", P, r); Console.WriteLine(); Console.Write("Press any key to exit..."); Console.ReadLine();
8 8 Question 3 (22) 3.1 public void Push(T data) Node newnode = new Node(data); newnode.next = top; top = newnode; numberelements++; 3.2 public void Pop() if (IsEmpty()) throw new InvalidOperationException("Cannot pop empty stack."); else Node oldnode = top; top = top.next; numberelements--; oldnode = null; //Pop 3.3 public T Top() if (IsEmpty()) throw new InvalidOperationException("Cannot access top of stack."); else return top.data; Question 4 (8) class Program static void Main(string[] args) string s = "Long ago, on Sunday 31 July 1960, my mother had a boy."; string re February March April May June July August" + " September October November December)\s\d4"; Regex reg = new Regex(re); Match match = reg.match(s); if (match.success) Console.WriteLine("DOB: " + s.substring(match.index, match.length)); Console.Write("Press any key to exit..."); Console.ReadKey(); //Main //class Program
9 9 Question 5 (28) private void GetPaths(string start, string u, string Path, int weight) foreach (Edge edge in lstedges.where(edge => edge.u == u &&!Path.Contains("'" + edge.v + "'") && edge.v!= start )) GetPaths(start, edge.v, Path + "'" + edge.v + "', ", weight + edge.w); lstpaths.add(path + "'" + edge.v + "'"); lstweights.add(weight + edge.w); //GetPaths private static void ShortestPatrol() List<string> lstpaths; List<int> lstweights; string shortestpath = ""; int minlength = int.maxvalue; graph.getpaths("cr", out lstpaths, out lstweights); for (int i = 0; i < lstpaths.count; i++) string[] paths = lstpaths[i].split(new char[] ',', ' ', StringSplitOptions.RemoveEmptyEntries); if (paths.length == graph.size-1) Console.WriteLine((i + 1).ToString().PadLeft(3) + ": " + lstpaths[i] + " (" + lstweights[i] + ")"); if (lstweights[i] < minlength) minlength = lstweights[i]; shortestpath = (i + 1).ToString().PadLeft(3) + ": " + lstpaths[i] + " (" + lstweights[i] + ")"; //for Console.WriteLine("Shortest patrol route: " + shortestpath); //ShortestPatrol
10 10 Question 6 (15) class Trig private static Dictionary<decimal, double> diccos, dicsin, dictan; public static void Prepare() diccos = new Dictionary<decimal, double>(); dicsin = new Dictionary<decimal, double>(); dictan = new Dictionary<decimal, double>(); for (decimal deg = -180; deg < 180; deg += 0.01m) double rad = (double)deg * Math.PI / 180; diccos[deg] = Math.Cos(rad); dicsin[deg] = Math.Sin(rad); dictan[deg] = Math.Tan(rad); //Prepare public static double Cos(decimal degrees) degrees = (int)(degrees * 100) / 100m; if (diccos.containskey(degrees)) return diccos[degrees]; else return 0; //Cos public static double Sin(decimal degrees) degrees = (int)(degrees * 100) / 100m; if (dicsin.containskey(degrees)) return dicsin[degrees]; else return 0; //Sin public static double Tan(decimal degrees) degrees = (int)(degrees * 100) / 100m; if (dictan.containskey(degrees)) return dictan[degrees]; else return 0; //Tan //class
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS 2614 MODULE TEST 2
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS 2614 MODULE TEST 2 DATE: 12 May 2017 TIME: 3 hours MARKS: 110 ASSESSORS: Prof. P. Blignaut & Mr. G. Dollman BONUS MARKS:
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS 2614 MODULE TEST 2
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS 2614 MODULE TEST 2 DATE: 13 May 2016 TIME: 3.5 hours MARKS: 112 ASSESSOR: Prof. P.J. Blignaut BONUS MARKS: 5 MODERATOR:
More informationAnswer the following questions on the answer sheet that is provided. The computer must be switched off while you are busy with Section A.
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 114 DATE: 25 April 2013 TIME: 180 minutes MARKS: 100 ASSESSORS: Prof. P.J. Blignaut & Mr. F. Radebe (+2 bonus marks) MODERATOR:
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 214 MODULE TEST 1
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 214 MODULE TEST 1 DATE: 12 March 2014 TIME: 4 hours MARKS: 220 ASSESSORS: Prof. P.J. Blignaut & Mr G.J. Dollman BONUS MARKS:
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614 DATE: 7 May 2015 MARKS: 130 ASSESSOR: Prof. P.J. Blignaut (Bonus marks: 5) MODERATOR: Dr. L. de Wet TIME: 180 minutes
More informationThis is an open-book test. You may use the text book Be Sharp with C# but no other sources, written or electronic, will be allowed.
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 124 DATE: 1 September 2014 TIME: 3 hours MARKS: 105 ASSESSORS: Prof. P.J. Blignaut BONUS MARKS: 3 MODERATOR: Dr. L. De Wet
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 114 CLASS TEST 2 and 3 DATE: 4 August 2014 TIME: 180 minutes MARKS: 70
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 114 CLASS TEST 2 and 3 DATE: 4 August 2014 TIME: 180 minutes MARKS: 70 ASSESSOR: Prof. P.J. Blignaut (+1 bonus mark) This
More informationMemorandum public override string string Node while null return public void bool false Node while null null true while public void Node new
Memorandum 1.1.1 public override string ToString() string s = ""; while (current!= null) s += current.element.tostring() + ", "; current = current.next; return s; //ToString() 1.1.2 public void Sort()
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS2614 MODULE TEST 1
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS2614 MODULE TEST 1 DATE: 18 March 2016 MARKS: 165 ASSESSOR: Prof. P.J. Blignaut (Bonus 8) MODERATOR: Dr T. Beelders TIME:
More informationObject Oriented Programming in C#
Introduction to Object Oriented Programming in C# Class and Object 1 You will be able to: Objectives 1. Write a simple class definition in C#. 2. Control access to the methods and data in a class. 3. Create
More informationMemorandum. 1.1 public enum Days : int { Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 }
Memorandum Question 1 1.1 public enum Days : int Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 1.2 class Temps private double[] Values = new double[7]; 1.3
More informationUNIVERSITY OF THE FREE STATE MAIN & QWA-QWA CAMPUS RIS 124 DEPARTMENT: COMPUTER SCIENCE AND INFORMATICS CONTACT NUMBER:
UNIVERSITY OF THE FREE STATE MAIN & QWA-QWA CAMPUS RIS 124 DEPARTMENT: COMPUTER SCIENCE AND INFORMATICS CONTACT NUMBER: 4012754 EXAMINATION: Main End-of-year Examination 2013 PAPER 1 ASSESSORS: Prof. P.J.
More informationThis is an open-book test. You may use the text book Be Sharp with C# but no other sources, written or electronic, will be allowed.
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 124 DATE: 5 September 2011 TIME: 3½ hours MARKS: 150 ASSESSORS: Prof. P.J. Blignaut & Mr. M.B. Mase MODERATOR: Dr. A. van
More informationRIS214. Class Test 3
RIS214 Class Test 3 Use console applications to solve the following problems and employ defensive programming to prevent run-time errors. Every question will be marked as follows: mark = copied? -5 : runs?
More informationLesson11-Inheritance-Abstract-Classes. The GeometricObject case
Lesson11-Inheritance-Abstract-Classes The GeometricObject case GeometricObject class public abstract class GeometricObject private string color = "White"; private DateTime datecreated = new DateTime(2017,
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614. DATE: 5 March 2015 MARKS: 100 SECTION A (36)
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614 DATE: 5 March 2015 MARKS: 100 ASSESSOR: Prof. P.J. Blignaut TIME: 180 minutes MODERATOR: Dr. L. de Wet SECTION A (36)
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationLearn C# Errata. 3-9 The Nullable Types The Assignment Operators
1 The following pages show errors from the original edition, published in July 2008, corrected in red. Future editions of this book will be printed with these corrections. We apologize for any inconvenience
More informationCMPSCI 187: Programming With Data Structures. Lecture 12: Implementing Stacks With Linked Lists 5 October 2011
CMPSCI 187: Programming With Data Structures Lecture 12: Implementing Stacks With Linked Lists 5 October 2011 Implementing Stacks With Linked Lists Overview: The LinkedStack Class from L&C The Fields and
More informationClass Test 10. Question 1. Create a console application using visual studio 2012 ultimate.
Class Test 10 Question 1 Create a console application using visual studio 2012 ultimate. Figure 1 Use recursion to create a menu, DO NOT use a while, do while or for loop. When any value is entered that
More informationStrings and Arrays. Hendrik Speleers
Hendrik Speleers Overview Characters and strings String manipulation Formatting output Arrays One-dimensional Two-dimensional Container classes List: ArrayList and LinkedList Iterating over a list Characters
More informationIST311. Advanced Issues in OOP: Inheritance and Polymorphism
IST311 Advanced Issues in OOP: Inheritance and Polymorphism IST311/602 Cleveland State University Prof. Victor Matos Adapted from: Introduction to Java Programming: Comprehensive Version, Eighth Edition
More informationComputer Science CS221 Test 2 Name. 1. Give a definition of the following terms, and include a brief example. a) Big Oh
Computer Science CS221 Test 2 Name 1. Give a definition of the following terms, and include a brief example. a) Big Oh b) abstract class c) overriding d) implementing an interface 10/21/1999 Page 1 of
More informationComputer Programming, I. Laboratory Manual. Experiment #3. Selections
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationData Structures. BSc in Computer Science University of New York, Tirana. Assoc. Prof. Marenglen Biba 1-1
Data Structures BSc in Computer Science University of New York, Tirana Assoc. Prof. Marenglen Biba 1-1 General info Course : Data Structures (3 credit hours) Instructor : Assoc. Prof. Marenglen Biba Office
More informationCS 216 Exam 1 Fall SOLUTION
CS 216 Exam 1 Fall 2004 - SOLUTION Name: Lab Section: Email Address: Student ID # This exam is closed note, closed book. You will have an hour and fifty minutes total to complete the exam. You may NOT
More informationFall Semester (081) Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals
INTERNET PROTOCOLS AND CLIENT-SERVER PROGRAMMING Client SWE344 request Internet response Fall Semester 2008-2009 (081) Server Module 2.1: C# Programming Essentials (Part 1) Dr. El-Sayed El-Alfy Computer
More informationAbout this exam review
Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review
More informationSequential Search (Searching Supplement: 1-2)
(Searching Supplement: 1-2) A sequential search simply involves looking at each item in an array in turn until either the value being searched for is found or it can be determined that the value is not
More informationCSC Java Programming, Fall Java Data Types and Control Constructs
CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference
More informationCS Programming I: Arrays
CS 200 - Programming I: Arrays Marc Renault Department of Computer Sciences University of Wisconsin Madison Fall 2017 TopHat Sec 3 (PM) Join Code: 719946 TopHat Sec 4 (AM) Join Code: 891624 Array Basics
More information1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'
Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java
More informationEquality in.net. Gregory Adam 07/12/2008. This article describes how equality works in.net
Equality in.net Gregory Adam 07/12/2008 This article describes how equality works in.net Introduction How is equality implemented in.net? This is a summary of how it works. Object.Equals() Object.Equals()
More informationStandard ADTs. Lecture 19 CS2110 Summer 2009
Standard ADTs Lecture 19 CS2110 Summer 2009 Past Java Collections Framework How to use a few interfaces and implementations of abstract data types: Collection List Set Iterator Comparable Comparator 2
More informationCSE 131 Introduction to Computer Science Fall Exam II
CSE 131 Introduction to Computer Science Fall 2013 Given: 6 November 2013 Exam II Due: End of session This exam is closed-book, closed-notes, no electronic devices allowed. The exception is the cheat sheet
More informationEECS2030 Fall 2016 Preparation Exercise for Lab Test 2: A Birthday Book
EECS2030 Fall 2016 Preparation Exercise for Lab Test 2: A Birthday Book Chen-Wei Wang Contents 1 Before Getting Started 2 2 Task: Implementing Classes for Birthdays, Entries, and Books 3 2.1 Requirements
More informationHas-a Relationships. A pen has a or contains a ball
Has-a Relationships A pen has a or contains a ball Has-a Relationships Has-a relationship Also called containment Cannot be implemented using inheritance Example: To implement the has-a relationship between
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More informationData Structures G5029
Data Structures G5029 Lecture 2 Kingsley Sage Room 5C16, Pevensey III khs20@sussex.ac.uk University of Sussex 2006 Lecture 2 Stacks The usual analogy is the stack of plates. A way of buffering a stream
More information1.00 Lecture 26. Data Structures: Introduction Stacks. Reading for next time: Big Java: Data Structures
1.00 Lecture 26 Data Structures: Introduction Stacks Reading for next time: Big Java: 19.1-19.3 Data Structures Set of primitives used in algorithms, simulations, operating systems, applications to: Store
More informationCS171 Midterm Exam. October 29, Name:
CS171 Midterm Exam October 29, 2012 Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 50 minutes to complete this exam. Read each problem carefully, and
More informationObjectives. Introduce static keyword examine syntax describe common uses
Static Objectives Introduce static keyword examine syntax describe common uses 2 Static Static represents something which is part of a type rather than part of an object Two uses of static field method
More informationReusing Classes. Hendrik Speleers
Hendrik Speleers Overview Composition Inheritance Polymorphism Method overloading vs. overriding Visibility of variables and methods Specification of a contract Abstract classes, interfaces Software development
More informationCS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes
CS/ENGRD 2110 SPRING 2019 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due Thursday night (14 February) Go back to Lecture 6 & discuss method
More informationCOPYRIGHTED MATERIAL. Part I The C# Ecosystem. ChapTEr 1: The C# Environment. ChapTEr 2: Writing a First Program
Part I The C# Ecosystem ChapTEr 1: The C# Environment ChapTEr 2: Writing a First Program ChapTEr 3: Program and Code File Structure COPYRIGHTED MATERIAL 1The C# Environment What s in This ChapTEr IL and
More informationpublic static boolean isoutside(int min, int max, int value)
See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static
More informationA method is a code block that contains a series of statements. Methods. Console.WriteLine(); Console.ReadKey(); Console.ReadKey(); int.
A method is a code block that contains a series of statements Methods Built-in User Define Built-in Methods (Examples): Console.WriteLine(); int.parse(); Methods Void (Procedure) Return (Function) Procedures
More informationCS/ENGRD 2110 FALL Lecture 7: Interfaces and Abstract Classes
CS/ENGRD 2110 FALL 2017 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due tomorrow night (17 February) Get started on A3 a method every other day.
More informationTHE UNIVERSITY OF WESTERN AUSTRALIA
THE UNIVERSITY OF WESTERN AUSTRALIA MID SEMESTER EXAMINATION April 2016 SCHOOL OF COMPUTER SCIENCE & SOFTWARE ENGINEERING DATA STRUCTURES AND ALGORITHMS CITS2200 This Paper Contains: 6 Pages 10 Questions
More informationData Structures And Algorithms
Data Structures And Algorithms Stacks Eng. Anis Nazer First Semester 2017-2018 Stack An Abstract data type (ADT) Accessed only on one end Similar to a stack of dishes you can add/remove on top of stack
More informationDepartment of Networks College of Bardarash Technical Institute DUHOK Polytechnic University Subject: Programming Fundamental by JAVA Course Book
1 Department of Networks College of Bardarash Technical Institute DUHOK Polytechnic University Subject: Programming Fundamental by JAVA Course Book Year 1 Lecturer's name: MSc. Sami Hussein Ismael Academic
More informationExceptions and Design
Exceptions and Exceptions and Table of contents 1 Error Handling Overview Exceptions RuntimeExceptions 2 Exceptions and Overview Exceptions RuntimeExceptions Exceptions Exceptions and Overview Exceptions
More informationCSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2014
CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2014 Name: This exam consists of 8 problems on the following 8 pages. You may use your two- sided hand- written 8 ½ x 11 note sheet during the exam.
More informationAdvanced Object-Oriented Programming. 11 Features. C# Programming: From Problem Analysis to Program Design. 4th Edition
11 Features Advanced Object-Oriented Programming C# Programming: From Problem Analysis to Program Design C# Programming: From Problem Analysis to Program Design 1 4th Edition Chapter Objectives 2 Chapter
More informationdouble d0, d1, d2, d3; double * dp = new double[4]; double da[4];
All multiple choice questions are equally weighted. You can generally assume that code shown in the questions is intended to be syntactically correct, unless something in the question or one of the answers
More informationCMSC 132: Object-Oriented Programming II. Stack and Queue
CMSC 132: Object-Oriented Programming II Stack and Queue 1 Stack Allows access to only the last item inserted. An item is inserted or removed from the stack from one end called the top of the stack. This
More informationCS350: Data Structures Linked Lists
Linked Lists James Moscola Department of Physical Sciences York College of Pennsylvania James Moscola Linked Lists Come in a variety of different forms - singly linked lists - doubly linked lists - circular
More informationClasses and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?
Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable
More information09/08/2017 CS2530 INTERMEDIATE COMPUTING 9/8/2017 FALL 2017 MICHAEL J. HOLMES UNIVERSITY OF NORTHERN IOWA TODAY S TOPIC: Exceptions and enumerations.
CS2530 INTERMEDIATE COMPUTING 9/8/2017 FALL 2017 MICHAEL J. HOLMES UNIVERSITY OF NORTHERN IOWA TODAY S TOPIC: Exceptions and enumerations. 1 RUNTIME ERRORS All of us have experienced syntax errors. This
More informationWhat property of a C# array indicates its allocated size? What keyword in the base class allows a method to be polymorphic?
What property of a C# array indicates its allocated size? a. Size b. Count c. Length What property of a C# array indicates its allocated size? a. Size b. Count c. Length What keyword in the base class
More informationEXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 Trimester 2, MID-TERM TEST COMP103 Introduction
More information4/27/2014. Templates II. Warmup Write the templated Swap function. Class Templates CMSC 202
Templates II CMSC 202 Warmup Write the templated Swap function void Swap( T& a, T& b ) T temp = a; a = b; b = temp; Class Templates Fundamental Idea Define classes that operate on various types of objects
More informationData Structures and Object-Oriented Design III. Spring 2014 Carola Wenk
Data Structures and Object-Oriented Design III Spring 2014 Carola Wenk Array-Based Stack vs. DynamicStack public class ArrayStack { final static int DEFAULT_CAPACITY=50; private int[] S; private int top;
More informationInterfaces & Generics
Interfaces & Generics CSC207 Winter 2018 The Programming Interface The "user" for almost all code is a programmer. That user wants to know:... what kinds of object your class represents... what actions
More informationl Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)
Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between
More informationIntroduction to Computer Science II (ITI 1121) Midterm Examination
Introduction to Computer Science II (ITI 1121) Midterm Examination Instructor: Marcel Turcotte February 2008, duration: 2 hours Identification Student name: Student number: Signature: Instructions 1. 2.
More informationLecture 16. Lecture
Recursive lists D0010E Variants of lists Doubly linked lists Binary trees Circular lists - Håkan Jonsson 1 - Håkan Jonsson 2 - Håkan Jonsson 3 1 1. Circular lists A singly linked list has a beginning and
More informationCS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid:
CS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid: CS 2150 Exam 1 Name You MUST write your e-mail ID on EACH page and put your name on the top of this page, too. If you are still writing when pens down
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2013
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2013 Name: This exam consists of 5 problems on the following 6 pages. You may use your double-sided hand-written 8 ½ x 11 note sheet
More informationDC69 C# &.NET DEC 2015
Q.2 a. Briefly explain the advantage of framework base classes in.net. (5).NET supplies a library of base classes that we can use to implement applications quickly. We can use them by simply instantiating
More informationProgramming using C# LECTURE 07. Inheritance IS-A and HAS-A Relationships Overloading and Overriding Polymorphism
Programming using C# LECTURE 07 Inheritance IS-A and HAS-A Relationships Overloading and Overriding Polymorphism What is Inheritance? A relationship between a more general class, called the base class
More informationCS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12
CS 151 Linked Lists, Recursively Implemented 1 2 Linked Lists, Revisited Recall that a linked list is a structure that represents a sequence of elements that are stored non-contiguously in memory. We can
More informationLecture 5: Methods CS2301
Lecture 5: Methods NADA ALZAHRANI CS2301 1 Opening Problem Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively. 2 Solution public static int sum(int i1, int i2) { int
More informationCS2012 Programming Techniques II
27 January 14 Lecture 6 (continuing from 5) CS2012 Programming Techniques II Vasileios Koutavas 1 27 January 14 Lecture 6 (continuing from 5) 2 Previous Lecture Amortized running time cost of algorithms
More informationCT 229 Object-Oriented Programming Continued
CT 229 Object-Oriented Programming Continued 24/11/2006 CT229 Summary - Inheritance Inheritance is the ability of a class to use the attributes and methods of another class while adding its own functionality
More informationC# Programming for Developers Course Labs Contents
C# Programming for Developers Course Labs Contents C# Programming for Developers...1 Course Labs Contents...1 Introduction to C#...3 Aims...3 Your First C# Program...3 C# The Basics...5 The Aims...5 Declaring
More informationIntroduction to Computing II (ITI 1121) Final Examination
Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of Engineering School of Electrical Engineering and Computer Science Introduction
More informationCOMP 213 Advanced Object-oriented Programming Lecture 8 The Queue ADT (cont.)
COMP 213 Advanced Object-oriented Programming Lecture 8 The Queue ADT (cont.) Recall: The Queue ADT A data structure in which elements enter at one end and are removed from the opposite end is called a
More informationFaculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination Monday, March 9, 2009 Examiners: Mathieu Petitpas [Section 1] 18:30
More informationChapter 19: Program Design. Chapter 19. Program Design. Copyright 2008 W. W. Norton & Company. All rights reserved.
Chapter 19 Program Design 1 Introduction Most full-featured programs are at least 100,000 lines long. Although C wasn t designed for writing large programs, many large programs have been written in C.
More informationCSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall
CSE443 Compilers Dr. Carl Alphonce alphonce@buffalo.edu 343 Davis Hall http://www.cse.buffalo.edu/faculty/alphonce/sp17/cse443/index.php https://piazza.com/class/iybn4ndqa1s3ei Phases of a compiler Target
More informationCMSC 202 Final May 19, Name: UserID: (Circle your section) Section: 101 Tuesday 11: Thursday 11:30
CMSC 202 Final May 19, 2005 Name: UserID: (Circle your section) Section: 101 Tuesday 11:30 102 Thursday 11:30 Directions 103 Tuesday 12:30 104 Thursday 12:30 105 Tuesday 1:30 106 Thursday 1:30 This is
More informationProgramming Basics. Part 1, episode 1, chapter 1, passage 1
Programming Basics Part 1, episode 1, chapter 1, passage 1 Agenda 1. What is it like to program? 2. Our first code 3. Integers 4. Floats 5. Conditionals 6. Booleans 7. Strings 8. Built-in functions What
More informationCollections Chapter 12. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013
Collections Chapter 12 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Scope Introduction to Collections: Collection terminology The Java Collections API Abstract nature of collections
More information1.00/ Introduction to Computers and Engineering Problem Solving. Quiz 2 / November 10, 2005
1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 2 / November 10, 2005 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do
More informationCSC-140 Assignment 6
CSC-140 Assignment 6 1 Introduction In this assignment we will start out defining our own classes. For now, we will design a class that represents a date, e.g., Tuesday, March 15, 2011, or in short hand
More informationIntroduction to Computer Science II (CSI 1101)
Introduction to Computer Science II (CSI 1101) Professor: M. Turcotte February 2002, duration: 75 minutes Identification Student name: last name: Section: Student number: initials: Signature: Instructions
More informationUniversity of Illinois at Urbana-Champaign Department of Computer Science. First Examination
University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2007 7p-9p, Thursday, March 1 Name: NetID: Lab Section
More informationCOSC 320 Exam 2 Key Spring Part 1: Hash Functions
COSC 320 Exam 2 Key Spring 2011 Part 1: Hash s 1. (5 Points) Create the templated function object lessthan, you may assume that the templated data type T has overloaded the < operator. template
More informationIntroduction to Computing II (ITI 1121) FINAL EXAMINATION
Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of Engineering School of Electrical Engineering and Computer Science Identification
More informationFACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE & SOFTWARE ENGINEERING IFM01B1 / IFM1B10 INTRODUCTION TO DATA STRUCTURES (VB)
FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE & SOFTWARE ENGINEERING MODULE CAMPUS IFM01B1 / IFM1B10 INTRODUCTION TO DATA STRUCTURES (VB) APK EXAM NOVEMBER 2014 DATE 2014-11-08 SESSION 08h30 10h30 ASSESSORS
More informationComputer Science 1 Ah
UNIVERSITY OF EDINBURGH course CS0077 COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS Computer Science 1 Ah Resit Examination Specimen Solutions Date: Monday 1st September 2003 Time: 09:30 11:00
More informationProgramming Logic and Design Sixth Edition
Objectives Programming Logic and Design Sixth Edition Chapter 6 Arrays In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested decisions
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 : Structure declaration and initialization. Access to fields of structure. Array of Structs. 11/10/2016
More informationCS 101 Spring 2007 Midterm 2 Name: ID:
You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure
More informationBasic Data Structures
Basic Data Structures Some Java Preliminaries Generics (aka parametrized types) is a Java mechanism that enables the implementation of collection ADTs that can store any type of data Stack s1
More informationCSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013
CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013 Name: This exam consists of 6 problems on the following 6 pages. You may use your two-sided hand-written 8 ½ x 11 note sheet during the exam.
More informationWrite a program to implement stack or any other data structure in Java ASSIGNMENT NO 15
Write a program to implement stack or any other data structure in Java ASSIGNMENT NO 15 Title: Demonstrate implementation of data structure in Java Objectives: To learn implementation of data structure
More informationEEE-425 Programming Languages (2013) 1
2 Namespaces Classes Fields Properties Methods Attributes Events Interfaces (contracts) Methods Properties Events Control Statements if, else, while, for, switch foreach Additional Features Operation Overloading
More information