Cmpt 135 Assignment 2: Solutions and Marking Rubric Feb 22 nd 2016 Due: Mar 4th 11:59pm

Size: px
Start display at page:

Download "Cmpt 135 Assignment 2: Solutions and Marking Rubric Feb 22 nd 2016 Due: Mar 4th 11:59pm"

Transcription

1 Assignment 2 Solutions This document contains solutions to assignment 2. It is also the Marking Rubric for Assignment 2 used by the TA as a guideline. The TA also uses his own judgment and discretion during marking. Some marks may vary slightly. If you have concerns, please first raise them with the TA using the cmpt-135-help@sfu.ca address. Scott A. Written Assignment For part A, since there is no code, the 10 marks are all for correctness. If their text/doc/pdf file does not include student name, number, , then deduct 2 marks (20% of the total for part A). If the submitted doc is hard to read, deduct up to 3 marks for clarity (30%). If their submission is an image file of a handwritten answer, give them zero. One mark each. Avoid half marks, give students full mark if in doubt. Student does not need to provide the full answer provided in the rubric for a full mark, but should include the ideas underlined (although the wording need not be identical). 1. Chapter 10 Classes 10 Marks (a) What is the benefit of encapsulation? Main benefit is reducing system complexity Treat data or object as a black box hides implementation details hides data details Reduces inter-module coupling Increases intra-module cohesion (b) What is the difference between a Struct and a Class A struct is an aggregation of data but defines no methods associated with that data. A Class defines both data and methods associated with managing that data. Both serve to encapsulate and hide complexity. Class members default to private, struct members to public. 1

2 (c) What is the difference between an Object and a Class? A Class is a blue print for an object. It defines a set of variables, methods, and interfaces but has no state and reserves no memory space for those variables. An Object is an instantiation of a Class and is assigned a new copy of any instance data associated with that class. It has both state and methods that operate on that state. (d) Are members of a class public or private by default? Structs and Classes have both Public and Private sections. Class members are private by default. One must place the keyword public before members to make them visible externally. Struct members are public by default. (e) What are constructors used for? Constructors are special methods called when an object is instantiated in order to initialize the object s data and initial state. (f) What does it mean to overload constructor? Constructors may be overloaded by defining multiple constructors with different parameter signatures within the same class declaration. Methods and functions may be overloaded in the same way by a class defining multiple functions with different signatures. Methods may be overridden when a derived/child class redefines the base/parent constructor with the same signature (g) What is an aggregate object? An aggregate object is an object that contains other objects as instance data. That is, an aggregate object is made up of other objects. An aggregate struct is a data structure that contains other defined data structures. That is, an aggregate struct is made up of other data structures. (h) Describe the difference between a public and private method. A public method has global scope and can be used by any method that has visibility to its class. 2

3 A private method has only local scope and can only be used within the class that defines it and friends of that class. (i) Describe what an Abstract Data Type (ADT) is and why we use them? An Abstract Data Type (ADT) hides the details about how the data type is implemented, so the user can focus on what it can be used for. An ADT allows the implementation to be changed without impacting users since their interface to the ADT is perserved. ADTs reduce system complexity by hiding details from users. (j) What is Inheritance and what is its key benefit? Inheritance allows derived classes to be created that re-use the existing methods and data of the base class. It's key benefit is software re-use. It allows new services to quickly benefit from existing software features and already tested designs. Re-Use results in more reliable software systems that are produced quicker with less effort. 3

4 B. Written Assignment Submit in CourSys For part B questions 1-4, since there is no code, the marks are all for correctness. If their text/doc/pdf file does not include student name, number, , then deduct 20% of the total. If the submitted doc is hard to read, deduct up to 30% for clarity. If their submission is an image file of a handwritten answer, give them zero. 1. Class Definition Questions Multiple Choice 10 Marks Questions with one correct answer only: Score [1] if you choose the correct answer and do not choose another, score [0.5] if you choose one correct answer and one incorrect answer, score [0] if no correct answer is chosen, or more than two are chosen. If the question has 2 correct answers: [1] if you choose both correct, [0.5] if you choose one correct and one incorrect, [0.5] if you choose one correct and do not choose other, [0] if no correct answer chosen or more than two are chosen. Correct Answers will be highlighted in blue. (a) Assume that we are defining a Book class, and one of the instance variables is title. To prevent the possibility that the title of a book object is changed from outside the Book class, unless it is done via the setter method settitle(), the variable title has to be declared as: 1) friend 2) public 3) private 4) void 5) class (b) To allow the title of a book object to be changed from outside the Book class via the setter method settitle(), the method settitle() has to be declared as: 1) friend 2) class 3) private 4) public 5) void (c) To allow the non-member function outputtitle(book book) to access book's private member variable title directly, outputtitle() has to be declared within the Book Class as: 1) friend 2) class 4

5 3) private 4) public 5) void (d) When passing parameters by value to a C++ method that are BASIC DATA TYPES, the corresponding actual and formal parameters (respectively, the corresponding parameters when calling the method and those declared in the called method): 1) are references to different objects 2) become aliases to the same data in memory 3) are static variables 4) are different variables containing the same value 5) cannot be references to arrays (e) When passing parameters that are ARRAYs to a C++ method, the corresponding actual and formal parameters: 1) are references to different objects 2) become aliases to the same data in memory 3) are static variables 4) are variables containing the same value 5) cannot be references to arrays (f) In order to preserve the encapsulation of an object, we would do the following in the class defining the object: 1) declare the instance variables as private in the class 2) write a Tester class associated to the class defining the object 3) declare the methods of the class defining the object as void 4) include private getter and setter methods in the class 5) define only one constructor method and not more (g) Assume that a method receives an array of strings as a pass-by-value parameter and the method modifies some elements of the array. To be able to see the changes in the array outside the method: 1) The method necessarily has to be defined of type String[] and the modified array needs to be returned from the method 2) The method may be defined to return any type. The changes in the array can be seen outside the method regardless. 3) No changes will be seen because the array was passed-by-value 4) The elements of the array may be changed. While the elements of the array may refer to a different string object, the array will be changed. 5) Because it is an array, the parameter was passed to the method by value, and thus the changes cannot be seen outside the method. (h) A constructor is used in a Class definition to: 1) Define how methods are built 2) Allow object state information to be initialized upon instantiation 3) Return constructed primitive data types back to the invoker 4) Accept parameters used to instantiated the object 5

6 5) Construct class definitions at compile-time (i) Method Overloading occurs when: 1) More than one class implement the same method 2) A method is invoked too often 3) A method is implemented multiple times in the same class with different signatures 4) A method is used to implement more than one thing 5) A method has the same name and parameters but returns different types (j) Method Overriding occurs when: 1) A method is implemented multiple times in the same class with different signatures 2) A child class provides a method with the same signature as its parent class 3) A child class provides a method with the same signature as an ancestor class in the class hierarchy 4) A Class catches an exception and handles the error condition 5) A local variable shadows another variable with the same name 6

7 2. Chapter 7 Arrays 5 Marks Rubric for this section: -1.0 if write up is poorly presented and hard to read -1.0 if contains many grammar or spelling mistakes For each question: 0 if the answer is wrong 0.5 if the answer is incomplete 1.0 if the answer is correct and complete (a) What is an Array? An array is a list of elements located contiguously in memory. The entire list can be referenced by its name, and each element in the list can be referenced individually based on its position in the array using an index. (b) What is an array s element type? An array s element type is the type of values that the array can hold. All values in a particular array have the same type, or are at least of compatible types. Thus, we might have an array of integers, or an array of boolean values, or an array of Dog objects, and so on. (c) How is each element in an array referenced? Each element in an array can be referenced by its numeric position, called an index, in the array. In C++, all array indexes begin at zero. Square brackets are used to specify the index. For example, nums[5] refers to the sixth element in the array called nums. (d) How is an entire array passed as a parameter? Passing the array name as a parameter provides a pointer to the entire array. Any changes made to the array elements will be reflected outside of the method. The pointer itself is passed by value, so while the contents of the array can be modified, the method cannot modify the caller's pointer to the array. (e) What is a command-line argument and how are they accessed? Command-line arguments are the parameters specified when the program is invoked from the linux shell. These parameters are passed to main() as argv, which is a pointer to an array of C strings, plus argc which is the length of the array. 7

8 3. Chapter 10.4 Introduction to Inheritance 5 Marks Rubric for this section: -1.0 if write up is poorly presented and hard to read -1.0 if contains many grammar or spelling mistakes For each question: 0 if the answer is wrong 0.5 if the answer is incomplete 1.0 if the answer is correct and complete (a) Describe the relationship between a parent class and a child class. A child class is derived from a parent class using inheritance. The methods and variables of the parent class automatically become a part of the child class, subject to the rules of the visibility modifiers used to declare them. (b) How does inheritance support software reuse? Because a new class can be derived from an existing class, the characteristics of the parent class can be reused without the error-prone process of copying and modifying code. Any future enhancements or fixes to the parent class are automatically inherited by the child class. (c) Can a child class access the private member variables of its parent? A child cannot access private member variables of its parent. Like other classes, it has no access to private members. (d) Can a child invoke a public member function of its parent? Yes, a child has access to all public member functions. (e) Can a child declare member functions already declared by its parent? Yes, this is known as over-riding. It allows a derived class to override methods defined by the parent. 8

9 4. Testing 5 Marks Rubric for this question: -1.0 if write up is poorly presented and hard to read -1.0 if contains many grammar or spelling mistakes For each question: 0 if the answer is wrong 0.5 if the answer is incomplete 1.0 if the answer is correct and complete (a) Describe the difference between Black Box and White Box testing. 2 Marks - one of Block Box and one for White Box Testing Description Black Box testing Tests observable functionality of one or more modules with no regard to internal implementation details. White Box testing has internal implementation knowledge about the system under test. It Tests both external and internal interfaces using implementation knowledge to verify correctness of all internal logic paths (b) Describe the goals and scope of the three types of testing called Unit testing, Integration testing, and System testing. 3 Marks - one of each description of the three testing types Unit Testing: Verifies that an individual Class and its methods function correctly given a set of sample inputs and expected outputs Integration Testing: Verifies that several software components, packages, or classes produced by several teams work together as expected. System Testing: Verifies that the product satisfies customer requirements and meets specific quality objectives and it usually includes regression testcases. 9

10 5. Data Flow Diagrams 5 Marks Rubric for this question: -2 if write up is poorly presented and hard to read -1 Mark for each missing constructor No penalty for lack of comments +1 Bonus if comments are brief but clear 1 Mark for Gambler Class declaration 1 Mark for Die Class declaration 1 Mark for Die Roll method returning bool 1 Mark for Gambler RollTheDice method returning an int 1 Mark for private variables for each class match diagram Class declarations: 10

11 6. UML Diagrams 5 Marks Create a UML Diagram that describes the classes in the Data Flow Diagram above. Your UML diagram must show the relationship between the two classes, their public member functions, and private member variables. You may draw the UML diagram by hand if desired, then scan into a jpeg file that you include in your assignment write up document. Class relationships in UML Diagrams can get tricky to capture if one gets deep into the subtle nuances of class dependencies versus class associations such as aggregation and composition. For an overview of these concepts and UML in general, the interested student should read: For this course, I have simplified these concepts into just three basic relationships: Dependency (A uses B) Aggregation (A has-a B) Inheritance (A is-a B) In the case of the Gambler and Die classes from question 5, it can be confusing since the Gamble Class uses the Die Class (Dependency), but also has two object instances of the Die class (Aggregation). So which is it? Aggregation is reserved for situations when one class is composed of another object such as when we say a Car has-a Engine. The engine is part of the car. Dependency is used to describe when one object requests services of another object, and is therefore dependent on that object. The Gambler class is dependent on the Die class as shown in the diagram below: 11

12 Although not correct, a UML diagram that depicts the Aggregation relationship is acceptable for this assignment since the differences were not clearly explained in class. Rubric for this question: -2 if diagram is poorly formatted or hard to read -1 Mark for missing constructors 1 Mark for Gambler and Die Classes 1 Mark for Die Roll method 1 Mark for Gambler RollTheDice method 1 Mark for private variables correct 1 Mark for Dependency marked with Arrow (or Aggregation) 12

13 C. Programming To be completed by Students Individually You may not use the array or vector classes for this assignment. 1. Passing Arrays to Functions as Parameters 10 Marks Your function called has77 must have the following signature: bool has77(int nums[], int length) { } Rubric: 1 Mark Block Comment at top of file with name, student number, 1 Mark Function Block Comment describes function, inputs, and outputs 3 Marks Well structured easy to read code (score from 0 to 3) 5 Marks Correctly passes all test cases (-1 per failed testcase) Penalties: 0 Marks if code does not compile -5 Marks if code compiles but does not run Testcases: has77({1, 7, 7},3) true has77({1, 7, 1, 7},4) true has77({1, 7, 1, 1, 7},5) false has77({7, 7, 1, 1, 7},5) true has77({2, 7, 2, 2, 7, 2},6) false has77({2, 7, 2, 2, 7, 7},6) true has77({7, 2, 7, 2, 2, 7},6) true has77({7, 2, 6, 2, 2, 7},6) false has77({7, 7, 7},3) true has77({7, 1, 7},3) true has77({7, 1, 1},3) false has77({1, 2},2) false has77({1, 7},2) false has77({7},1) false 13

14 2. Modifying Arrays in a Method 10 Marks Your function called withoutten must have the following signature: void withoutten(int nums[], int length) { } Rubric: 1 Mark Block Comment at top of file with name, student number, 1 Mark Function Block Comment describes function, inputs, and outputs 3 Marks Well structured easy to read code (score from 0 to 3) 5 Marks Correctly passes all test cases (-1 per failed testcase) Penalties: 0 Marks if code does not compile -5 Marks if code compiles but does not run Testcases: withoutten Number of Testcases: 10 withoutten({ 1, 10, 10, 2},4)={ 1, 2, 0, 0} result={ 1, 2, 0, 0} withoutten({10, 2, 10},3)={ 2, 0, 0} result={ 2, 0, 0} withoutten({ 1, 99, 10},3)={ 1, 99, 0} result={ 1, 99, 0} withoutten({10, 13, 10, 14},4)={13, 14, 0, 0} result={13, 14, 0, 0} withoutten({10, 13, 10, 14, 10},5)={13, 14, 0, 0, 0} result={13, 14, 0, 0, 0} withoutten({10, 10, 3},3)={ 3, 0, 0} result={ 3, 0, 0} withoutten({ 1},1)={ 1} result={ 1} withoutten({13, 1},2)={13, 1} result={13, 1} withoutten({10},1)={ 0} result={ 0} withoutten({},0)={} result={} Congrats! All tests passed! 14

15 3. Two Dimensional Arrays 10 Marks Rubric: 1 Mark Block Comment at top of file with name, student number, 1 Mark Function Block Comment describes function, inputs, and outputs 3 Marks Well structured easy to read code (score from 0 to 3) 1 Mark Internally double avg[] correctly computed and stored 1 Mark Row number and Avg correctly printed out as specified 1 Mark Internally int randomnum[][] correctly uses indexing [row][col] 1 Mark randomnum[][] correctly printed as [row][column] 1 Mark Numbers under 10 correctly left padded with a space Penalties: -2 Marks if output formatting does not match example test run -2 Marks if any average contains a non-zero in the second decimal place -2 Marks if no averages contain a non-zero in the first decimal place -2 Marks - if random numbers do not change after each test run -5 Marks if code compiles but does not run -10 Marks if code does not compile Example test run: (testcase output should match exactly) Array2d Row 0: Avg=34.10 Row 1: Avg=49.90 Row 2: Avg=45.30 Row 3: Avg=49.60 Row 4: Avg=

16 4. Command Line Parameters 5 Marks Rubric: 1 Mark Well commented File and Function Block Comments 1 Mark Well structured easy to read code (score of 0 or 1) 3 Marks For passing each testcase Penalties: -2 Marks if output does not match example test run formatting exactly -3 Marks if code compiles but does not run -5 Marks if code does not compile Test Cases: Testcase 1: No Command Line Parameters CmdLine There are 0 command line parameters: Testcase 3: Two Command Line Parameters CmdLine Hello World There are 2 command line parameters: "Hello" "World" Testcase 4: 5 Command Line Parameters (example from assignment) CmdLine These are command line parms There are 5 command line parameters: "These" "are" "command" "line" "parms" 16

17 5. Abstract Data Types and Operator Overloading 20 Marks RationalTest.cpp uses the same formatting from assignment 1, but uses your new overloaded operators to verify that the student's code produces the same results. The output is expected to be identical. In addition, specific test cases will be used to verify that your operators and Rational Class works as specified. Rubric: 2 Marks Well commented File and Function Block Comments 3 Marks Well structured easy to read code (score from 0 or 3) 5 Marks Testcase 1 passes 10 Marks 1 Mark each for test cases 2 to 11 Penalties: - 2 Marks if output does not match Testcase 1 formatting exactly - 1 Mark for each math or comparison operator testcase failed -15 Marks if code compiles but does not run -All Marks if code does not compile Test Cases: Testcase 1: Example Test Run (5 Marks) RationalTest Enter a rational number in the form a/b: 15/3 Enter a rational number in the form c/d: 10/2 a=15 b=3 c=10 d=2 Testing: a/b + c/d = (a * d + b * c) / (b * d) 15/3 + 10/2 = (15 * * 10)/(3 * 2) = 10/1 Testing: a/b - c/d = (a * d - b * c) / (b * d) 15/3-10/2 = (15 * 2-3 * 10)/(3 * 2) = 0/1 Testing: (a/b) * (c/d) = (a * c) / (b * d) 15/3 * 10/2 = (15 * 10) / (3 * 2) = 25/1 Testing: (a/b) / (c/d) = (a * d) / (c * b) 15/3 / 10/2 = (15 * 2) / (10 * 3) = 1/1 Testing: -(a/b) = (-a/b) -(15/3) = (-15 / 3) = -5/1 Testing: (a/b) < (c/d) means (a * d) < (c * b) 15/3 < 10/2 means (15 * 2) < (10 * 3) means 30/1 < 30/1 Testing: (a/b) == (c/d) means (a * d) == (c * b) 15/3 == 10/2 means (15 * 2) == (10 * 3) means 30/1 == 30/1 17

18 RationalTest.cpp will be enhanced to test each of the following operators automatically. Each test case is worth 1 mark each. Testcase 2: Overloaded + operator Testcase 3: Overloaded - operator Testcase 4: Overloaded * operator Testcase 5: Overloaded / operator Testcase 6: Overloaded negation - operator Testcase 7: Overloaded == operator Testcase 8: Overloaded > operator Testcase 9: Overloaded < operator Testcase 10: Overloaded >> operator Testcase 11: Overloaded << operator 18

19 D. Programming for Bonus Marks 1. PostFix Rational Expression Evaluator 25 Marks Rubric: 2 Marks Well commented File and Function Block Comments 3 Marks Well structured easy to read code (score from 0 or 3) 10 Marks Testcase 1 passes 10 Marks 1 Mark each for test cases 2 to 11 Penalties: - 2 Marks if output does not match Testcase 1 formatting exactly - 2 Marks for each math or comparison operator testcase failed - 5 Marks if any operator uses cout or cin in its implementation -10 Marks if code compiles but does not run -All Marks if code does not compile Testcase 1: PostFixRational Postfix Rational expression evaluator --> 1/2 1/4 + = tos = 3/4 --> 5/3 1/2 % = tos = 1/6 --> 5 2 % = tos = 1/1 --> dup + + = tos = 13/6 --> ^2 = tos = 169/36 --> inc = tos = 205/36 --> dec = tos = 169/36 --> 4 ^2 = tos = 16/1 --> = tos = 7/2 -->.5 - = tos = 3/1 --> 5 1/2 + = tos = 11/2 --> = tos = 8/1 --> Q Bye! Testcases 2-11: Same testcases as 2-11 for Question C5 19

20 E. Submission Due date: Friday Mar 4 th 11:59pm Late Submissions: If you submit any component after the deadline, it affects the timestamp for the entire submission. If any component is submitted late, the late penalty will be applied to all components. Late Penalty is 10% per day late, or portion of a day late. Late submissions will be accepted up to two days late with the final cut-off Sunday Mar 6 th 11:59pm. 20

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Chapter 5 Object-Oriented Programming

Chapter 5 Object-Oriented Programming Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares

More information

Instructions. Quiz #2. Name: Solutions Student Number: Signature:

Instructions. Quiz #2. Name: Solutions Student Number: Signature: Quiz #2 Name: Solutions Student Number: Signature: Instructions 1. Fill in your Name, Student Number, and signature above. 2. This is a closed book Quiz. No electronic or paper aids permitted. 3. Do not

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

Instructions PLEASE READ (notice bold and underlined phrases)

Instructions PLEASE READ (notice bold and underlined phrases) Lab Exercises wk05 More Debugging with NetBeans Required Reading None Instructions PLEASE READ (notice bold and underlined phrases) Lab Exercise has three parts: A. Lab Demo Watch Demo, reproduce it, show

More information

Review for Midterm. Instructor: Scott Kristjanson CMPT 135 SFU Surrey, Spring 2016

Review for Midterm. Instructor: Scott Kristjanson CMPT 135 SFU Surrey, Spring 2016 Review for Midterm Instructor: Scott Kristjanson CMPT 135 SFU Surrey, Spring 2016 2 What will be covered by the Midterm? Selected material from these topics: Assignment 2 - Parts A, B, C1-C2 Assignment

More information

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

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

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

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University Day 3 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda assignments 1 was due before class 2 is posted (be sure to read early!) a quick look back testing test cases for arrays

More information

Introduction to Programming Using Java (98-388)

Introduction 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 information

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

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand

More information

Anatomy of a Class Encapsulation Anatomy of a Method

Anatomy of a Class Encapsulation Anatomy of a Method Writing Classes Writing Classes We've been using predefined classes. Now we will learn to write our own classes to define objects Chapter 4 focuses on: class definitions instance data encapsulation and

More information

Instructions PLEASE READ (notice bold and underlined phrases)

Instructions PLEASE READ (notice bold and underlined phrases) Assignment 3 Dynamic Arrays and Inheritance Note: This is a Preview! More Questions are coming in Version 1.0 Required Reading Problem Solving with C++ Chapter 7 Arrays Chapter 9 Pointers and Dynamic Arrays

More information

CGS 2405 Advanced Programming with C++ Course Justification

CGS 2405 Advanced Programming with C++ Course Justification Course Justification This course is the second C++ computer programming course in the Computer Science Associate in Arts degree program. This course is required for an Associate in Arts Computer Science

More information

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance CS257 Computer Science I Kevin Sahr, PhD Lecture 10: Inheritance 1 Object Oriented Features For a programming language to be called object oriented it should support the following features: 1. objects:

More information

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Chapter 4: Writing Classes

Chapter 4: Writing Classes Chapter 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Writing Classes We've been using predefined classes. Now we will learn to write our own

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

COMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading

COMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading COMP 202 CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading More on OO COMP 202 - Week 7 1 Static member variables So far: Member variables

More information

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++ No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)

More information

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity. OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.

More information

Computer Science II (20073) Week 1: Review and Inheritance

Computer Science II (20073) Week 1: Review and Inheritance Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system

More information

Instructions PLEASE READ (notice bold and underlined phrases)

Instructions PLEASE READ (notice bold and underlined phrases) Assignment 3 Dynamic Arrays and Classes Required Reading Problem Solving with C++ Chapter 7 Arrays Chapter 9 Pointers and Dynamic Arrays Chapter 10 Classes Chapter 11 Classes and Arrays Optional Reading

More information

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed CREATED BY: Muhammad Bilal Arslan Ahmad Shaad JAVA Chapter No 5 Instructor: Muhammad Naveed Muhammad Bilal Arslan Ahmad Shaad Chapter No 5 Object Oriented Programming Q: Explain subclass and inheritance?

More information

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes Based on Introduction to Java Programming, Y. Daniel Liang, Brief Version, 10/E 1 Creating Classes and Objects Classes give us a way of defining custom data types and associating data with operations on

More information

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information

More information

What is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1

What is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1 Polymorphism Part 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid adult

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

Polymorphism Part 1 1

Polymorphism Part 1 1 Polymorphism Part 1 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid

More information

Instructions PLEASE READ (notice bold and underlined phrases)

Instructions PLEASE READ (notice bold and underlined phrases) Assignment 4 Recursive and Sorting Methods Solutions Required Reading Java Foundations Chapter 13 Linked Structures Chapter 17 Recursion Chapter 18 Searching and Sorting Chapter 19 Trees Instructions PLEASE

More information

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a. Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype

More information

COMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading

COMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading COMP 202 CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading More on OO COMP 202 Objects 3 1 Static member variables So far: Member variables

More information

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation Assigned: Sunday, November 14, 2004 Due: Thursday, Dec 9, 2004, at 11:59pm No solution will be accepted after Sunday, Dec 12,

More information

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS JAN 28,2011 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 FINALTERM EXAMINATION 14 Feb, 2011 CS304- Object Oriented

More information

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

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT Object Oriented Programming Examiner s Report March 2017 A1. a) Explain what is meant by the following terms:

More information

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object

More information

THE BCS PROFESSIONAL EXAMINATION BCS Level 5 Diploma in IT September 2017 EXAMINERS REPORT

THE BCS PROFESSIONAL EXAMINATION BCS Level 5 Diploma in IT September 2017 EXAMINERS REPORT THE BCS PROFESSIONAL EXAMINATION BCS Level 5 Diploma in IT September 2017 EXAMINERS REPORT Object Oriented Programming Question A1 a) Explain the terms abstract data type and encapsulation and describe

More information

Inheritance -- Introduction

Inheritance -- Introduction Inheritance -- Introduction Another fundamental object-oriented technique is called inheritance, which, when used correctly, supports reuse and enhances software designs Chapter 8 focuses on: the concept

More information

Chief Reader Report on Student Responses:

Chief Reader Report on Student Responses: Chief Reader Report on Student Responses: 2017 AP Computer Science A Free-Response Questions Number of Students Scored 60,519 Number of Readers 308 Score Distribution Exam Score N %At Global Mean 3.15

More information

CS304 Object Oriented Programming

CS304 Object Oriented Programming 1 CS304 Object Oriented Programming 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes?

More information

CS 162, Lecture 25: Exam II Review. 30 May 2018

CS 162, Lecture 25: Exam II Review. 30 May 2018 CS 162, Lecture 25: Exam II Review 30 May 2018 True or False Pointers to a base class may be assigned the address of a derived class object. In C++ polymorphism is very difficult to achieve unless you

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

CS-202 Introduction to Object Oriented Programming

CS-202 Introduction to Object Oriented Programming CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction

More information

CS260 Intro to Java & Android 03.Java Language Basics

CS260 Intro to Java & Android 03.Java Language Basics 03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance

More information

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed?

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed? QUIZ Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed? Or Foo(x), depending on how we want the initialization

More information

And Even More and More C++ Fundamentals of Computer Science

And Even More and More C++ Fundamentals of Computer Science And Even More and More C++ Fundamentals of Computer Science Outline C++ Classes Special Members Friendship Classes are an expanded version of data structures (structs) Like structs, the hold data members

More information

Note 12/1/ Review of Inheritance Practice: Please write down 10 most important facts you know about inheritance...

Note 12/1/ Review of Inheritance Practice: Please write down 10 most important facts you know about inheritance... CISC 2000 Computer Science II Fall, 2014 Note 12/1/2014 1 Review of Inheritance Practice: Please write down 10 most important facts you know about inheritance... (a) What s the purpose of inheritance?

More information

Introduction to OO Concepts

Introduction to OO Concepts Introduction to OO Concepts Written by John Bell for CS 342, Fall 2018 Based on chapters 1, 2, and 10 of The Object-Oriented Thought Process by Matt Weisfeld, with additional material from UML Distilled

More information

Instantiation of Template class

Instantiation of Template class Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double

More information

Lab Exercise 6: Abstract Classes and Interfaces CS 2334

Lab Exercise 6: Abstract Classes and Interfaces CS 2334 Lab Exercise 6: Abstract Classes and Interfaces CS 2334 September 29, 2016 Introduction In this lab, you will experiment with using inheritance in Java through the use of abstract classes and interfaces.

More information

Encapsulation. Administrative Stuff. September 12, Writing Classes. Quick review of last lecture. Classes. Classes and Objects

Encapsulation. Administrative Stuff. September 12, Writing Classes. Quick review of last lecture. Classes. Classes and Objects Administrative Stuff September 12, 2007 HW3 is due on Friday No new HW will be out this week Next Tuesday we will have Midterm 1: Sep 18 @ 6:30 7:45pm. Location: Curtiss Hall 127 (classroom) On Monday

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Inheritance and Polymorphism Inheritance (Continued) Polymorphism Polymorphism by inheritance Polymorphism by interfaces Reading for this lecture: L&L 10.1 10.3 1 Interface Hierarchies Inheritance can

More information

Data Structures (list, dictionary, tuples, sets, strings)

Data Structures (list, dictionary, tuples, sets, strings) Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Inheritance, Polymorphism, and Interfaces

Inheritance, Polymorphism, and Interfaces Inheritance, Polymorphism, and Interfaces Chapter 8 Inheritance Basics (ch.8 idea) Inheritance allows programmer to define a general superclass with certain properties (methods, fields/member variables)

More information

PREPARING FOR THE FINAL EXAM

PREPARING FOR THE FINAL EXAM PREPARING FOR THE FINAL EXAM CS 1110: FALL 2017 This handout explains what you have to know for the final exam. Most of the exam will include topics from the previous two prelims. We have uploaded the

More information

9/10/2018 Programming Data Structures Inheritance

9/10/2018 Programming Data Structures Inheritance 9/10/2018 Programming Data Structures Inheritance 1 Email me if the office door is closed 2 Introduction to Arrays An array is a data structure used to process a collection of data that is all of the same

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

CS 376b Computer Vision

CS 376b Computer Vision CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves

More information

Ch02. True/False Indicate whether the statement is true or false.

Ch02. True/False Indicate whether the statement is true or false. Ch02 True/False Indicate whether the statement is true or false. 1. The base class inherits all its properties from the derived class. 2. Inheritance is an is-a relationship. 3. In single inheritance,

More information

COMP-202. Objects, Part III. COMP Objects Part III, 2013 Jörg Kienzle and others

COMP-202. Objects, Part III. COMP Objects Part III, 2013 Jörg Kienzle and others COMP-202 Objects, Part III Lecture Outline Static Member Variables Parameter Passing Scopes Encapsulation Overloaded Methods Foundations of Object-Orientation 2 Static Member Variables So far, member variables

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

Inheritance. Quick Review of Last Lecture. November 12, Passing Arguments. Passing Arguments. Variable Assignment Revisited

Inheritance. Quick Review of Last Lecture. November 12, Passing Arguments. Passing Arguments. Variable Assignment Revisited Inheritance November 12, 200 Quick Review of Last Lecture ComS 20: Programming I (in Java) Iowa State University, FALL 200 Instructor: Alexander Stoytchev Passing Arguments Another important issue related

More information

Inheritance Chapter 8. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Inheritance Chapter 8. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Inheritance Chapter 8 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Scope Class Inheritance: Deriving classes Method overriding Class hierarchies Abstract classes Visibility and inheritance

More information

Assignment 3: Inheritance

Assignment 3: Inheritance Assignment 3: Inheritance Due Wednesday March 21 st, 2012 by 11:59 pm. Submit deliverables via CourSys: https://courses.cs.sfu.ca/ Late penalty is 10% per calendar day (each 0 to 24 hour period past due).

More information

CS 6353 Compiler Construction Project Assignments

CS 6353 Compiler Construction Project Assignments CS 6353 Compiler Construction Project Assignments In this project, you need to implement a compiler for a language defined in this handout. The programming language you need to use is C or C++ (and the

More information

Chapter 15: Object Oriented Programming

Chapter 15: Object Oriented Programming Chapter 15: Object Oriented Programming Think Java: How to Think Like a Computer Scientist 5.1.2 by Allen B. Downey How do Software Developers use OOP? Defining classes to create objects UML diagrams to

More information

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and

More information

CISC 2200 Data Structure Fall, C++ Review:3/3. 1 From last lecture:

CISC 2200 Data Structure Fall, C++ Review:3/3. 1 From last lecture: CISC 2200 Data Structure Fall, 2016 C++ Review:3/3 1 From last lecture: pointer type and pointer variable (stores memory addresses of a variable (of any type, local or global, automatic/static/dynamic)

More information

Computer Science II (20082) Week 1: Review and Inheritance

Computer Science II (20082) Week 1: Review and Inheritance Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax

More information

Object-Oriented Programming. Lecture 2 Dr Piotr Cybula

Object-Oriented Programming. Lecture 2 Dr Piotr Cybula Object-Oriented Programming Lecture 2 Dr Piotr Cybula Encapsulation : data protection code safety and independence better team support with the code separation without «giving

More information

Polymorphism. Zimmer CSCI 330

Polymorphism. Zimmer CSCI 330 Polymorphism Polymorphism - is the property of OOP that allows the run-time binding of a function's name to the code that implements the function. (Run-time binding to the starting address of the code.)

More information

Programming in C# Inheritance and Polymorphism

Programming in C# Inheritance and Polymorphism Programming in C# Inheritance and Polymorphism C# Classes Classes are used to accomplish: Modularity: Scope for global (static) methods Blueprints for generating objects or instances: Per instance data

More information

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING Wednesady 23 rd March 2016 Afternoon Answer any FOUR questions out of SIX. All

More information

Object Oriented Programming in C#

Object 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 information

Assignment 4 - Vectors, Menus, & Creatures!

Assignment 4 - Vectors, Menus, & Creatures! Assignment 4 - Vectors, Menus, & Creatures! Due Wednesday July 20, 2011 by 11:59pm You may not work on assignments during your lab time. Submit all the deliverables to the Course Management System: https://courses.cs.sfu.ca/

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes

More information

Midterm Exam CS 251, Intermediate Programming March 6, 2015

Midterm Exam CS 251, Intermediate Programming March 6, 2015 Midterm Exam CS 251, Intermediate Programming March 6, 2015 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

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

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in

More information

Instructions PLEASE READ (notice bold and underlined phrases)

Instructions PLEASE READ (notice bold and underlined phrases) Lab Exercises wk12 Practice with Linked Lists Required Reading Chapter 13 - Pointers and Linked Lists Lecture Slides on Linked Lists, Presented in class wk11 Instructions PLEASE READ (notice bold and underlined

More information

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

Cpt S 122 Data Structures. Course Review Midterm Exam # 2 Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm

More information

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011 UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011 1 Goals of the Lecture Review the material in Chapter 2 of the Textbook Cover key parts of the UML notation

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

Handout 7. Defining Classes part 1. Instance variables and instance methods.

Handout 7. Defining Classes part 1. Instance variables and instance methods. Handout 7 CS180 Programming Fundamentals Spring 15 Page 1 of 8 Handout 7 Defining Classes part 1. Instance variables and instance methods. In Object Oriented programming, applications are comprised from

More information

8.1 Inheritance. 8.1 Class Diagram for Words. 8.1 Words.java. 8.1 Book.java 1/24/14

8.1 Inheritance. 8.1 Class Diagram for Words. 8.1 Words.java. 8.1 Book.java 1/24/14 8.1 Inheritance superclass 8.1 Class Diagram for Words! Inheritance is a fundamental technique used to create and organize reusable classes! The child is- a more specific version of parent! The child inherits

More information

Inheritance and Interfaces

Inheritance and Interfaces Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical

More information

Object-Oriented Design

Object-Oriented Design Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration

More information

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

Department of Computer science and Engineering Sub. Name: Object oriented programming and data structures Sub. Code: EC6301 Sem/Class: III/II-ECE Staff name: M.Kavipriya Two Mark Questions UNIT-1 1. List

More information

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). UNITII Classes Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). It s a User Defined Data-type. The Data declared in a Class are called Data- Members

More information

Lecture 5: Methods CS2301

Lecture 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 information

Overriding המחלקה למדעי המחשב עזאם מרעי אוניברסיטת בן-גוריון

Overriding המחלקה למדעי המחשב עזאם מרעי אוניברסיטת בן-גוריון Overriding עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון 2 Roadmap A method in a child class overrides a method in the parent class if it has the same name and type signature: Parent void method(int,float)

More information

Declarations and Access Control SCJP tips

Declarations and Access Control  SCJP tips Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching

More information