EE219 Object Oriented Programming I (2006/2007) SEMESTER 1 SOLUTIONS
|
|
- Michael Daniels
- 6 years ago
- Views:
Transcription
1 Q1(a) Corrected code is: #include <iostream> using namespace std; class Shape protected: int x, y; public: Shape(int, int); ; EE219 Object Oriented Programming I (2006/2007) SEMESTER 1 SOLUTIONS Shape::Shape(int a, int b): x(a), y(b) class Circle: public Shape int rad; public: Circle(int, int, int); virtual void display(); ; Circle::Circle(int x, int y, int r): Shape(x,y), rad(r) void Circle::display() cout << "A circle with centre (" << x <<","<< y << ")"; cout << " and radius: " << rad << endl; int main(void) Circle c(10,10,5); c.display(); return 0; 1. rad should not have =0 as this is not allowed 2. a(x) and b(y) should be x(a), y(b) in the shape constructor 3. the Shape states should be protected, not private 4. d(12,12) is invalid as there is no such constructor 5. the word void is missing from the display implementation 6. the display method always displays x,y and not the values 7. missing using from the namespace statement 8. import should be include 9. There is no display method for the parent. Remove or write a method. [18 marks] Q1(b) DCU, student, staff, technician, lecturer, name, address, id, classroom, modules, desks, blackboard, phone, university EE219 - Semester /2007 Solutions Page 1 of 8
2 This answer is only one of hundreds available. Computer has software, hard-disk, CPU, DVD drive, colour, keyboard Laptop ISA Computer Desktop ISA computer Has monitor, mouse PC ISA computer DVD ISA disk Hard-disk ISA disk (questionable) CD-ROM ISA disk Dell ISA computer MacOS ISA software WindowsXP ISA software Linux ISA software -> can create an operating systems class LCD ISA monitor -> can create a CRT class etc. Students should draw a diagram of these relationships. Arrows must be in the correct direction, inheritance should be clear i.e. clearly distinguish ISA from IS A PART OF. [7 marks] Q2(a) #include <iostream> #include <string> using namespace std; class Vehicle int numberdoors, numberwheels; string color; public: Vehicle(int, int, string); virtual void display(); ; class Car: public Vehicle int numberseats; string modelname; public: Car(int, int, string, int, string); Car(Vehicle, int, string); virtual void display(); ; Vehicle::Vehicle(int numdoors, int numwheels, string col): numberdoors(numdoors), numberwheels(numwheels), color(col) void Vehicle::display() EE219 - Semester /2007 Solutions Page 2 of 8
3 cout << "The Vehicle has " << numberdoors << " doors, " // << numberwheels << " wheels, and is " << color << " in colour." << endl; Car::Car(int numdoors, int numwheels, string col, int numseats, string model): Vehicle(numDoors, numwheels, col), numberseats(numseats), modelname(model) Car::Car(Vehicle v, int numseats, string model): Vehicle(v), numberseats(numseats), modelname(model) void Car::display() Vehicle::display(); cout << " It is a Car with " << numberseats << " seats and " // << modelname << " as the model name" << endl; int main(void) Car c(5, 4, "blue", 5, "Toyota"); Car d(vehicle(3, 4, "red"), 2, "Ferrari"); c.display(); d.display(); return 0; Q2(b) [3 marks for each method approx] [18 marks] int main(void) Vehicle vehicles[3] = Vehicle(3, 4, "red"), Vehicle(5, 4, "blue"), Vehicle(4, 5, "green"); Vehicle *ptr = &vehicles[0]; for(int i=0; i<3; i++) ptr++->display(); return 0; a->display(); is equivalent to (*a).display(); [5 marks] [2 marks] [7 marks] 3(a) Pointers There are generally few problems with this fact as Java provides suitable replacement through the use of well-formatted references. Memory Management EE219 - Semester /2007 Solutions Page 3 of 8
4 The Java garbage collector manages all memory in Java. It reclaims all memory for objects once there are no remaining references to that object. When the garbage collector runs, it searches for all objects that have no references and reclaims the memory. C++ developers are required to provide their own memory management routines, otherwise a complex C++ application, running for a long period would simply cause the computer to run out of memory. Implementing memory management correctly in C++ is complicated, and so memory leaks are a very frequent problem with C++ developed applications. Garbage collection was not added to the C++ language specification, as all developers would be required to deal with a standard garbage collector and every C++ application would incur the overhead. There are many 3rd party C++ garbage collectors available, such as the Boehm-Demers-Weiser conservative garbage collector, that replaces the C malloc() or C++ new calls (It can alternatively be used as a leak detector!). Access Specifiers Like C++, in Java we have public, private and protected access specifiers, but we also have another access specifier "package". This is the default access specifier and means that all states and methods are accessible to all classes within the same package. There is no package access specifier keyword, it is simply the default if public, private or protected are not used. Access specifiers in Java are: public - accessible everywhere, an interface method (same as C++) private - accessible only in the class where it was defined (same as C++) protected - accessible in the class where it is defined, the derived classes and in the same package (almost the same as C++ with the exception of the package) "package" - default (there is no package specifier keyword) and means that it is accessible by any class in the same package. You can equate this to the C++ friendly condition by saying that all of the classes in the same package (directory) are friendly. In Java there is no direct equivalent to protected in C++. In Java version 1.0 there was! it was called "private protected", but was deemed complex and unnecessary, and so was removed. Destructors There are no destructors in Java, even thought there is a new keyword, there is no corresponding delete keyword, as Java takes care of all of the memory managment. Java has a special finalize() method that you can add to any class. The strange thing about this method is that you can use it for tidying up (printing a paper record for Account etc.), but you do not know when it will be called. In C++ this was easier, as the destructor is called when the object goes out of scope, but in Java the finalize() method will be called when the garbage collector destroys the object. We do not know when this will be called! As discussed previously, we can request that the garbage collector should run, but we do not know when it will run! You can help the garbage collector slightly by setting all your references to null when you no longer need them, e.g. a = null; - will send a hint to the garbage collector that the object is no longer being used. [12 marks] 3(b) Namespaces allow the programmer to define a region that is limited in scope. When writing C++ applications we can make it explicit that we are using the standard namespace by a "using directive": using namespace std; // i.e. I want to use the declarations and EE219 - Semester /2007 Solutions Page 4 of 8
5 // definitions in the "Standard Library" // namespace at the beginning of our code segments, however this can be considered poor practice in certain circumstances as the entire contents of the namespace are included. The alternative is to make it explicit that we were calling the standard cout output stream by typing: std::cout << "Hello World!" << std::endl; which states that the cout and endl that we wish to use are both defined in the std standard library. It is possible to include the exact namespace member to be included by a "using declaration":: using std::cout; would allow us to use cout without including all of the names in the std namespace. Packages are groups of similar classes, that can be, but are not necessarily related to each other through an inheritance structure. Packages are classes organised into directories on a file system. Packages are '.' separated words, where the package refers to the directory that the class files are in. For example java.awt (the directory /java/awt/ is a package that stores the classes for creating buttons, textfields, etc. A package can also contain more packages in a subfolder. For example, java.awt.event contains classes for events, within the awt package. Use the import keyword to load in packages. Multiple classes can be loaded using the * character. So, for example,import java.awt.*; imports all the classes in the awt package, but please note, it does not include classes in the sub-packages, so, you must explicitly import java.awt.event.*;. In a source file, if no package name is defined on an import e.g. import SomeClass; then it is assumed that the class SomeClass is in the same directory as the source file. Packages are very similar to a combination of C++ namespaces and includes, only a lot easier to use. Packages and Namespaces can be nested. There is a friendly default access specifier in java that shares across packages. There is no such access specifier in C++. [11 marks] 4(a) Java applets generally do not have a main() method. What is the lifecycle of a Java applet and what standard methods do we have to write? If we do not write one of these methods will the Applet compile? EE219 - Semester /2007 Solutions Page 5 of 8
6 The life cycle of the applet has the following stages: The appletviewer loads and creates the specified class. The applet initializes itself. The applet starts running. When finished the applet is destroyed. The applet always receives an init() method first and then a start() and paint() call (Note: This may happen asynchronously! i.e. at the same time). init() - This method 'sets-up' the applet, called once when the applet is first initialized. Use this method to set up the display of the applet, set colours etc. start() - Called whenever the applet is visited, i.e. the applet starts running again. You could use this method to start up an animation that stops when the applet is minimised. This method would be called when the web browser has been restored after being minimised. stop() - Called when the applet is no longer active (e.g. minimized) paint()- This method is called whenever the appearance of the applet is required to be updated, such as when the applet is being maximized from a minimized state. The appearance needs to be updated. It is also possible for the programmer to call this method. This method does nothing by default, you must write the code. destroy() - Called when the applet is discarded. This method should perform any closing down tasks that you would wish to perform, such as closing connections to databases, etc. If we do not write one of these methods then the applet will still compile as the method will be inherited from the parent Applet class. [9 marks] 4(b) This is better than making the accountnumber state public, retaining encapsulation. Inline is ignored with virtual methods. We can provide full access to a state through methods, rather than directly to the state by making it public, by providing an accessor and a mutator. For example for the accountnumber state in the Account class, these would look like int getaccountnumber(); //accessor void setaccountnumber(int newnumber); //mutator The main advantage of this format is that access can be controlled to the accountnumber state, so, if additional functionality is required at a later stage, it can be achieved, without effecting the developers using the Account class. We can also declare standalone methods (global methods) to be inline, such as: inline int account::getaccountnumber() //etc 4(c) The output is: x has the value: 1 [5 marks] EE219 - Semester /2007 Solutions Page 6 of 8
7 y has the value: z has the value: 14 This is because x=z++ increments z after the assignment has taken place. Y is undefined as variables in c++ are not set to zero on initialisation and z has the value of 14 as it is assigned the last value of i in the loop (i.e. 9) then it is added to the previous value of i, which is 5, giving a total of 14. Q4(d) [6 marks] By default, every class extends the Object class, even if you don't extend any class. The Object class provides methods that are inherited by all Java classes, such as equals(), getclass(), tostring() and more. The Class class (called class descriptors) are automatically created and associated with the objects to which they refer. For example, the getname() and tostring() methods return the String containing the name of the class or interface. We could use this to compare the classes of objects. Q5(a) [5 marks] import java.awt.*; import java.awt.event.*; import java.applet.*; public class VectorApplet extends Applet implements ActionListener TextField u1str, u2str, v1str, v2str, thetastr; float u1, u2, v1, v2, theta; public void init() this.add(new Label(" u = (")); u1str = new TextField("0.0"); this.add(u1str); this.add(new Label(",")); u2str = new TextField("0.0"); this.add(u2str); this.add(new Label(") and v = (")); v1str = new TextField("0.0"); this.add(v1str); this.add(new Label(",")); v2str = new TextField("0.0"); this.add(v2str); EE219 - Semester /2007 Solutions Page 7 of 8
8 this.add(new Label("), gives theta = ")); thetastr = new TextField("0", 10); this.add(thetastr); Button b = new Button("go"); b.addactionlistener(this); this.add(b); this.setsize(500,40); public void actionperformed(actionevent e) try u1 = Float.valueOf(u1str.getText()).floatValue(); u2 = Float.valueOf(u2str.getText()).floatValue(); v1 = Float.valueOf(v1str.getText()).floatValue(); v2 = Float.valueOf(v2str.getText()).floatValue(); catch(exception ex) float magu = (float) Math.sqrt((u1*u1) + (u2*u2)); float magv = (float) Math.sqrt((v1*v1) + (v2*v2)); float dotuv = (u1*v1) + (u2*v2); theta = (float) Math.acos(dotuv/(magu*magv)); thetastr.settext(float.tostring((float)math.todegrees(theta))); HTML page: <title> Question 5 Page </title> <hr> <applet code=question5.class width=200 height=200> </applet> <hr> [25 marks] [3 marks for HTML page, 4 marks for layout, 5 marks for events, 10 marks for functionality, 3 mark for states etc] Note Maths must be perfect as API documentation was provided. EE219 - Semester /2007 Solutions Page 8 of 8
EE219 Object Oriented Programming I (2007/2008) REPEAT SOLUTIONS
Q1(a) Corrected code is: EE219 Object Oriented Programming I (2007/2008) REPEAT SOLUTIONS 00 #include 01 using namespace std; 02 03 class Shape 04 05 protected: 06 float posx, posy; 07 public:
More informationDUBLIN CITY UNIVERSITY
DUBLIN CITY UNIVERSITY SEMESTER ONE EXAMINATIONS 2007 MODULE: Object Oriented Programming I - EE219 COURSE: B.Eng. in Electronic Engineering B.Eng. in Information Telecommunications Engineering B.Eng.
More informationEE219 - Semester /2009 Solutions Page 1 of 10
EE219 Object Oriented Programming I (2008/2009) SEMESTER 1 SOLUTIONS Q1(a) Corrected code is: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
More informationEE219 Object Oriented Programming I Repeat Solutions for 2005/2006
EE219 Object Oriented Programming I Repeat Solutions for 2005/2006 Q1(a) Corrected Code: #include using namespace std; class Question1 int a,b; public: Question1(); Question1(int, int); virtual
More informationEE219 Object Oriented Programming I (2005/2006) SEMESTER 1 SOLUTIONS
Q1(a) Corrected code is: EE219 Object Oriented Programming I (2005/2006) SEMESTER 1 SOLUTIONS 01 #include 02 using namespace std; 03 04 class Question1 05 06 int a,b,*p; 07 08 public: 09 Question1(int
More informationObject-Oriented Programming EE219 Repeat 2004/2005 Page 1 of 8
REPEAT EXAMINATIONS SOLUTIONS 2004/2005 MODULE: Object-Oriented Programming for Engineers EE219 COURSE: B.Eng. in Electronic Engineering B.Eng. in Telecommunications Engineering B.Eng. in Digital Media
More informationDUBLIN CITY UNIVERSITY
DUBLIN CITY UNIVERSITY REPEAT EXAMINATIONS 2008 MODULE: Object-oriented Programming I - EE219 COURSE: B.Eng. in Electronic Engineering (Year 2 & 3) B.Eng. in Information Telecomms Engineering (Year 2 &
More informationSEMESTER ONE EXAMINATIONS SOLUTIONS 2003/2004
SEMESTER ONE EXAMINATIONS SOLUTIONS 2003/2004 MODULE: Object-Oriented Programming for Engineers EE219 COURSE: B.Eng. in Electronic Engineering B.Eng. in Telecommunications Engineering B.Eng. in Digital
More informationCSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010
CSE 374 Programming Concepts & Tools Hal Perkins Spring 2010 Lecture 19 Introduction ti to C++ C++ C++ is an enormous language: g All of C Classes and objects (kind of like Java, some crucial differences)
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationChapter 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 informationCSE 303: Concepts and Tools for Software Development
CSE 303: Concepts and Tools for Software Development Hal Perkins Autumn 2008 Lecture 24 Introduction to C++ CSE303 Autumn 2008, Lecture 24 1 C++ C++ is an enormous language: All of C Classes and objects
More informationSEMESTER ONE EXAMINATIONS 2008/2009 SOLUTIONS. Object-Oriented Programming for Engineers - EE553
SEMESTER ONE EXAMINATIONS 2008/2009 SOLUTIONS MODULE: COURSE: Object-Oriented Programming for Engineers - EE553 M.Eng./Grad. Dip./Grad. Cert. in Electronic Systems M.Eng./Grad. Dip./Grad. Cert. in Telecomms.
More informationEL2310 Scientific Programming
Lecture 14: Object Oriented Programming in C++ (ramviyas@kth.se) Overview Overview Lecture 14: Object Oriented Programming in C++ Classes (cont d) More on Classes and Members Group presentations Last time
More informationAssumptions. History
Assumptions A Brief Introduction to Java for C++ Programmers: Part 1 ENGI 5895: Software Design Faculty of Engineering & Applied Science Memorial University of Newfoundland You already know C++ You understand
More informationCSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 19 Introduction to C++ C++ C++ is an enormous language: All of C Classes and objects (kind of like Java, some crucial differences) Many
More informationJava Applet Basics. Life cycle of an applet:
Java Applet Basics Applet is a Java program that can be embedded into a web page. It runs inside the web browser and works at client side. Applet is embedded in a HTML page using the APPLET or OBJECT tag
More informationObject Oriented Design
Object Oriented Design Lecture 3: Introduction to C++ (Continue) Examples using declarations that eliminate the need to repeat the std:: prefix 1 Examples using namespace std; enables a program to use
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationCE221 Programming in C++ Part 1 Introduction
CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationG51PRG: Introduction to Programming Second semester Applets and graphics
G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting
More informationCS 11 C++ track: lecture 1
CS 11 C++ track: lecture 1 Administrivia Need a CS cluster account http://www.cs.caltech.edu/cgi-bin/ sysadmin/account_request.cgi Need to know UNIX (Linux) www.its.caltech.edu/its/facilities/labsclusters/
More informationFunctions and Recursion
Functions and Recursion 1 Storage Classes Scope Rules Functions with Empty Parameter Lists Inline Functions References and Reference Parameters Default Arguments Unary Scope Resolution Operator Function
More informationInterview 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 informationCA341 - Comparative Programming Languages
CA341 - Comparative Programming Languages David Sinclair Dynamic Data Structures Generally we do not know how much data a program will have to process. There are 2 ways to handle this: Create a fixed data
More informationFast Introduction to Object Oriented Programming and C++
Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming
More informationWeek 9. Abstract Classes
Week 9 Abstract Classes Interfaces Arrays (Assigning, Passing, Returning) Multi-dimensional Arrays Abstract Classes Suppose we have derived Square and Circle subclasses from the superclass Shape. We may
More informationG52CPP C++ Programming Lecture 13
G52CPP C++ Programming Lecture 13 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture Function pointers Arrays of function pointers Virtual and non-virtual functions vtable and
More informationGet Unique study materials from
Downloaded from www.rejinpaul.com VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : IV Section : EEE - 1 & 2 Subject Code
More informationCMSC 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 informationObject-Oriented Programming for Scientific Computing
Object-Oriented Programming for Scientific Computing Dynamic Memory Management Ole Klein Interdisciplinary Center for Scientific Computing Heidelberg University ole.klein@iwr.uni-heidelberg.de 2. Mai 2017
More informationObject Oriented Programming COP3330 / CGS5409
Object Oriented Programming COP3330 / CGS5409 Inheritance Assignment 5 Many types of classes that we create can have similarities. Useful to take advantage of the objectoriented programming technique known
More informationAn applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a
CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled
More informationProgramming, numerics and optimization
Programming, numerics and optimization Lecture A-4: Object-oriented programming Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428
More informationIntroduction to Programming using C++
Introduction to Programming using C++ Lecture One: Getting Started Carl Gwilliam gwilliam@hep.ph.liv.ac.uk http://hep.ph.liv.ac.uk/~gwilliam/cppcourse Course Prerequisites What you should already know
More informationC How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. 1
C How to Program, 6/e 1 Structures : Aggregate data types are built using elements of other types struct Time { int hour; int minute; Members of the same structure must have unique names. Two different
More informationAN OVERVIEW OF C++ 1
AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function
More informationIntermediate Programming, Spring 2017*
600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general
More informationReview. Outline. Array Pointer Object-Oriented Programming. Fall 2013 CISC2200 Yanjun Li 1. Fall 2013 CISC2200 Yanjun Li 2
Review Fall 2013 CISC2200 Yanjun Li 1 Outline Array Pointer Object-Oriented Programming Fall 2013 CISC2200 Yanjun Li 2 1 Array Arrays are data structures containing related data items of same type. An
More informationPraktikum: Entwicklung interaktiver eingebetteter Systeme
Praktikum: Entwicklung interaktiver eingebetteter Systeme C++-Labs (falk@cs.fau.de) 1 Agenda Writing a Vector Class Constructor, References, Overloading Templates, Virtual Functions Standard Template Library
More informationObjects 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 informationCS24 Week 3 Lecture 1
CS24 Week 3 Lecture 1 Kyle Dewey Overview Some minor C++ points ADT Review Object-oriented Programming C++ Classes Constructors Destructors More minor Points (if time) Key Minor Points const Motivation
More informationReview. Outline. Array Pointer Object-Oriented Programming. Fall 2017 CISC2200 Yanjun Li 1. Fall 2017 CISC2200 Yanjun Li 2
Review Fall 2017 CISC2200 Yanjun Li 1 Outline Array Pointer Object-Oriented Programming Fall 2017 CISC2200 Yanjun Li 2 1 Computer Fall 2017 CISC2200 Yanjun Li 3 Array Arrays are data structures containing
More informationCS
CS 1666 www.cs.pitt.edu/~nlf4/cs1666/ Programming in C++ First, some praise for C++ "It certainly has its good points. But by and large I think it s a bad language. It does a lot of things half well and
More informationOBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING Design principles for organizing code into user-defined types Principles include: Encapsulation Inheritance Polymorphism http://en.wikipedia.org/wiki/encapsulation_(object-oriented_programming)
More informationMidterm Exam 5 April 20, 2015
Midterm Exam 5 April 20, 2015 Name: Section 1: Multiple Choice Questions (24 pts total, 3 pts each) Q1: Which of the following is not a kind of inheritance in C++? a. public. b. private. c. static. d.
More informationCS 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 informationCpt S 122 Data Structures. Introduction to C++ Part II
Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function
More informationIntroduction Of Classes ( OOPS )
Introduction Of Classes ( OOPS ) Classes (I) A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions. An object is an instantiation of a class.
More information15: Polymorphism & Virtual Functions
15: Polymorphism & Virtual Functions 김동원 2003.02.19 Overview virtual function & constructors Destructors and virtual destructors Operator overloading Downcasting Thinking in C++ Page 1 virtual functions
More informationINTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 9: Writing Java Applets. Introduction
INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 9: Writing Java Applets Introduction Applets are Java programs that execute within HTML pages. There are three stages to creating a working Java
More informationObject Oriented Programming COP3330 / CGS5409
Object Oriented Programming COP3330 / CGS5409 Classes & Objects DDU Design Constructors Member Functions & Data Friends and member functions Const modifier Destructors Object -- an encapsulation of data
More informationEL2310 Scientific Programming
(pronobis@kth.se) Overview Overview Wrap Up Introduction to Object Oriented Paradigm More on and Members Operator Overloading Last time Intro to C++ Differences between C and C++ Intro to OOP Today Object
More informationCOMP 2355 Introduction to Systems Programming
COMP 2355 Introduction to Systems Programming Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 Today Class syntax, Constructors, Destructors Static methods Inheritance, Abstract
More informationCSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory
Announcements CSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory There will be no lecture on Tuesday, Feb. 16. Prof. Thompson s office hours are canceled for Monday, Feb. 15. Prof.
More informationGovernment Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING
Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++
More informationPolymorphism 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 informationObject Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name:
Object Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name: Section 1 Multiple Choice Questions (40 pts total, 2 pts each): Q1: Employee is a base class and HourlyWorker is a derived class, with
More informationA Tour of the C++ Programming Language
A Tour of the C++ Programming Language We already know C Everything that can be done with a computer, can be done in C Why should we learn another language? Newer languages provide a bigger toolbox Some
More informationProgramming in C++: Assignment Week 5
Programming in C++: Assignment Week 5 Total Marks : 20 Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology Kharagpur 721302 partha.p.das@gmail.com April 3, 2017
More informationIntroduction to Java
Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn
More informationTime : 3 hours. Full Marks : 75. Own words as far as practicable. The questions are of equal value. Answer any five questions.
XEV (H-3) BCA (6) 2 0 1 0 Time : 3 hours Full Marks : 75 Candidates are required to give their answers in their Own words as far as practicable. The questions are of equal value. Answer any five questions.
More informationEL2310 Scientific Programming
Lecture 14: Object Oriented Programming in C++ (fpokorny@kth.se) Overview Overview Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes
More informationCE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings
CE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings 19/10/2017 CE221 Part 2 1 Variables and References 1 In Java a variable of primitive type is associated with a memory location
More informationPROGRAMMING LANGUAGE 2
1 PROGRAMMING LANGUAGE 2 Lecture 13. Java Applets Outline 2 Applet Fundamentals Applet class Applet Fundamentals 3 Applets are small applications that are accessed on an Internet server, transported over
More informationCMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am
CMSC 202 Section 010x Spring 2007 Computer Science II Final Exam Name: Username: Score Max Section: (check one) 0101 - Justin Martineau, Tuesday 11:30am 0102 - Sandeep Balijepalli, Thursday 11:30am 0103
More informationObject Oriented Programming: Inheritance Polymorphism
Object Oriented Programming: Inheritance Polymorphism Shahram Rahatlou Computing Methods in Physics http://www.roma1.infn.it/people/rahatlou/cmp/ Anno Accademico 2018/19 Today s Lecture Introduction to
More informationJava Basic Syntax. Java vs C++ Wojciech Frohmberg / OOP Laboratory. Poznan University of Technology
Java vs C++ 1 1 Department of Computer Science Poznan University of Technology 2012.10.07 / OOP Laboratory Outline 1 2 3 Outline 1 2 3 Outline 1 2 3 Tabular comparizon C++ Java Paradigm Procedural/Object-oriented
More informationG52CPP C++ Programming Lecture 14. Dr Jason Atkin
G52CPP C++ Programming Lecture 14 Dr Jason Atkin 1 Last Lecture Automatically created methods: A default constructor so that objects can be created without defining a constructor A copy constructor used
More informationLecture 2, September 4
Lecture 2, September 4 Intro to C/C++ Instructor: Prashant Shenoy, TA: Shashi Singh 1 Introduction C++ is an object-oriented language and is one of the most frequently used languages for development due
More informationEND TERM EXAMINATION
END TERM EXAMINATION THIRD SEMESTER [BCA] DECEMBER 2007 Paper Code: BCA 209 Subject: Object Oriented Programming Time: 3 hours Maximum Marks: 75 Note: Attempt all questions. Internal choice is indicated.
More informationProgramming. C++ Basics
Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++
More informationObject-Oriented Programming. Lecture 4 Dr Piotr Cybula
Object-Oriented Programming Lecture 4 Dr Piotr Cybula Inheritance enrichment of existing classes with additional functionality ability of modifying the action of methods without
More informationSRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR
SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name
More informationJava Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application
Last Time v We created our first Java application v What are the components of a basic Java application? v What GUI component did we use in the examples? v How do we write to the standard output? v An
More informationIntroduction to Inheritance
INHERITANCE Introduction to Inheritance Inheritance is a relationship between two or more classes where derived class inherites behaviour and attributes of pre-existing (base) classes Intended to help
More informationIntroduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview
Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple
More informationG52CPP C++ Programming Lecture 16
G52CPP C++ Programming Lecture 16 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last Lecture Casting static cast dynamic cast const cast reinterpret cast Implicit type conversion 2 How
More informationC++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez!
C++ Mini-Course Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion C Rulez! C++ Rulez! C++ Mini-Course Part 1: Mechanics C++ is a
More informationLecture 8: Object-Oriented Programming (OOP) EE3490E: Programming S1 2017/2018 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology
Lecture 8: Object-Oriented Programming (OOP) 1 Introduction to C++ 2 Overview Additional features compared to C: Object-oriented programming (OOP) Generic programming (template) Many other small changes
More informationthe gamedesigninitiative at cornell university Lecture 7 C++ Overview
Lecture 7 Lecture 7 So You Think You Know C++ Most of you are experienced Java programmers Both in 2110 and several upper-level courses If you saw C++, was likely in a systems course Java was based on
More informationA Tour of the C++ Programming Language
A Tour of the C++ Programming Language We already know C Everything that can be done with a computer, can be done in C Why should we learn another language? Newer languages provide a bigger toolbox Some
More informationCS3157: 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 informationClasses in C++98 and C++11
Classes in C++98 and C++11 January 10, 2018 Brian A. Malloy Slide 1 of 38 1. When we refer to C++98, we are referring to C++98 and C++03, since they differ only slightly. C++98 contained 3 types of constructors,
More informationCS250 Final Review Questions
CS250 Final Review Questions The following is a list of review questions that you can use to study for the final. I would first make sure you review all previous exams and make sure you fully understand
More informationC++ Programming Classes. Michael Griffiths Corporate Information and Computing Services The University of Sheffield
C++ Programming Classes Michael Griffiths Corporate Information and Computing Services The University of Sheffield Email m.griffiths@sheffield.ac.uk Presentation Outline Differences between C and C++ Object
More informationUse the template below and fill in the areas in Red to complete it.
C++ with Inheritance Pproblem involving inheritance. You have to finish completing code that creates a class called shape, from which 3 classes are derived that are called square and triangle. I am giving
More informationWeek 0: Intro to Computers and Programming. 1.1 Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components
Week 0: Intro to Computers and Programming Gaddis: Sections 1.1-3 and 2.1 CS 1428 Fall 2014 Jill Seaman 1.1 Why Program? Computer programmable machine designed to follow instructions Program instructions
More informationCSE 333 Final Exam December 13, 2017 Sample Solution
Question 1. (16 points) STL. Implement the template function is_sorted, below, so it returns true if its list argument is sorted in non-decreasing order, and returns false if not. Your function should
More informationC++ (Non for C Programmer) (BT307) 40 Hours
C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular
More informationConstructor - example
Constructors A constructor is a special member function whose task is to initialize the objects of its class. It is special because its name is same as the class name. The constructor is invoked whenever
More informationProgramming in C and C++
Programming in C and C++ 6. C++: Operators, Inheritance, Virtual Methods Dr. Neel Krishnaswami University of Cambridge (based on notes from and with thanks to Anil Madhavapeddy, Alan Mycroft, Alastair
More informationExtending Classes (contd.) (Chapter 15) Questions:
Extending Classes (contd.) (Chapter 15) Questions: 1 1. The following C++ program compiles without any problems. When run, it even prints out the hello called for in line (B) of main. But subsequently
More informationCSE 333 Lecture 9 - intro to C++
CSE 333 Lecture 9 - intro to C++ Hal Perkins Department of Computer Science & Engineering University of Washington Administrivia & Agenda Main topic: Intro to C++ But first: Some hints on HW2 Labs: The
More informationPHY4321 Summary Notes
PHY4321 Summary Notes The next few pages contain some helpful notes that summarize some of the more useful material from the lecture notes. Be aware, though, that this is not a complete set and doesn t
More informationLecture Static Methods and Variables. Static Methods
Lecture 15.1 Static Methods and Variables Static Methods In Java it is possible to declare methods and variables to belong to a class rather than an object. This is done by declaring them to be static.
More informationCS93SI Handout 04 Spring 2006 Apr Review Answers
CS93SI Handout 04 Spring 2006 Apr 6 2006 Review Answers I promised answers to these questions, so here they are. I'll probably readdress the most important of these over and over again, so it's not terribly
More informationPaytm 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 informationAppendix G: Writing Managed C++ Code for the.net Framework
Appendix G: Writing Managed C++ Code for the.net Framework What Is.NET?.NET is a powerful object-oriented computing platform designed by Microsoft. In addition to providing traditional software development
More information