Java Model of Basic Algebraic Structures

Size: px
Start display at page:

Download "Java Model of Basic Algebraic Structures"

Transcription

1 Java Model of Basic Algebraic Structures Petr Grillinger * pgrillin@kiv.zcu.cz Jaroslav Kačer * jkacer@kiv.zcu.cz Abstract This article presents a model of basic algebraic structures implemented in Java. The model is highly portable and extensible, and contains strong self-checking mechanisms. It is based on finite sets and provides brute-force methods simulating basic operations on algebraic structures. The implemented structures (from set to ring) form a single-rooted hierarchy of classes (the root is a set element). So far the model is not very useful for automated theorem proving, because is lacks support for intentional set definitions, but this should change in the future. 1. Introduction Many solutions to programming problems are based on principles from algebra most constructs that are used can be described by appropriate algebraic structures. Some of these structures are directly represented (e.g. sets, vectors, functions) others are provided in a less obvious way (e.g. additive group of whole numbers). Conversely, by using a programming language we can build an explicit model of these algebraic structures. Such model could be used as an alternative means of writing algebraic expressions. It would also enable the automation of some basic algebraic tasks verification of specified axioms by brute force approach. This work aims to create a basic set of algebraic structures that could be used to quickly solve simple algebraic tasks. The model must be well designed and open to allow further extensions. We aim for portability, clarity of design and robustness, while performance is of low importance. Many algebraic structures form a natural hierarchy (e.g. set monoid group) that can be easily represented by object oriented modeling. We chose to implement the model in Java, because from the wide range of OO languages, Java provides the best portability. Moreover, the strong type-checking and mandatory exception handling makes Java a very safe language. 2. Model Limitations Only a small subset from the large number of various algebraic structures was selected for implementation. This subset can be seen in a tree form (the branches indicate parent-descendant relationship between classes) in Fig.1. Common programming methods cannot represent infinite sets and it is in no way possible to successfully perform a brute force algorithm on such sets. For this reason, we are not going to include infinite sets and problems that require them will have to use an adequate substitute representation (e.g. randomly chosen finite subset). This limitation makes the model only partially useful for automated theorem proving (results for infinite sets will be probabilistic), but simplifies significantly the implementation. * Ing., University of West Bohemia, Department of Computer Science and Engineering, Univerzitní 22, Plzeň 30614, Czech Republic

2 Element Function Set Vector Relation Operation Monoid CartesianProduct Group Ring Fig. 1: Class specialization tree (parent descendant) 3. Basic Classes The model is encapsulated in a Java package labeled cz.zcu.fav.kma.alg. It contains all classes representing individual algebraic structures as well as several support classes. We will describe in some detail the basic structures (all that are depicted in Fig. 1), the others are only listed Class Element Element is an abstract class that defines any single element of a set or a vector. Every element is specified by its type (instance of class ElementType) and value. The type is used to identify a group of elements with common properties, e.g. integers. Only elements of the same type can be in one set and many operations require specific element types. The value of an element is used for comparison and two elements are identical if they have the same type and value. The method getidentification() is used to retrieve the textual value of an element Class ElementType An element type is defined by a string constant (e.g. INTEGER ). This constant is used during the creation of a new type to determine whether a type with the same string already exists (then the existing type is used) or not (a new type is created). To allow this behavior, the class is constructed as a factory, i.e. instances are obtained by calling the method createtype() rather than by using a constructor Class Set This class is a container that manages instances of the Element class. The elements are not ordered, must have the same type, and no two elements may be equal. As mentioned previously, infinite sets are not supported this means that every set can be defined by a simple enumeration of its elements (extensive set). The extensive definition allows to easily iterate through elements (the standard Java Iterator is supported). A set is not fully defined until the type of its elements is known the element type is fixed permanently after the first element is inserted. The type of a set is defined as SET(ELEMENT_T).

3 3.4. Class Vector A vector is used to hold a fixed number of elements in given order. The elements must have the same type, and duplicates are possible. The number of elements must be specified during creation and the element type (used for the vector type and identification) is collected as the first element is inserted. A vector is not fully defined until the type of its elements is known the element type is fixed permanently after the first element is inserted. The type of a vector is defined as VECTOR[#](ELEMENT_T) Class Function This is an abstract class that defines the basic properties of any function. Descendants should override methods getvalue() and gettransformationdescription() the later is used to automatically create the identification of the function (function is also an element and this is its visible value). The constructor of this class requires two parameters domain and codomain both are used to construct a complete element type for the function. The type of a function is defined as FUNCTION(DOMAIN_T,CODOMAIN_T) Class Relation A relation is a subset of the Cartesian product of several sets. It can be expressed also as a function with codomain {0,1 that returns the integral number 1 if the elements in a given vector meet the relation, 0 otherwise. In this implementation, Relation is descended from the Function class and its codomain is fixed. It does not override the abstract methods of function, so it remains an abstract class. The type of relation depends on the domain, i.e. its textual description is RELATION(DOMAIN_T) Class Operation Operation is a function where domain is the same as codomain or a Cartesian product on codomain. This means, that operation is descended from Function, and only the codomain and the dimension of domain are specified (number of operands). The operation type depends on the number of operands and codomain type, i.e. the textual form is OPERATION[#](CODOMAIN_T) Class CartesianProduct A Cartesian product is a set of all vectors that can be produces by combining elements of given sets in defined order. The memory consumption of this product can be considerable, so the current implementation is intentional and not extensive. This should be changed in the future or the class should provide an iterator for sequential browsing. The type is a set in fact and is defined by the sets forming the product. These sets are given in a vector of fixed size, so the textual type definition is SET(VECTOR_T) 3.9. Class Monoid Monoid groups a set of elements, a binary operation on this set and an identity element into a single unit. All three parts must be specified on construction, but only the type of the set elements defines the type of the monoid. The correctness of a monoid is checked in a simple way during creation and a thorough check that verifies all axioms can be requested explicitly. The textual type description is MONOID(ELEMENT_T) Class Group A group extends the monoid structure by an inverse operation an instance of UnaryOperation class. All rules from monoid are still valid, the correctness check is extended to verify the inverse operation. The textual definition of type is GROUP(ELEMENT_T).

4 3.11. Class Ring Similarly as group is an extension of monoid, ring is an extension of group. It adds a second binary operation with an identity element and places another restriction on the first operation it must be commutative. Moreover, the first operation must be distributive with respect to the second. The textual type definition is RING(ELEMENT_T) Other Classes The so far described classes represent the most important keys of the algebraic model. Other classes are present and often more usable because they provide particular services and not abstract interfaces. These classes are only listed in the following paragraph and more detailed description can be easily found in program-generated documentation (available at AdditionModulo BinaryOperation BinaryRelation CharacteristicFunction EmptySet EquivalenceClass IdentityFunction Insertion IntegralNumber InverseAdditionModulo MultiplicationModulo NestedFunction OrderedPair Permutation PermutationSet RelationOnSet ResidueClass UnaryOperation Singletons Some classes serve special purpose and only one instance of such class is created. These classes were implemented with a hidden constructor (private) and the actual instance can be accessed through method getinstance() only. So far only two classes are singletons: EmptySet Set01 4. Self-Checking Mechanisms The model contains several independent checking mechanisms that are used for different purposes Class Tests A class test is written by the designer of the class to verify that the implementation is correct. It typically inherits the class test from its parent and then executes a test suite for the new features. The test suite should contain the creation of several instances and verification of every new method. It is generally not possible to determine correctness automatically it is up to the user to visually check the output of the class test. The test can be run from the command line by typing this sequence: java cz.zcu.fav.kma.alg.<class_name> 3.2. Instance Test This kind of test can be started during program execution by calling the method selftest() of any class descended from Element. The method will verify that the definition of the instance is complete (for non-atomically initialized classes) and that all axioms for the given algebraic structure are fulfilled. E.g., any function must have a domain, a codomain, and a transformation rule that handles any element from domain and produces only elements from codomain. The instance test returns true if all tests are passed, false otherwise.

5 3.3. Exception System The model enforces strong error checking by using a hierarchy of exceptions. All exceptions that denote the violation of algebraic rules are descended from a single class AlgException. Java guarantees that an exception must be handled or correctly declared in the interface, so user applications are verified for robustness already during compilation. 5. Example A simple example was prepared to demonstrate the basic features of the model. The example solves the following problem: Find all automorphisms of an additive group Z 8 (elements are residues from modulo 8). An automorphism is a bijective function f on a group that preserves the structure of the group, i.e. for every two elements x, y and group operation + it is true: f(x+y) = f(x)+f(y). From the function definition follows, that an automorphism is always a permutation on the group, so the fastest approach to the task is to generate every permutation (use the class PermutationSet) and test if the additive operation is preserved. The group can be easily constructed from a ResidueClass set, the binary operation AdditionModulo, and unary operation InverseAdditionModulo. The test whether a function is automorphism or not is already included in the Function class. public class Example2 { public static main(string[] args) { Group g8 = new Group( new ResidueClass(8), new AdditionModulo(8), new IntegralNumber(0), new InverseAdditionModulo(8)); Set all_perm = new PermutationSet(g8.getSet()); Iterator iter = all_perm.iterator(); Function f; while (iter.hasnext()) { f = (Function) iter.next(); if (f.isautomorphism(g8)) System.out.println(f.getIdentification() + " is automorphism."); 6. Conclusions The described model of algebraic structures has so far quite limited capabilities, but provides a stable and easily extensible interface. The Java language provides excellent portability and applications robustness. The example in previous section demonstrates that solving a seemingly complicated task can be quite easy given that the necessary tools are available. The most severe limitations of the model are the incomplete implementation of some structures (e.g., testing of sub-groups, finding the kernel) and the missing structures (e.g. fundamental group, intentional sets). This flaw will be continuously removed in the future. Bibliography [1] S. Mac Lane, G. Birkhoff, 1968: Algebra (2 nd edition), The Macmillan Company, New York. Slovak translation. [2] B. Eckel, 2002: Thinking in Java (3 rd edition), Prentice-Hall. ISBN Online version at

Functions. How is this definition written in symbolic logic notation?

Functions. How is this definition written in symbolic logic notation? functions 1 Functions Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A. We write f(a) = b if b is the unique element of B assigned by

More information

More On inheritance. What you can do in subclass regarding methods:

More On inheritance. What you can do in subclass regarding methods: More On inheritance What you can do in subclass regarding methods: The inherited methods can be used directly as they are. You can write a new static method in the subclass that has the same signature

More information

Genetic Algorithms for EQ-algebras Automatic Generation

Genetic Algorithms for EQ-algebras Automatic Generation Genetic Algorithms for EQ-algebras Automatic Generation Hashim Habiballa, Vilém Novák, Martin Dyba Centre of Excellence IT4Innovations - Division University of Ostrava Institute for Research and Applications

More information

Chapter 5 Object-Oriented Programming

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

More information

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1 Design Principles Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques 2-1 Data Structures Data Structure - A systematic way of organizing and accessing

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

A DESIGN PROPOSAL FOR AN OBJECT ORIENTED ALGEBRAIC LIBRARY

A DESIGN PROPOSAL FOR AN OBJECT ORIENTED ALGEBRAIC LIBRARY STUDIA UNIV. BABEŞ BOLYAI, INFORMATICA, Volume XLVIII, Number 1, 2003 A DESIGN PROPOSAL FOR AN OBJECT ORIENTED ALGEBRAIC LIBRARY VIRGINIA NICULESCU Abstract. Object oriented programming and design patterns

More information

Programming II. Modularity 2017/18

Programming II. Modularity 2017/18 Programming II Modularity 2017/18 Module? Lecture Outline Evolution and history of programming languages Modularity Example History of Programming Programming Paradigms How and why languages develop? How

More information

PROGRAMMING LANGUAGE 2

PROGRAMMING LANGUAGE 2 31/10/2013 Ebtsam Abd elhakam 1 PROGRAMMING LANGUAGE 2 Java lecture (7) Inheritance 31/10/2013 Ebtsam Abd elhakam 2 Inheritance Inheritance is one of the cornerstones of object-oriented programming. It

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target

More information

Chapter 1: Principles of Programming and Software Engineering

Chapter 1: Principles of Programming and Software Engineering Chapter 1: Principles of Programming and Software Engineering Data Abstraction & Problem Solving with C++ Fifth Edition by Frank M. Carrano Software Engineering and Object-Oriented Design Coding without

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Rules and syntax for inheritance. The boring stuff

Rules and syntax for inheritance. The boring stuff Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for

More information

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language Categories of languages that support OOP: 1. OOP support is added to an existing language - C++ (also supports procedural and dataoriented programming) - Ada 95 (also supports procedural and dataoriented

More information

Enums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed.

Enums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed. Enums Introduction In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed. The Final Tag To display why this is useful, I m going to

More information

Material from Recitation 1

Material from Recitation 1 Material from Recitation 1 Darcey Riley Frank Ferraro January 18, 2011 1 Introduction In CSC 280 we will be formalizing computation, i.e. we will be creating precise mathematical models for describing

More information

SDC Design patterns GoF

SDC Design patterns GoF SDC Design patterns GoF Design Patterns The design pattern concept can be viewed as an abstraction of imitating useful parts of other software products. The design pattern is a description of communicating

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (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 information

The Java language has a wide variety of modifiers, including the following:

The Java language has a wide variety of modifiers, including the following: PART 5 5. Modifier Types The Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers 5.1 Access Control Modifiers Java provides a number of access

More information

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

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

More information

Lecture Notes on Ints

Lecture Notes on Ints Lecture Notes on Ints 15-122: Principles of Imperative Computation Frank Pfenning Lecture 2 August 26, 2010 1 Introduction Two fundamental types in almost any programming language are booleans and integers.

More information

Object Oriented Finite Element Modeling

Object Oriented Finite Element Modeling Object Oriented Finite Element Modeling Bořek Patzák Czech Technical University Faculty of Civil Engineering Department of Structural Mechanics Thákurova 7, 166 29 Prague, Czech Republic January 2, 2018

More information

Data Structure. Recitation III

Data Structure. Recitation III Data Structure Recitation III Topic Binary Search Abstract Data types Java Interface Linked List Binary search Searching a sorted collection is a common task. A dictionary is a sorted list of word definitions.

More information

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np Chapter 1: Introduction Introduction Purpose of the Theory of Computation: Develop formal mathematical models of computation that reflect real-world computers. Nowadays, the Theory of Computation can be

More information

6. Asymptotics: The Big-O and Other Notations

6. Asymptotics: The Big-O and Other Notations Chapter 7 SEARCHING 1. Introduction, Notation 2. Sequential Search 3. Binary Search 4. Comparison Trees 5. Lower Bounds 6. Asymptotics: The Big-O and Other Notations Outline Transp. 1, Chapter 7, Searching

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

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

More information

Using metadata for automated testing of complex object structure

Using metadata for automated testing of complex object structure Using metadata for automated testing of complex object structure Jaroslav Zacek Faculty of Science, 30. dubna 22 University of Ostrava Ostrava 702 00, Czech Republic jaroslav.zacek@osu.cz Frantisek Hunka

More information

Class, Variable, Constructor, Object, Method Questions

Class, Variable, Constructor, Object, Method Questions Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx

More information

On Generalization of Fuzzy Concept Lattices Based on Change of Underlying Fuzzy Order

On Generalization of Fuzzy Concept Lattices Based on Change of Underlying Fuzzy Order On Generalization of Fuzzy Concept Lattices Based on Change of Underlying Fuzzy Order Pavel Martinek Department of Computer Science, Palacky University, Olomouc Tomkova 40, CZ-779 00 Olomouc, Czech Republic

More information

FAQ: Classes & Objects

FAQ: Classes & Objects Question 1: How do I define a class as a data type? Answer 1: Data types in Java can be simple data types such as integers and floating point numbers. Data types can also be complex, collecting many different

More information

Categorical models of type theory

Categorical models of type theory 1 / 59 Categorical models of type theory Michael Shulman February 28, 2012 2 / 59 Outline 1 Type theory and category theory 2 Categorical type constructors 3 Dependent types and display maps 4 Fibrations

More information

Wrapping a complex C++ library for Eiffel. FINAL REPORT July 1 st, 2005

Wrapping a complex C++ library for Eiffel. FINAL REPORT July 1 st, 2005 Wrapping a complex C++ library for Eiffel FINAL REPORT July 1 st, 2005 Semester project Student: Supervising Assistant: Supervising Professor: Simon Reinhard simonrei@student.ethz.ch Bernd Schoeller Bertrand

More information

Chapter 3 (part 3) Describing Syntax and Semantics

Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 30, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING SUB CODE / SUBJECT: CS1203 / Object oriented programming YEAR / SEM: II / III QUESTION BANK UNIT I FUNDAMENTALS PART-A (2 MARKS) 1. What is Object Oriented

More information

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph. Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial

More information

Character Stream : It provides a convenient means for handling input and output of characters.

Character Stream : It provides a convenient means for handling input and output of characters. Be Perfect, Do Perfect, Live Perfect 1 1. What is the meaning of public static void main(string args[])? public keyword is an access modifier which represents visibility, it means it is visible to all.

More information

Object-Oriented Design

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

More information

Syntax of Eiffel: a Brief Overview

Syntax of Eiffel: a Brief Overview Syntax of Eiffel: a Brief Overview EECS3311 A: Software Design Fall 2018 CHEN-WEI WANG Escape Sequences Escape sequences are special characters to be placed in your program text. In Java, an escape sequence

More information

More About Objects. Zheng-Liang Lu Java Programming 255 / 282

More About Objects. Zheng-Liang Lu Java Programming 255 / 282 More About Objects Inheritance: passing down states and behaviors from the parents to their children. Interfaces: requiring objects for the demanding methods which are exposed to the outside world. Polymorphism

More information

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner. HAS-A Relationship Association is a relationship where all objects have their own lifecycle and there is no owner. For example, teacher student Aggregation is a specialized form of association where all

More information

Example: Count of Points

Example: Count of Points Example: Count of Points 1 class Point { 2... 3 private static int numofpoints = 0; 4 5 Point() { 6 numofpoints++; 7 } 8 9 Point(int x, int y) { 10 this(); // calling the constructor with no input argument;

More information

CS 671, Automated Reasoning

CS 671, Automated Reasoning CS 671, Automated Reasoning Lesson 20: Type Constructs based on Intersection (II): dependent records, abstract data types, basic algebra April 3, 2001 Last time we discussed record types and their representation

More information

Inheritance -- Introduction

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

More information

The Data Organization

The Data Organization C V I T F E P A O TM The Data Organization 1251 Yosemite Way Hayward, CA 94545 (510) 303-8868 info@thedataorg.com By Rainer Schoenrank Data Warehouse Consultant May 2017 Copyright 2017 Rainer Schoenrank.

More information

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

INHERITANCE: EXTENDING CLASSES

INHERITANCE: EXTENDING CLASSES INHERITANCE: EXTENDING CLASSES INTRODUCTION TO CODE REUSE In Object Oriented Programming, code reuse is a central feature. In fact, we can reuse the code written in a class in another class by either of

More information

More on Objects in JAVA TM

More on Objects in JAVA TM More on Objects in JAVA TM Inheritance : Definition: A subclass is a class that extends another class. A subclass inherits state and behavior from all of its ancestors. The term superclass refers to a

More information

Java Fundamentals (II)

Java Fundamentals (II) Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class

More information

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1 Object-Oriented Languages and Object-Oriented Design Ghezzi&Jazayeri: OO Languages 1 What is an OO language? In Ada and Modula 2 one can define objects encapsulate a data structure and relevant operations

More information

CompuScholar, Inc. 9th - 12th grades

CompuScholar, Inc. 9th - 12th grades CompuScholar, Inc. Alignment to the College Board AP Computer Science A Standards 9th - 12th grades AP Course Details: Course Title: Grade Level: Standards Link: AP Computer Science A 9th - 12th grades

More information

Concepts of Programming Languages

Concepts of Programming Languages Concepts of Programming Languages Lecture 10 - Object-Oriented Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages

More information

CSCI2100B Data Structures Trees

CSCI2100B Data Structures Trees CSCI2100B Data Structures Trees Irwin King king@cse.cuhk.edu.hk http://www.cse.cuhk.edu.hk/~king Department of Computer Science & Engineering The Chinese University of Hong Kong Introduction General Tree

More information

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity COS 597A: Principles of Database and Information Systems Relational model continued Understanding how to use the relational model 1 with as weak entity folded into folded into branches: (br_, librarian,

More information

Softwaretechnik. Lecture 03: Types and Type Soundness. Peter Thiemann. University of Freiburg, Germany SS 2008

Softwaretechnik. Lecture 03: Types and Type Soundness. Peter Thiemann. University of Freiburg, Germany SS 2008 Softwaretechnik Lecture 03: Types and Type Soundness Peter Thiemann University of Freiburg, Germany SS 2008 Peter Thiemann (Univ. Freiburg) Softwaretechnik SWT 1 / 35 Table of Contents Types and Type correctness

More information

Discrete-Time Process-Oriented Simulation with J-Sim

Discrete-Time Process-Oriented Simulation with J-Sim Discrete-Time Process-Oriented Simulation with J-Sim Jaroslav Kačer 1 University of West Bohemia, Faculty of Applied Sciences, Department of Computer Science and Engineering, Univerzitní 8, 30614 Plzeň,

More information

Discrete Event Simulations with J-Sim

Discrete Event Simulations with J-Sim Discrete Event Simulations with J-Sim Jaroslav Kačer 1 jkacer@kiv.zcu.cz Abstract This paper describes J-Sim, a Java library for discrete-time process-oriented simulation. J-Sim is a fully portable successor

More information

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

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

More information

THE CONCEPT OF OBJECT

THE CONCEPT OF OBJECT THE CONCEPT OF OBJECT An object may be defined as a service center equipped with a visible part (interface) and an hidden part Operation A Operation B Operation C Service center Hidden part Visible part

More information

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A.

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A. Functions functions 1 Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A. a A! b B b is assigned to a a A! b B f ( a) = b Notation: If

More information

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner. HAS-A Relationship Association is a relationship where all objects have their own lifecycle and there is no owner. For example, teacher student Aggregation is a specialized form of association where all

More information

C++ Important Questions with Answers

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

More information

Object Oriented Programming with Java

Object Oriented Programming with Java Object Oriented Programming with Java What is Object Oriented Programming? Object Oriented Programming consists of creating outline structures that are easily reused over and over again. There are four

More information

Thompson groups, Cantor space, and foldings of de Bruijn graphs. Peter J. Cameron University of St Andrews

Thompson groups, Cantor space, and foldings of de Bruijn graphs. Peter J. Cameron University of St Andrews Thompson groups, Cantor space, and foldings of de Bruijn graphs Peter J Cameron University of St Andrews Breaking the boundaries University of Sussex April 25 The 97s Three groups I was born (in Paul Erdős

More information

Example: Count of Points

Example: Count of Points Example: Count of Points 1 public class Point { 2... 3 private static int numofpoints = 0; 4 5 public Point() { 6 numofpoints++; 7 } 8 9 public Point(int x, int y) { 10 this(); // calling Line 5 11 this.x

More information

1 Shyam sir JAVA Notes

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

More information

Symbolic Execution and Proof of Properties

Symbolic Execution and Proof of Properties Chapter 7 Symbolic Execution and Proof of Properties Symbolic execution builds predicates that characterize the conditions under which execution paths can be taken and the effect of the execution on program

More information

Synchronization SPL/2010 SPL/20 1

Synchronization SPL/2010 SPL/20 1 Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization

More information

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline :: Module Title Duration : Intro to JAVA SE7 and Programming using JAVA SE7 : 9 days Course Description The Java SE 7 Fundamentals course was designed to enable students with little or no programming experience

More information

CSE 100: C++ TEMPLATES AND ITERATORS

CSE 100: C++ TEMPLATES AND ITERATORS CSE 100: C++ TEMPLATES AND ITERATORS Announcements iclickers: Please register at ted.ucsd.edu. Start ASAP!! For PA1 (Due next week). 10/6 grading and 10/8 regrading How is Assignment 1 going? A. I haven

More information

Exploring Possibilities for Symmetric Implementation of Aspect-Oriented Design Patterns in Scala

Exploring Possibilities for Symmetric Implementation of Aspect-Oriented Design Patterns in Scala Exploring Possibilities for Symmetric Implementation of Aspect-Oriented Design Patterns in Scala Pavol PIDANIČ Slovak University of Technology in Bratislava Faculty of Informatics and Information Technologies

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter 2.1-2.7 p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

Slides for Faculty Oxford University Press All rights reserved.

Slides for Faculty Oxford University Press All rights reserved. Oxford University Press 2013 Slides for Faculty Assistance Preliminaries Author: Vivek Kulkarni vivek_kulkarni@yahoo.com Outline Following topics are covered in the slides: Basic concepts, namely, symbols,

More information

Object-Oriented Programming

Object-Oriented Programming 13 Object-Oriented Programming Exercises 13.1 Using Java as an example: 13.2 Code reuse: inhertiance, interfaces. In the case of an interface, any class implementing the Comparable interface can be sorted

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Object-Oriented

More information

Object-oriented Paradigm as Evolution of Structured approach in Programming

Object-oriented Paradigm as Evolution of Structured approach in Programming Object-oriented Paradigm as Evolution of Structured approach in Programming Galina Istatkova Abstract: A viewpoint is given about structured programming (SP) as a fundamental approach for complex software

More information

Goals of the Lecture OO Programming Principles

Goals of the Lecture OO Programming Principles Goals of the Lecture OO Programming Principles Object-Oriented Analysis and Design - Fall 1998 n Discuss OO Programming Principles Ð Messages Ð Information Hiding Ð Classes and Instances Ð Inheritance

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

1 Method Signatures and Overloading (3 minutes, 2 points)

1 Method Signatures and Overloading (3 minutes, 2 points) CS180 Spring 2010 Exam 1 Solutions, 15 February, 2010 Prof. Chris Clifton Turn Off Your Cell Phone. Use of any electronic device during the test is prohibited. Time will be tight. If you spend more than

More information

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 17 Inheritance Overview Problem: Can we create bigger classes from smaller ones without having to repeat information? Subclasses: a class inherits

More information

Object-Oriented Genetic Improvement for Improved Energy Consumption in Google Guava

Object-Oriented Genetic Improvement for Improved Energy Consumption in Google Guava Object-Oriented Genetic Improvement for Improved Energy Consumption in Google Guava Nathan Burles 1, Edward Bowles 1, Alexander E. I. Brownlee 2, Zoltan A. Kocsis 2, Jerry Swan 1, Nadarajen Veerapen 2

More information

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

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

More information

Java Software Solutions for AP Computer Science 3rd Edition, Lewis et al. 2011

Java Software Solutions for AP Computer Science 3rd Edition, Lewis et al. 2011 A Correlation of AP Computer Science 3rd Edition, Lewis et al. 2011 To the INTRODUCTION This document demonstrates how AP (Advanced Placement) Computer Science, 3rd Edition 2011, Lewis et al. meets the

More information

Quadratic Equations over Matrices over the Quaternions. By Diana Oliff Mentor: Professor Robert Wilson

Quadratic Equations over Matrices over the Quaternions. By Diana Oliff Mentor: Professor Robert Wilson Quadratic Equations over Matrices over the Quaternions By Diana Oliff Mentor: Professor Robert Wilson Fields A field consists of a set of objects S and two operations on this set. We will call these operations

More information

AP Computer Science A Syllabus

AP Computer Science A Syllabus AP Computer Science A Syllabus Course Overview The focus of this class is structured logic with an emphasis on developing simple, elegant algorithms and thinking in an object-oriented manner. The Java

More information

Commands, and Queries, and Features. Syntax of Eiffel: a Brief Overview. Escape Sequences. Naming Conventions

Commands, and Queries, and Features. Syntax of Eiffel: a Brief Overview. Escape Sequences. Naming Conventions Commands, and Queries, and Features Syntax of Eiffel: a Brief Overview EECS3311 A: Software Design Fall 2018 CHEN-WEI WANG In a Java class: Attributes: Data Mutators: Methods that change attributes without

More information

CS1004: Intro to CS in Java, Spring 2005

CS1004: Intro to CS in Java, Spring 2005 CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a

More information

36 Modular Arithmetic

36 Modular Arithmetic 36 Modular Arithmetic Tom Lewis Fall Term 2010 Tom Lewis () 36 Modular Arithmetic Fall Term 2010 1 / 10 Outline 1 The set Z n 2 Addition and multiplication 3 Modular additive inverse 4 Modular multiplicative

More information

Lecture 2 and 3: Fundamental Object-Oriented Concepts Kenneth M. Anderson

Lecture 2 and 3: Fundamental Object-Oriented Concepts Kenneth M. Anderson Lecture 2 and 3: Fundamental Object-Oriented Concepts Kenneth M. Anderson January 13, 2005 January 18, 2005 1 of 38 Lecture Goals Introduce the basic concepts of object-oriented analysis/design/programming

More information

Inheritance and Polymorphism

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

More information

CE221 Programming in C++ Part 1 Introduction

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

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Atelier Java - J1. Marwan Burelle.  EPITA Première Année Cycle Ingénieur. marwan.burelle@lse.epita.fr http://wiki-prog.kh405.net Plan 1 2 Plan 3 4 Plan 1 2 3 4 A Bit of History JAVA was created in 1991 by James Gosling of SUN. The first public implementation (v1.0) in 1995.

More information

Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn. 4. Testing

Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn. 4. Testing 4. vs. Model Checking (usually) means checking the correctness of source code Model Checking means verifying the properties of a model given in some formal (not program code) notation Attention: things

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

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

102. Introduction to Java Programming

102. Introduction to Java Programming 102. Introduction to Java Programming Version 5.0 Java is a popular and powerful language. Although comparatively simple in its language structure, there are a number of subtleties that can trip up less

More information

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking Agenda COMP 181 Type checking October 21, 2009 Next week OOPSLA: Object-oriented Programming Systems Languages and Applications One of the top PL conferences Monday (Oct 26 th ) In-class midterm Review

More information

Comparing sizes of sets

Comparing sizes of sets Comparing sizes of sets Sets A and B are the same size if there is a bijection from A to B. (That was a definition!) For finite sets A, B, it is not difficult to verify that there is a bijection from A

More information

Notes for Lecture 10

Notes for Lecture 10 COS 533: Advanced Cryptography Lecture 10 (October 16, 2017) Lecturer: Mark Zhandry Princeton University Scribe: Dylan Altschuler Notes for Lecture 10 1 Motivation for Elliptic Curves Diffie-Hellman For

More information