ELET4133: Embedded Systems
|
|
- Gwendolyn Miller
- 7 years ago
- Views:
Transcription
1 ELET4133: Embedded Systems Topic 8 Inheritance (Standard Java)
2 One of the foundations of Object-Oriented Programming Allows you to create generic objects define the state and behavior of all related objects Generic traits inherited by subclasses variables and methods do not have to be re-written 2
3 The keyword extends Allows you to create a subclass that inherits variable and methods of a superclass 3
4 Example class Super { int a, b; A new class is created called Super void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); 4
5 Example class Super { int a, b; void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; A new class is created called Super Contains two variables and one method void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); 5
6 Example class Super { int a, b; void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; Keyword extends allows class Sub to inherit variables and methods of Super void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); 6
7 Example class Super { int a, b; void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; Class Sub now has three variables: a, b, and c void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); 7
8 Example class Super { int a, b; void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); And three methods 8
9 Example class SuperEx { public static void main (String args[ ] ) { Super superobject = new Super(); Sub subobject = new Sub(); Create a new instance of the Super class Create a new instance of the Sub class superobject.a = 10; superobject.b = 25; System.out.println(" This is the superobject"); superobject.show(); subobject.a = 20; subobject.b = 30; subobject.c = 50; System.out.println(" This is the subobject"); subobject.show(); subobject.showc(); subobject.addem(); superobject.show(); 9
10 Example class SuperEx { public static void main (String args[ ] ) { Super superobject = new Super(); Sub subobject = new Sub(); superobject.a = 10; superobject.b = 25; System.out.println(" This is the superobject"); superobject.show(); Set variables for Super class (Super has no c variable) subobject.a = 20; subobject.b = 30; subobject.c = 50; System.out.println(" This is the subobject"); subobject.show(); subobject.showc(); subobject.addem(); superobject.show(); 10
11 Example class SuperEx { public static void main (String args[ ] ) { Super superobject = new Super(); Sub subobject = new Sub(); superobject.a = 10; superobject.b = 25; System.out.println(" This is the superobject"); superobject.show(); subobject.a = 20; subobject.b = 30; subobject.c = 50; System.out.println(" This is the subobject"); subobject.show(); subobject.showc(); subobject.addem(); Set variables for Sub class (c declared in Sub, a and b declared in Super) superobject.show(); 11
12 Example class SuperEx { public static void main (String args[ ] ) { Super superobject = new Super(); Sub subobject = new Sub(); superobject.a = 10; superobject.b = 25; System.out.println(" This is the superobject"); superobject.show(); subobject.a = 20; subobject.b = 30; subobject.c = 50; System.out.println(" This is the subobject"); subobject.show(); subobject.showc(); subobject.addem(); superobject.show(); This method shows that the class Sub inherited the show() method Let s look at class definitions again 12
13 Example class Super { int a, b; Super class does not have a showc() or addem() method void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); 13
14 Example class Super { int a, b; void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; class Sub inherits the variables and methods declared in the Super class void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); 14
15 Example class Super { int a, b; void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); There is no declaration of a or b or the show() method in the Sub class 15
16 Example class Super { int a, b; void show () { System.out.println(" a = " + a + " and b = " + b); class Sub extends Super{ int c; void showc (){ System.out.println(" c = " + c); void addem (){ System.out.println(" The sum of a, b, and c is: " + (a+b+c)); There is no declaration of a or b or the show() method in the Sub class Back to the main() program 16
17 Example class SuperEx { public static void main (String args[ ] ) { Super superobject = new Super(); Sub subobject = new Sub(); superobject.a = 10; superobject.b = 25; System.out.println(" This is the superobject"); superobject.show(); subobject.a = 20; subobject.b = 30; subobject.c = 50; These show that the Sub class may use all of these methods and that its variables are separate from the Super class s variables System.out.println(" This is the subobject"); subobject.show(); subobject.showc(); subobject.addem(); superobject.show(); 17
18 Example class SuperEx { public static void main (String args[ ] ) { Super superobject = new Super(); Sub subobject = new Sub(); superobject.a = 10; superobject.b = 25; System.out.println(" This is the superobject"); superobject.show(); subobject.a = 20; subobject.b = 30; subobject.c = 50; System.out.println(" This is the subobject"); subobject.show(); subobject.showc(); subobject.addem(); This is to show that the Super class s variables are unaffected by the Sub class s variables and methods superobject.show(); 18
19 Example class SuperEx { public static void main (String args[ ] ) { Super superobject = new Super(); Sub subobject = new Sub(); superobject.a = 10; superobject.b = 25; System.out.println(" This is the superobject"); superobject.show(); subobject.a = 20; subobject.b = 30; subobject.c = 50; System.out.println(" This is the subobject"); subobject.show(); subobject.showc(); subobject.addem(); superobject.show(); This is to show that the Super class s variables are unaffected by the Sub class s variables and methods Let s look at the program s output.. 19
20 Example The Super object 20
21 Example The Super object The Sub object 21
22 A subclass inherits all of the members in its superclass that are accessible to that subclass A Superclass can explicitly hide members A Subclass may override a member of the superclass Constructors are not members and are not inherited by subclasses 22
23 The rules: Subclasses inherit those superclass members declared as public or protected. Subclasses inherit those superclass members declared with no access specifier as long as the subclass is in the same package as the superclass. Subclasses don't inherit a superclass's member if the subclass declares a member with the same name. Variables: the member variable in the subclass hides the one in the superclass. Methods: the method in the subclass overrides the one in the superclass. 23
24 The keyword super: can be used in two ways: call the superclass constructor for the subclass explicit use of the superclass s members 24
25 Example: We want to extend the Box class used in the previous topic to include a variable for weight class Box { double width, height, depth, vol; Box (double w, double h, double d) { width = w; height = h; depth = d; Box ( ) { width = 0; height = 0; depth = 0; Box (double x ) { width = height = depth = x; Box class declaration constructors 25
26 Example: Statement to do this: class boxw extends box { If we want to use the box constructors to create we would use the super keyword class boxw extends box { double weight; boxw (double w, double, h, double d, double w){ super(w, h, d); weight = w; Subclass constructor To do this, super( ) must be the first statement within the subclass s constructor 26
27 Many times that a subclass will want to hide one of the variables of a superclass It does this by having a variable of the same name. If the programmer then wants to reference the superclass s instance variable, the keyword super must be used. 27
28 Example: class Super { int a; Superclass definition class Sub extends Super { int a; Sub (int x, int y){ super.a = x; a = y; void show (){ System.out.println("a in the Superclass = + super.a + \n and a in the subclass = + a); class SuperEx { public static void main (String args[ ] ) { Sub subobject = new Sub(10, 20); subobject.show(); 28
29 Example: class Super { int a; class Sub extends Super { int a; Sub (int x, int y){ super.a = x; a = y; Subclass definition void show (){ System.out.println("a in the Superclass = + super.a + \n and a in the subclass = + a); class SuperEx { public static void main (String args[ ] ) { Sub subobject = new Sub(10, 20); subobject.show(); 29
30 Example: class Super { int a; class Sub extends Super { int a; Sub (int x, int y){ super.a = x; a = y; Hides a in Superclass void show (){ System.out.println("a in the Superclass = + super.a + \n and a in the subclass = + a); class SuperEx { public static void main (String args[ ] ) { Sub subobject = new Sub(10, 20); subobject.show(); 30
31 Example: class Super { int a; class Sub extends Super { int a; Sub (int x, int y){ super.a = x; a = y; Uses a in Superclass Uses a in Subclass void show (){ System.out.println("a in the Superclass = + super.a + \n and a in the subclass = + a); class SuperEx { public static void main (String args[ ] ) { Sub subobject = new Sub(10, 20); subobject.show(); 31
32 Example: class Super { int a; class Sub extends Super { int a; Sub (int x, int y){ super.a = x; a = y; void show (){ System.out.println("a in the Superclass = + super.a + \n and a in the subclass = + a); class SuperEx { public static void main (String args[ ] ) { Sub subobject = new Sub(10, 20); subobject.show(); Calls show() in Subclass to print both a in Superclass and a in Subclass 32
33 This program outputs the following statements: a in the Superclass = 10 and a in the subclass = 20 super can also be used to call overridden methods from the superclass 33
34 You can create a class hierarchy with as many levels of superclass/subclass as you would like Each successive subclass created inherits all of the variables and methods from the ancestors in the superclasses 34
35 Example: Mammals Sea Land quadruped biped ape human human would inherit all of the attributes and behaviors (variables and methods) of the biped, the land, and the mammal classes highest class in the hierarchy is the most generalized lowest class in the hierarchy is the most specialized 35
36 Example: Mammals Sea Land quadruped biped ape human Reduces the amount of code For instance, all mammals breathe air All levels of the hierarchy would inherit this method code would not have to be re-written 36
37 Method Overriding To override an ancestor s method, create a new method in the subclass with the exact same name and type signature The subclass s method will be called in place of the ancestor s method - it will be overridden If you need to call the ancestor s method, use the super keyword 37
38 Example Superclass class Super { int a, b ; Super (int x, int y) { a = x; b = y; void displayvars ( ) { System.out.println( a = + a + and b = + b); class Sub extends Super { int c; Sub (int x, int y, int z){ super(x, y); c = z; void displayvars ( ) { System.out.println( a = + a + and b = + b + and c = + c); 38
39 Example class Super { int a, b ; Super (int x, int y) { a = x; b = y; void displayvars ( ) { System.out.println( a = + a + and b = + b); class Sub extends Super { int c; Sub (int x, int y, int z){ super(x, y); c = z; void displayvars ( ) { System.out.println( a = + a + and b = + b + and c = + c); Superclass constructor 39
40 Example class Super { int a, b ; Super (int x, int y) { a = x; b = y; void displayvars ( ) { System.out.println( a = + a + and b = + b); class Sub extends Super { int c; Sub (int x, int y, int z){ super(x, y); c = z; void displayvars ( ) { System.out.println( a = + a + and b = + b + and c = + c); Superclass s displayvars() method (2 variables) 40
41 Example class Super { int a, b ; Super (int x, int y) { a = x; b = y; void displayvars ( ) { System.out.println( a = + a + and b = + b); class Sub extends Super { int c; Sub (int x, int y, int z){ super(x, y); c = z; void displayvars ( ) { Calls Superclass s constructor in Subclass s constructor System.out.println( a = + a + and b = + b + and c = + c); Subclass Inherits all of Superclass s variables and methods 41
42 Example class Super { int a, b ; Super (int x, int y) { a = x; b = y; void displayvars ( ) { System.out.println( a = + a + and b = + b); class Sub extends Super { int c; Sub (int x, int y, int z){ super(x, y); c = z; void displayvars ( ) { System.out.println( a = + a + and b = + b + and c = + c); Subclass s displayvars() method overrides (3 vars) Superclass s displayvars() method (2 vars) 42
43 Example class OverEx { public static void main (String args[ ] ) { Sub subobject = new Sub(1, 2, 3); Program that uses subclass s displayvars() method subobject.displayvars(); Program Output Subclass s method (3 variables instead of two) 43
44 To access the displayvars() method in the superclass Call the superclass s method using the keyword super: super.displayvars(); or Create a superobject in the OverEx class and call it explicitly: superobject.displayvars(); Method overriding occurs only if: The names of the two methods are identical, and The type signature is identical 44
45 Suppose we changed the displayvars() method in the subclass declaration to include passing a String object void displayvars(string message) {.. Original had no parameters In this case the type signature of the two methods would be different, so the new method would overload the superclass s method not override it Call it if the parameters matched Call it in place of the other 45
46 Dynamic Method Dispatch Fancy name for a powerful java implementation of polymorphism A run-time decision of the JVM regarding which method to execute Decision based on a reference variable Not explicit statements Recall that a superclass reference variable may refer to a subclass object 46
47 When an overridden method is called through a superclass reference variable, the JVM determines which method to execute based on the type of object being referenced at the time class OverEx { public static void main (String args[ ] ) { Sub subobject = new Sub(1, 2, 3); Super refvar; refvar = superobject; refvar.displayvars(); Superclass reference variable refvar = subobject; refvar.displayvars(); 47
48 When an overridden method is called through a superclass reference variable, the JVM determines which method to execute based on the type of object being referenced at the time class OverEx { public static void main (String args[ ] ) { Sub subobject = new Sub(1, 2, 3); Super refvar; refvar = superobject; refvar.displayvars(); refvar = subobject; refvar.displayvars(); References the Superclass, so it calls the Superclass s method 48
49 When an overridden method is called through a superclass reference variable, the JVM determines which method to execute based on the type of object being referenced at the time class OverEx { public static void main (String args[ ] ) { Sub subobject = new Sub(1, 2, 3); Super refvar; refvar = superobject; refvar.displayvars(); refvar = subobject; refvar.displayvars(); References the Subclass, so it calls the Subclass s method 49
50 Abstract Classes You may want to create a framework for subclasses, but not fully implement them This will happen when a superclass cannot create a meaningful implementation of a method In this case you will have methods that must be overridden Declare an abstract method in the superclass If a method is declared an abstract method it must be overridden 50
51 Abstract Classes Limitations and restrictions that must be observed: 1. Any class that contains one or more abstract methods must also be declared abstract. 2. There can be no instances of an abstract class, but it may have a reference. 3. You cannot declare abstract constructors 4. You cannot declare abstract static methods 5. A subclass of an abstract class must implement all of the ancestor s methods or be declared abstract itself. 51
52 final: The keyword final was used earlier to create constants for java programs. The keyword final has two other uses: 1. Methods declared as final cannot be overridden 2. Classes Declared as final cannot have subclasses 52
53 The Object Class All objects in java are subclasses of the class Object Inherit many capabilities in java that they may not otherwise have Reference variable of type Object can refer to any other object Arrays and Strings are objects in java A reference variable of type Object can refer to any array or String 53
54 Object defines the following methods that are inherited by all objects created in java: Method Purpose Object clone( ) boolean equals (Object object) void finalize ( ) Class getclass ( ) int hashcode ( ) void notify( ) void notifyall( ) String tostring( ) void wait( ) void wait(long milliseconds ) void wait(long millisec, int nanosec ) Creates a new object that is a clone of the first Determines whether two object are equal Called before an unused object is recycled Obtains the class of an object at run-time Returns the hashcode associated with the object Resumes execution of a thread waiting on the invoking object Resumes execution of all threads waiting on the invoking object Returns a string that describes the object Waits on another thread of execution Waits on another thread of execution Waits on another thread of execution 54
CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.
CSCI 253 Object Oriented Design: Java Review OOP George Blankenship George Blankenship 1 Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation Abstract Data Type (ADT) Implementation
More informationJava Interview Questions and Answers
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 and compile the java
More informationCohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT
BSc (Hons) in Computer Applications, BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems & BSc (Hons) Software Engineering Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT
More informationChapter 13 - Inheritance
Goals Chapter 13 - Inheritance To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package
More informationJava CPD (I) Frans Coenen Department of Computer Science
Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials
More informationAgenda. What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism
Polymorphism 1 Agenda What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism 2 What is & Why Polymorphism? 3 What is Polymorphism? Generally, polymorphism refers
More informationPreet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75
Preet raj Core Java and Databases CS4PR Time Allotted: 3 Hours Final Exam: Total Possible Points 75 Q1. What is difference between overloading and overriding? 10 points a) In overloading, there is a relationship
More informationJava Programming Language
Lecture 1 Part II Java Programming Language Additional Features and Constructs Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Subclasses and
More informationSE 360 Advances in Software Development Object Oriented Development in Java. Polymorphism. Dr. Senem Kumova Metin
SE 360 Advances in Software Development Object Oriented Development in Java Polymorphism Dr. Senem Kumova Metin Modified lecture notes of Dr. Hüseyin Akcan Inheritance Object oriented programming languages
More informationAP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
More informationDescription of Class Mutation Mutation Operators for Java
Description of Class Mutation Mutation Operators for Java Yu-Seung Ma Electronics and Telecommunications Research Institute, Korea ysma@etri.re.kr Jeff Offutt Software Engineering George Mason University
More informationPart I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
More informationObject-Oriented Programming: Polymorphism
1 10 Object-Oriented Programming: Polymorphism 10.3 Demonstrating Polymorphic Behavior 10.4 Abstract Classes and Methods 10.5 Case Study: Payroll System Using Polymorphism 10.6 final Methods and Classes
More informationD06 PROGRAMMING with JAVA
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch13 Inheritance PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for accompanying
More informationThe Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1
The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose
More informationObject-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
More informationINTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction
INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 7: Object-Oriented Programming Introduction One of the key issues in programming is the reusability of code. Suppose that you have written a program
More informationMasters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
More informationClasses and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:
In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our
More informationLAB4 Making Classes and Objects
LAB4 Making Classes and Objects Objective The main objective of this lab is class creation, how its constructer creation, object creation and instantiation of objects. We will use the definition pane to
More informationJ a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
More informationPHP Object Oriented Classes and objects
Web Development II Department of Software and Computing Systems PHP Object Oriented Classes and objects Sergio Luján Mora Jaume Aragonés Ferrero Department of Software and Computing Systems DLSI - Universidad
More informationBuilding Java Programs
Building Java Programs Chapter 9 Lecture 9-1: Inheritance reading: 9.1 The software crisis software engineering: The practice of developing, designing, documenting, testing large computer programs. Large-scale
More informationFree Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third
More informationFree Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman
More informationCS170 Lab 11 Abstract Data Types & Objects
CS170 Lab 11 Abstract Data Types & Objects Introduction: Abstract Data Type (ADT) An abstract data type is commonly known as a class of objects An abstract data type in a program is used to represent (the
More informationComp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111
Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages Corky Cartwright Swarat Chaudhuri November 30, 20111 Overview I In OO languages, data values (except for designated non-oo
More informationThe Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0
The following applies to all exams: Once exam vouchers are purchased you have up to one year from the date of purchase to use it. Each voucher is valid for one exam and may only be used at an Authorized
More informationInheritance, overloading and overriding
Inheritance, overloading and overriding Recall with inheritance the behavior and data associated with the child classes are always an extension of the behavior and data associated with the parent class
More informationJava Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
More informationHistory OOP languages Year Language 1967 Simula-67 1983 Smalltalk
History OOP languages Intro 1 Year Language reported dates vary for some languages... design Vs delievered 1957 Fortran High level programming language 1958 Lisp 1959 Cobol 1960 Algol Structured Programming
More informationFundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
More informationProgrammation 2. Introduction à la programmation Java
Programmation 2 Introduction à la programmation Java 1 Course information CM: 6 x 2 hours TP: 6 x 2 hours CM: Alexandru Costan alexandru.costan at inria.fr TP: Vincent Laporte vincent.laporte at irisa.fr
More informationHow To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For
Projet Java Responsables: Ocan Sankur, Guillaume Scerri (LSV, ENS Cachan) Objectives - Apprendre à programmer en Java - Travailler à plusieurs sur un gros projet qui a plusieurs aspects: graphisme, interface
More informationGlossary of Object Oriented Terms
Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction
More informationCS 111 Classes I 1. Software Organization View to this point:
CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects
More informationICOM 4015: Advanced Programming
ICOM 4015: Advanced Programming Lecture 10 Reading: Chapter Ten: Inheritance Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter 10 Inheritance Chapter Goals To learn about inheritance To
More informationOutline of this lecture G52CON: Concepts of Concurrency
Outline of this lecture G52CON: Concepts of Concurrency Lecture 10 Synchronisation in Java Natasha Alechina School of Computer Science nza@cs.nott.ac.uk mutual exclusion in Java condition synchronisation
More informationRMI Client Application Programming Interface
RMI Client Application Programming Interface Java Card 2.2 Java 2 Platform, Micro Edition Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, CA 94303 U.S.A. 650-960-1300 June, 2002 Copyright 2002 Sun
More informationjava Features Version April 19, 2013 by Thorsten Kracht
java Features Version April 19, 2013 by Thorsten Kracht Contents 1 Introduction 2 1.1 Hello World................................................ 2 2 Variables, Types 3 3 Input/Output 4 3.1 Standard I/O................................................
More informationObject-Oriented Programming in Java
Object-Oriented Programming in Java Quiz 1 Jan 10, 2001 Problem 1: Who wants to be a Java developer? (with apologies to Regis) Fill in your answer in the space provided. Question 1: Which is these word-pairs
More informationContents. 9-1 Copyright (c) 1999-2004 N. Afshartous
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
More informationYosemite National Park, California. CSE 114 Computer Science I Inheritance
Yosemite National Park, California CSE 114 Computer Science I Inheritance Containment A class contains another class if it instantiates an object of that class HAS-A also called aggregation PairOfDice
More informationHandout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
More informationJava Interfaces. Recall: A List Interface. Another Java Interface Example. Interface Notes. Why an interface construct? Interfaces & Java Types
Interfaces & Java Types Lecture 10 CS211 Fall 2005 Java Interfaces So far, we have mostly talked about interfaces informally, in the English sense of the word An interface describes how a client interacts
More informationJava (12 Weeks) Introduction to Java Programming Language
Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short
More informationCompile-time type versus run-time type. Consider the parameter to this function:
CS107L Handout 07 Autumn 2007 November 16, 2007 Advanced Inheritance and Virtual Methods Employee.h class Employee public: Employee(const string& name, double attitude, double wage); virtual ~Employee();
More informationJAVA - INHERITANCE. extends is the keyword used to inherit the properties of a class. Below given is the syntax of extends keyword.
http://www.tutorialspoint.com/java/java_inheritance.htm JAVA - INHERITANCE Copyright tutorialspoint.com Inheritance can be defined as the process where one class acquires the properties methodsandfields
More information3 Pillars of Object-oriented Programming. Industrial Programming Systems Programming & Scripting. Extending the Example.
Industrial Programming Systems Programming & Scripting Lecture 12: C# Revision 3 Pillars of Object-oriented Programming Encapsulation: each class should be selfcontained to localise changes. Realised through
More informationThird AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts
Third AP Edition Object-Oriented Programming and Data Structures Maria Litvin Phillips Academy, Andover, Massachusetts Gary Litvin Skylight Software, Inc. Skylight Publishing Andover, Massachusetts Skylight
More informationChecking Access to Protected Members in the Java Virtual Machine
Checking Access to Protected Members in the Java Virtual Machine Alessandro Coglio Kestrel Institute 3260 Hillview Avenue, Palo Alto, CA 94304, USA Ph. +1-650-493-6871 Fax +1-650-424-1807 http://www.kestrel.edu/
More informationConstruction of classes with classes
(November 13, 2014 Class hierarchies 1 ) Construction of classes with classes Classes can be built on existing classes through attributes of object types. Example: I A class PairOfDice can be constructed
More informationSummit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A
Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A Developed By Brian Weinfeld Course Description: AP Computer
More informationMultiple Dispatching. Alex Tritthart WS 12/13
Multiple Dispatching Alex Tritthart WS 12/13 Outline 1 Introduction 2 Dynamic Dispatch Single Dispatch Double Dispatch 3 Multiple Dispatch Example 4 Evaluation 2 / 24 What is it all about? Introduction
More informationProgramming Languages Featherweight Java David Walker
Programming Languages Featherweight Java David Walker Overview Featherweight Java (FJ), a minimal Javalike language. Models inheritance and subtyping. Immutable objects: no mutation of fields. Trivialized
More informationCSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals
CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]
More informationCS193j, Stanford Handout #10 OOP 3
CS193j, Stanford Handout #10 Summer, 2003 Manu Kumar OOP 3 Abstract Superclass Factor Common Code Up Several related classes with overlapping code Factor common code up into a common superclass Examples
More informationException Handling. Overloaded methods Interfaces Inheritance hierarchies Constructors. OOP: Exception Handling 1
Exception Handling Error handling in general Java's exception handling mechanism The catch-or-specify priciple Checked and unchecked exceptions Exceptions impact/usage Overloaded methods Interfaces Inheritance
More informationHabanero Extreme Scale Software Research Project
Habanero Extreme Scale Software Research Project Comp215: Java Method Dispatch Zoran Budimlić (Rice University) Always remember that you are absolutely unique. Just like everyone else. - Margaret Mead
More informationAdvanced OOP Concepts in Java
Advanced OOP Concepts in Java Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring 09/28/2001 1 Overview
More informationAbstract Class & Java Interface
Abstract Class & Java Interface 1 Agenda What is an Abstract method and an Abstract class? What is Interface? Why Interface? Interface as a Type Interface vs. Class Defining an Interface Implementing an
More informationAbstract Classes. Suppose we want write a program that manipulates various types of bank accounts. An Account typically has following features;
Abstract Classes Suppose we want write a program that manipulates various types of bank accounts. An Account typically has following features; Name, AccountNumber, Balance. Following operations can be
More informationAn Introduction To UML Class Diagrams Classes
An Introduction To UML Class Diagrams Classes 1. Represent a user-created or defined data type a. they are an abstract data type (ADT) b. they implement data hiding and encapsulation c. they establish
More informationwww.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk
CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling
More informationUsing Inheritance and Polymorphism
186 Chapter 16 Using Inheritance and Polymorphism In this chapter we make use of inheritance and polymorphism to build a useful data structure. 16.1 Abstract Classes Circle1a ( 16.1) is a variation of
More informationUniversity of Twente. A simulation of the Java Virtual Machine using graph grammars
University of Twente Department of Computer Science A simulation of the Java Virtual Machine using graph grammars Master of Science thesis M. R. Arends, November 2003 A simulation of the Java Virtual Machine
More informationTutorial on Writing Modular Programs in Scala
Tutorial on Writing Modular Programs in Scala Martin Odersky and Gilles Dubochet 13 September 2006 Tutorial on Writing Modular Programs in Scala Martin Odersky and Gilles Dubochet 1 of 45 Welcome to the
More informationCMSC 202H. ArrayList, Multidimensional Arrays
CMSC 202H ArrayList, Multidimensional Arrays What s an Array List ArrayList is a class in the standard Java libraries that can hold any type of object an object that can grow and shrink while your program
More informationObject-Oriented Programming Lecture 2: Classes and Objects
Object-Oriented Programming Lecture 2: Classes and Objects Dr. Lê H!ng Ph"#ng -- Department of Mathematics, Mechanics and Informatics, VNUH July 2012 1 Content Class Object More on class Enum types Package
More informationCIS 190: C/C++ Programming. Polymorphism
CIS 190: C/C++ Programming Polymorphism Outline Review of Inheritance Polymorphism Car Example Virtual Functions Virtual Function Types Virtual Table Pointers Virtual Constructors/Destructors Review of
More informationTranslating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language
Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description
More informationAndroid Application Development Course Program
Android Application Development Course Program Part I Introduction to Programming 1. Introduction to programming. Compilers, interpreters, virtual machines. Primitive data types, variables, basic operators,
More informationAgile Software Development
Agile Software Development Lecturer: Raman Ramsin Lecture 13 Refactoring Part 3 1 Dealing with Generalization: Pull Up Constructor Body Pull Up Constructor Body You have constructors on subclasses with
More informationDesigning with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219
Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing
More informationAbstract. a http://www.eiffel.com
Abstract Eiffel Software a provides a compiler for the Eiffel programming language capable of generating C code or Common Intermediate Language byte code. The CLI code can be executed on the Common Language
More informationThe Interface Concept
Multiple inheritance Interfaces Four often used Java interfaces Iterator Cloneable Serializable Comparable The Interface Concept OOP: The Interface Concept 1 Multiple Inheritance, Example Person name()
More informationKonzepte objektorientierter Programmierung
Konzepte objektorientierter Programmierung Prof. Dr. Peter Müller Werner Dietl Software Component Technology Exercises 3: Some More OO Languages Wintersemester 04/05 Agenda for Today 2 Homework Finish
More informationSoftware Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.
Software Testing Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Testing can only reveal the presence of errors and not the
More informationFormal Engineering for Industrial Software Development
Shaoying Liu Formal Engineering for Industrial Software Development Using the SOFL Method With 90 Figures and 30 Tables Springer Contents Introduction 1 1.1 Software Life Cycle... 2 1.2 The Problem 4 1.3
More informationPart 3: GridWorld Classes and Interfaces
GridWorld Case Study Part 3: GridWorld Classes and Interfaces In our example programs, a grid contains actors that are instances of classes that extend the Actor class. There are two classes that implement
More informationGrundlæggende Programmering IT-C, Forår 2001. Written exam in Introductory Programming
Written exam in Introductory Programming IT University of Copenhagen, June 11, 2001 English version All materials are permitted during the exam, except computers. The exam questions must be answered in
More informationJAVA - METHODS. Method definition consists of a method header and a method body. The same is shown below:
http://www.tutorialspoint.com/java/java_methods.htm JAVA - METHODS Copyright tutorialspoint.com A Java method is a collection of statements that are grouped together to perform an operation. When you call
More informationC++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
More informationIntroduction: Abstract Data Types and Java Review
Introduction: Abstract Data Types and Java Review Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Welcome to Computer Science E-119! We will study fundamental data structures.
More informationD06 PROGRAMMING with JAVA. Ch3 Implementing Classes
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch3 Implementing Classes PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com,
More informationJava Programming. Binnur Kurt binnur.kurt@ieee.org. Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.
Java Programming Binnur Kurt binnur.kurt@ieee.org Istanbul Technical University Computer Engineering Department Java Programming 1 Version 0.0.4 About the Lecturer BSc İTÜ, Computer Engineering Department,
More informationChapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named
More informationWeb Development in Java
Web Development in Java Detailed Course Brochure @All Rights Reserved. Techcanvass, 265, Powai Plaza, Hiranandani Garden, Powai, Mumbai www.techcanvass.com Tel: +91 22 40155175 Mob: 773 877 3108 P a g
More informationYou are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:
Lecture 7 Picking Balls From an Urn The problem: An urn has n (n = 10) balls numbered from 0 to 9 A ball is selected at random, its' is number noted, it is set aside, and another ball is selected from
More informationA Scala Tutorial for Java programmers
A Scala Tutorial for Java programmers Version 1.3 January 16, 2014 Michel Schinz, Philipp Haller PROGRAMMING METHODS LABORATORY EPFL SWITZERLAND 2 1 Introduction This document gives a quick introduction
More informationUnit Testing and JUnit
Unit Testing and JUnit Testing Objectives Tests intended to find errors Errors should be found quickly Good test cases have high p for finding a yet undiscovered error Successful tests cause program failure,
More informationCS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
More informationAP Computer Science Java Mr. Clausen Program 9A, 9B
AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will
More informationIntroduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
More informationUnit Testing. and. JUnit
Unit Testing and JUnit Problem area Code components must be tested! Confirms that your code works Components must be tested t in isolation A functional test can tell you that a bug exists in the implementation
More informationWhat is Java? Applications and Applets: Result of Sun s efforts to remedy bad software engineering practices
What is Java? Result of Sun s efforts to remedy bad software engineering practices It is commonly thought of as a way to make Web pages cool. It has evolved into much more. It is fast becoming a computing
More informationJava Virtual Machine Locks
Java Virtual Machine Locks SS 2008 Synchronized Gerald SCHARITZER (e0127228) 2008-05-27 Synchronized 1 / 13 Table of Contents 1 Scope...3 1.1 Constraints...3 1.2 In Scope...3 1.3 Out of Scope...3 2 Logical
More informationDIPLOMADO DE JAVA - OCA
DIPLOMADO DE JAVA - OCA TABLA DE CONTENIDO INTRODUCCION... 3 ESTRUCTURA DEL DIPLOMADO... 4 Nivel I:... 4 Fundamentals of the Java Programming Language Java SE 7... 4 Introducing the Java Technology...
More informationFirst Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
More information