Object-Oriented Programming EE219 Repeat 2004/2005 Page 1 of 8
|
|
- Penelope Perry
- 5 years ago
- Views:
Transcription
1 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 Engineering INSTRUCTIONS: Answer FOUR questions. All questions carry equal marks. Question 1. (a) The corrected code is: #include<iostream.h> class Question1Parent int a; public: Question1Parent(int); virtual void display(); ; class Question1: Question1Parent int b; public: Question1(int,int); virtual void display(); ; Question1Parent::Question1Parent(int x): a(x) Question1::Question1(int x, int y): Question1Parent(x), b(y) void Question1Parent::display() cout << "a = " << a << endl; Page 1 of 8
2 void Question1::display() Question1Parent::display(); cout << "b = " << b << endl; int main(void) Question1 a(1,2),b(3,4),c(5,6); a.display(); The errors are: 1. Question1Parent(), b(y) missing parameter for constructor 2. missing ; from class definition 3. Question1Parent missing Question1Parent:: 4. c() cannot be called in main() as the default constructor has been replaced. 5. void is missing from the display() method. 6. the Question1Parent constructor is missing its type in the definition. 7. the return in main() is int, where there is no return type [2 points each = 14total] (b) End-of-line comments allow the compiler to ignore from // to the end of the line. Block comments are started by /* and ended by */ End of line comments can be nested and block comments cannot. You should use end of line comments where possible as block comments are very useful for commenting out a section of code when debugging. x = x * 4.533; // explain what you are doing // end of line commenting /* An example of block commenting */ y = 5 * 3; /* TODO: This section needs to be fixed! Derek 25/12/99 j = j * ; k = k * j + 1; */ (c) The code would be: [5 marks] Account *ptr; ptr = &a; a->display(); [6 marks 2 for each line] Question 2. (a) #include<string> #include<iostream> Page 2 of 8
3 using namespace std; class Account string owner; int number; float balance; public: Account(string, int, float); virtual void display(); ; class Deposit: public Account float interestrate; public: Deposit(string, int, float, float); Deposit(Account, float); virtual void display(); ; Account::Account(string theowner, int actnum, float thebalance): owner(theowner), number(actnum), balance(thebalance) void Account::display() cout << "The owner is: " << owner << endl; cout << "The account number is: " << number << endl; cout << "The balance is: " << balance << endl; Deposit::Deposit(string theowner, int actnum, float thebalance, float rate): Account(theOwner, actnum, thebalance), interestrate(rate) Deposit::Deposit(Account theaccount, float rate): Account(theAccount), interestrate(rate) void Deposit::display() Account::display(); cout << "The interest rate is: " << interestrate << endl; (b) [15 marks 3 per method] int main(void) Account a("derek Molloy", 12345, f); Deposit d(a, 0.05f); d.display(); [6 marks] (c) Default parameters can be added to the end of a parameter list. If a value is to be passed to a particular default parameter, then the preceding default parameters must also be passed. For example: void decrement(int &avalue, int amount=1) Page 3 of 8
4 avalue = avalue - amount; [4 marks] Question 3. (a) What are abstract classes? How does the notation differ from C++ to Java? An abstract class is a class that is incomplete, in that it describes a set of operations, but is missing the actual implementation of these operations. Abstract classes: Cannot be instantiated. So, can only be used through inheritance. For example: In the Vehicle class example previously the draw() method may be defined as abstract as it is not really possible to draw a generic vehicle. By doing this we are forcing all derived classes to write a draw() method if they are to be instantiated. virtual string getaccounttype() = 0; The assignment = 0 allows the method to be defined as abstract. This means that no implementation will be present for that method, in this case the getaccounttype() method. While abstract classes are not much different to abstract classes in C++, there are some points to note. Once again, abstract methods are a place-holder that define a set of operations within the class that have not yet been implemented. In Java you can actually set a class to be abstract, even if it has no abstract methods. This would prevent this class from being instantiated. However, if one or more methods in a class are abstract then the class must be defined as abstract. [12 marks] Page 4 of 8
5 [6 marks for description] [3 cpp notation] [3 java notation] (b) Explain pass-by-value and pass-by-reference. Write a short segment of code to demonstrate the difference? 8 float addinterest(float val, float rate) 9 10 return val + (val * (rate/100)); void main() float balance = 5000; 16 float irate = 5.0; balance = addinterest(balance, irate); cout << "After interest your balance is " 21 << balance << " Euro." << endl; 22 The previous code segment passed values to the function using pass by value. In this case you are really passing the value of the variables balance and irate, so in this case the numbers 5000 and 5.0. It is only possible to have one return value when passing by value. If we wish to have multiple return values, or wish to modify the source then we can pass by reference. This example is the same as the previous example except this time we are passing by reference: Passing by reference is like passing a copy of the name of the variable to the method. void addinterest(float &val, float rate) 9 10 val = val + (val * (rate/100)); void main() float balance = 5000; 16 float irate = 5.0; addinterest(balance,irate); cout << "After interest your balance is " 21 << balance << " Euro." << endl; 22 [13 marks] [4 marks for each segment] [5 marks for discussion] Question 4. Page 5 of 8
6 (a) The String class provides a convenient mechanism for working with strings in Java. String objects in Java are immutable - once assigned a value, it cannot be changed. The compiler converts string constants to String objects directly. String object comparisons are achieved using the compareto() and equals() methods. The StringBuffer object can be used instead of a String object when more flexibilty is required in the object. The StringBuffer class is mutable and so can grow in size as the application runs. We can convert directly between a String object and a StringBuffer object when required. StringBuffer buffer = new StringBuffer(s); buffer.insert(5, " to the"); String t = buffer.tostring(); (b) Explain the concept of packages in Java. How are they used? [8 marks] 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, classes for events, within the awt package. java.awt.event contains 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. (c) Explain the Java terms super and this. [5 marks] super - allows us to refer to the parent class directly. So, super.display() would call the display() method, written or inherited by the parent class. If the parent class of the parent class with a display() method also had a display() method, we do not have access to that method. this - allows us to refer to the object of this class that we are currently within. It allows us to pass a reference to the current object and it also allows us to access the states of the class that are currently out of scope. (b) Explain the Java classes Object class and Class class. [6 marks] [3 marks each] 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 Page 6 of 8
7 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. (c) What is a Java interface? [6 marks] [3 marks each] A Java Interface is a way of grouping methods that describe a particular behaviour. They allow developers to reuse design and they capture similarity, independent of the class hierarchy. We can share both methods and constants using Interfaces, but there can be no states in an interface. Methods in an interface are implicitly public and abstract. Constant states in an interface are implicitly public, static and final. [3 marks] Question 5. (a) Write the Java code and HTML code for the applet below. /* * Created on Oct 22, 2004 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ import java.awt.*; import java.applet.*; import java.awt.event.*; /** Derek Molloy * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class TestClass extends Applet implements ActionListener private Button rev= new Button("Reverse Text"); private Button clr = new Button("Clear Text"); private TextField t = new TextField(20); public void init() this.add(t); this.add(rev); this.add(clr); rev.addactionlistener(this); clr.addactionlistener(this); Page 7 of 8
8 private void reversetext() int len = t.gettext().length(); char[] newtext = new char[len]; for (int i=0; i<len; i++) newtext[i] = t.gettext().charat(len-i-1); t.settext(new String(newText)); public void actionperformed(actionevent e) if (e.getsource().equals(rev)) reversetext(); else t.settext(""); <html><title>test</title> <body> <center> <applet width=500 height=100 code="testclass.class"></applet> </center> </html> Marks [3 for html][3 for buttons][2 for textfield][3 for counting][2 for layout][3 for events] [2 for update][3 for actionperformed] [20 in total] Java provides us with the Canvas class that acts like any other component, but also allows you to draw graphics directly to it - just like an artist's canvas. The other advantage of using a component is that you can take advantage of the layout managers to control how the applet/application will place the component as it is moved or resized. The Canvas component specifies its co-ordinate system at (0,0) for the top left-hand corner. Canvas components can handle mouse events like the Applet class. You must subclass Canvas to add the behaviour you require, modifing the paint() method. So, for example: [5 marks] Page 8 of 8
SEMESTER 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 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 - 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 (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 informationEE219 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 informationEE219 Object Oriented Programming I (2006/2007) SEMESTER 1 SOLUTIONS
Q1(a) Corrected code is: #include 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
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationObjective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5
Objective Questions BCA Part III page 1 of 5 1. Java is purely object oriented and provides - a. Abstraction, inheritance b. Encapsulation, polymorphism c. Abstraction, polymorphism d. All of the above
More informationCSCE3193: Programming Paradigms
CSCE3193: Programming Paradigms Nilanjan Banerjee University of Arkansas Fayetteville, AR nilanb@uark.edu http://www.csce.uark.edu/~nilanb/3193/s10/ Programming Paradigms 1 Java Packages Application programmer
More informationFriend Functions, Inheritance
Friend Functions, Inheritance Friend Function Private data member of a class can not be accessed by an object of another class Similarly protected data member function of a class can not be accessed by
More informationJava - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,
Java - Applets C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1, 5.3.2. Java is not confined to a DOS environment. It can run with buttons and boxes in a Windows
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 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 information8. Polymorphism and Inheritance
8. Polymorphism and Inheritance Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives Describe polymorphism and inheritance in general Define interfaces
More informationSEMESTER ONE EXAMINATIONS SOLUTIONS 2004
SEMESTER ONE EXAMINATIONS SOLUTIONS 2004 MODULE: Object-Oriented Programming for Engineers EE553 COURSE: M.Eng./Grad. Dip./Grad. Cert. in Electronic Systems M.Eng./Grad. Dip./Grad. Cert. in Telecommunications
More informationJava - Applets. public class Buttons extends Applet implements ActionListener
Java - Applets Java code here will not use swing but will support the 1.1 event model. Legacy code from the 1.0 event model will not be used. This code sets up a button to be pushed: import java.applet.*;
More informationJava 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 information15CS45 : OBJECT ORIENTED CONCEPTS
15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?
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 informationLecture 18 CSE11 Fall 2013 Inheritance
Lecture 18 CSE11 Fall 2013 Inheritance What is Inheritance? Inheritance allows a software developer to derive a new class from an existing one write code once, use many times (code reuse) Specialization
More informationCS Exam 1 Review Suggestions
CS 235 - Fall 2015 - Exam 1 Review Suggestions p. 1 last modified: 2015-09-30 CS 235 - Exam 1 Review Suggestions You are responsible for material covered in class sessions, lab exercises, and homeworks;
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 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 informationProgramming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017
Programming Language Concepts Object-Oriented Programming Janyl Jumadinova 28 February, 2017 Three Properties of Object-Oriented Languages: Encapsulation Inheritance Dynamic method binding (polymorphism)
More informationKapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class
Chapter 6 Inheritance Extending a Class Introduction; Need for Inheritance; Different form of Inheritance; Derived and Base Classes; Inheritance and Access control; Multiple Inheritance Revisited; Multilevel
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 informationChapter 1 GUI Applications
Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations
More informationInheritance. Transitivity
Inheritance Classes can be organized in a hierarchical structure based on the concept of inheritance Inheritance The property that instances of a sub-class can access both data and behavior associated
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 informationProgramming C++ Lecture 3. Howest, Fall 2012 Instructor: Dr. Jennifer B. Sartor
Programming C++ Lecture 3 Howest, Fall 2012 Instructor: Dr. Jennifer B. Sartor Jennifer.sartor@elis.ugent.be S Inheritance S Software reuse inherit a class s data and behaviors and enhance with new capabilities.
More informationInheritance. Chapter 7. Chapter 7 1
Inheritance Chapter 7 Chapter 7 1 Introduction to Inheritance Inheritance allows us to define a general class and then define more specialized classes simply by adding new details to the more general class
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 informationFramework. Set of cooperating classes/interfaces. Example: Swing package is framework for problem domain of GUI programming
Frameworks 1 Framework Set of cooperating classes/interfaces Structure essential mechanisms of a problem domain Programmer can extend framework classes, creating new functionality Example: Swing package
More informationChapter 1: Object-Oriented Programming Using C++
Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms
More informationJAVA MOCK TEST JAVA MOCK TEST II
http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your
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 informationUsing the API: Introductory Graphics Java Programming 1 Lesson 8
Using the API: Introductory Graphics Java Programming 1 Lesson 8 Using Java Provided Classes In this lesson we'll focus on using the Graphics class and its capabilities. This will serve two purposes: first
More informationJava. GUI building with the AWT
Java GUI building with the AWT AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses the controls defined by your OS therefore
More informationBrief Summary of Java
Brief Summary of Java Java programs are compiled into an intermediate format, known as bytecode, and then run through an interpreter that executes in a Java Virtual Machine (JVM). The basic syntax of Java
More informationICS 4U. Introduction to Programming in Java. Chapter 10 Notes
ICS 4U Introduction to Programming in Java Chapter 10 Notes Classes and Inheritance In Java all programs are classes, but not all classes are programs. A standalone application is a class that contains
More informationC ONTENTS PART I FUNDAMENTALS OF PROGRAMMING 1. and Java 3. Chapter 1 Introduction to Computers, Programs,
C ONTENTS PART I FUNDAMENTALS OF PROGRAMMING 1 Chapter 1 Introduction to Computers, Programs, and Java 3 1.1 Introduction 4 1.2 What Is acomputer? 4 1.3 Programs 7 1.4 Operating Systems 9 1.5 Number Systems
More informationHomework 6. Yuji Shimojo CMSC 330. Instructor: Prof. Reginald Y. Haseltine
Homework 6 Yuji Shimojo CMSC 330 Instructor: Prof. Reginald Y. Haseltine July 21, 2013 Question 1 What is the output of the following C++ program? #include #include using namespace
More informationCore JAVA Training Syllabus FEE: RS. 8000/-
About JAVA Java is a high-level programming language, developed by James Gosling at Sun Microsystems as a core component of the Java platform. Java follows the "write once, run anywhere" concept, as it
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 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 informationThe Notion of a Class and Some Other Key Ideas (contd.) Questions:
The Notion of a Class and Some Other Key Ideas (contd.) Questions: 1 1. WHO IS BIGGER? MR. BIGGER OR MR. BIGGER S LITTLE BABY? Which is bigger? A class or a class s little baby (meaning its subclass)?
More informationPackages: Putting Classes Together
Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic
More informationHomework 5. Yuji Shimojo CMSC 330. Instructor: Prof. Reginald Y. Haseltine
Homework 5 Yuji Shimojo CMSC 330 Instructor: Prof. Reginald Y. Haseltine July 13, 2013 Question 1 Consider the following Java definition of a mutable string class. class MutableString private char[] chars
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 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 informationObject Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.
CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java
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 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 informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More informationThe mechanism that allows us to extend the definition of a class without making any physical changes to the existing class is called inheritance.
Class : BCA 3rd Semester Course Code: BCA-S3-03 Course Title: Object Oriented Programming Concepts in C++ Unit III Inheritance The mechanism that allows us to extend the definition of a class without making
More informationContents. 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 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 informationDCS235 Software Engineering Exercise Sheet 2: Introducing GUI Programming
Prerequisites Aims DCS235 Software Engineering Exercise Sheet 2: Introducing GUI Programming Version 1.1, October 2003 You should be familiar with the basic Java, including the use of classes. The luej
More informationPackages & Random and Math Classes
Packages & Random and Math Classes Quick review of last lecture September 6, 2006 ComS 207: Programming I (in Java) Iowa State University, FALL 2006 Instructor: Alexander Stoytchev Objects Classes An object
More informationFramework. Set of cooperating classes/interfaces. Example: Swing package is framework for problem domain of GUI programming
Frameworks 1 Framework Set of cooperating classes/interfaces Structure essential mechanisms of a problem domain Programmer can extend framework classes, creating new functionality Example: Swing package
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract
More informationComp-304 : Object-Oriented Design What does it mean to be Object Oriented?
Comp-304 : Object-Oriented Design What does it mean to be Object Oriented? What does it mean to be OO? What are the characteristics of Object Oriented programs (later: OO design)? What does Object Oriented
More information2. (True/False) All methods in an interface must be declared public.
Object and Classes 1. Create a class Rectangle that represents a rectangular region of the plane. A rectangle should be described using four integers: two represent the coordinates of the upper left corner
More informationObject-Oriented Programming (OOP) Fundamental Principles of OOP
Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is
More informationAbout This Lecture. Data Abstraction - Interfaces and Implementations. Outline. Object Concepts. Object Class, Protocol and State.
Revised 01/09/05 About This Lecture Slide # 2 Data Abstraction - Interfaces and Implementations In this lecture we will learn how Java objects and classes can be used to build abstract data types. CMPUT
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract
More information7. Program Frameworks
7. Program Frameworks Overview: 7.1 Introduction to program frameworks 7.2 Program frameworks for User Interfaces: - Architectural properties of GUIs - Abstract Window Toolkit of Java Many software systems
More informationCS 1302 Chapter 9 (Review) Object & Classes
CS 1302 Chapter 9 (Review) Object & Classes Reference Sections 9.2-9.5, 9.7-9.14 9.2 Defining Classes for Objects 1. A class is a blueprint (or template) for creating objects. A class defines the state
More informationQuestion 1. 1(a)(vii) (*prttoobject).somemethod(); Page 1 of 18.
Question 1. (a) Answer the following short questions. Keep your answers concise. (i) Explain the difference between the terms declaration and definition? (ii) Why are destructors always virtual in C++?
More informationCSC1322 Object-Oriented Programming Concepts
CSC1322 Object-Oriented Programming Concepts Instructor: Yukong Zhang February 18, 2016 Fundamental Concepts: The following is a summary of the fundamental concepts of object-oriented programming in C++.
More informationInheritance. Benefits of Java s Inheritance. 1. Reusability of code 2. Code Sharing 3. Consistency in using an interface. Classes
Inheritance Inheritance is the mechanism of deriving new class from old one, old class is knows as superclass and new class is known as subclass. The subclass inherits all of its instances variables and
More informationB2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA
B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE
More informationOverloading Example. Overloading. When to Overload. Overloading Example (cont'd) (class Point continued.)
Overloading Each method has a signature: its name together with the number and types of its parameters Methods Signatures String tostring() () void move(int dx,int dy) (int,int) void paint(graphicsg) (Graphics)
More informationObject Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia
Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing
More informationWe are on the GUI fast track path
We are on the GUI fast track path Chapter 13: Exception Handling Skip for now Chapter 14: Abstract Classes and Interfaces Sections 1 9: ActionListener interface Chapter 15: Graphics Skip for now Chapter
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationObject Oriented Design
Object Oriented Design Chapter 6 Example Activity Diagram 1 Outline Chapter 6 Topics 6.6 C++ Standard Library Header Files 6.14 Inline Functions 6.16 Default Arguments 6.17 Unary Scope Resolution Operator
More informationModern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi
Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Move semantics Classes Operator overloading Making your class copyable Making your class movable Rule of all or nothing Inheritance
More informationCS11 Java. Fall Lecture 3
CS11 Java Fall 2014-2015 Lecture 3 Today s Topics! Class inheritance! Abstract classes! Polymorphism! Introduction to Swing API and event-handling! Nested and inner classes Class Inheritance! A third of
More informationCS 11 java track: lecture 3
CS 11 java track: lecture 3 This week: documentation (javadoc) exception handling more on object-oriented programming (OOP) inheritance and polymorphism abstract classes and interfaces graphical user interfaces
More informationTopic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"
More informationTopic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques
More informationComputer Programming
Computer Programming Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering Session: Inheritance in C++ Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, 1 Overview
More informationChapter 6: Inheritance
Chapter 6: Inheritance EECS 1030 moodle.yorku.ca State of an object final int WIDTH = 3; final int HEIGTH = 4; final int WEIGHT = 80; GoldenRectangle rectangle = new GoldenRectangle(WIDTH, HEIGHT, WEIGHT);
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 informationJohn Cowell. Essential Java Fast. How to write object oriented software for the Internet. with 64 figures. Jp Springer
John Cowell Essential Java Fast How to write object oriented software for the Internet with 64 figures Jp Springer Contents 1 WHY USE JAVA? 1 Introduction 1 What is Java? 2 Is this book for you? 2 What
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 informationPointers. Developed By Ms. K.M.Sanghavi
Pointers Developed By Ms. K.M.Sanghavi Memory Management : Dynamic Pointers Linked List Example Smart Pointers Auto Pointer Unique Pointer Shared Pointer Weak Pointer Memory Management In order to create
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 informationIntroduction to Inheritance
Introduction to Inheritance James Brucker These slides cover only the basics of inheritance. What is Inheritance? One class incorporates all the attributes and behavior from another class -- it inherits
More informationB.Sc. (Hons.) Computer Science I B.Sc. (Hons.) Electronics. (i) Runtime polymorphism and compile time polymorphism
[This question paper contains 6 printed pages.] Sr. No. of Question Paper 6065 D Your Roll No.... Unique Paper Code 2341011251305 N arne of the Course Name of the Paper Semester B.Sc. (Hons.) Computer
More informationUniversity of Swaziland Department Of Computer Science Supplementary Examination JULY 2012
University of Swaziland Department Of Computer Science Supplementary Examination JULY 2012 Title ofpaper: Course number: Time Allowed: Cunder Unix CS344 Three (3) hours Instructions: Answer question 1.
More informationRoad Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets
Java Applets Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets Introduce inheritance Introduce the applet environment html needed for applets Reading:
More informationL4: Inheritance. Inheritance. Chapter 8 and 10 of Budd.
L4: Inheritance Inheritance Definition Example Other topics: Is A Test, Reasons for Inheritance, C++ vs. Java, Subclasses and Subtypes 7 Forms of Inheritance Discussions Chapter 8 and 10 of Budd. SFDV4001
More informationAdvanced Internet Programming CSY3020
Advanced Internet Programming CSY3020 Java Applets The three Java Applet examples produce a very rudimentary drawing applet. An Applet is compiled Java which is normally run within a browser. Java applets
More informationChapter 10 Defining Classes
Chapter 10 Defining Classes What Is a Class? A class is a data type whose variables are objects Some pre-defined data types you have used are int char You can define your own classes define your own types
More informationUnit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW
Prepared by: Dr. Abdallah Mohamed, AOU-KW 1 1. Introduction 2. Objects and classes 3. Information hiding 4. Constructors 5. Some examples of Java classes 6. Inheritance revisited 7. The class hierarchy
More informationBlock I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1
Block I Unit 2 Basic Constructs in Java M301 Block I, unit 2 1 Developing a Simple Java Program Objectives: Create a simple object using a constructor. Create and display a window frame. Paint a message
More informationIntroduction to C++ Introduction to C++ Dr Alex Martin 2013 Slide 1
Introduction to C++ Introduction to C++ Dr Alex Martin 2013 Slide 1 Inheritance Consider a new type Square. Following how we declarations for the Rectangle and Circle classes we could declare it as follows:
More informationInheritance
Inheritance 23-01-2016 Inheritance Inheritance is the capability of one class to acquire properties and characteristics from another class. For using Inheritance concept in our program we must use at least
More information