Undergraduate Topics in Computer Science
Series Editor
Ian Mackie
University of Sussex, Brighton, UK
Advisory Editors
Samson Abramsky
Department of Computer Science, University of Oxford, Oxford, UK
Chris Hankin
Department of Computing, Imperial College London, London, UK
Dexter C. Kozen
Computer Science Department, Cornell University, Ithaca, NY, USA
Andrew Pitts
William Gates Building, University of Cambridge, Cambridge, UK
Hanne Riis Nielson
Department of Applied Math and Computer Science, Technical University of Denmark, Kgs. Lyngby, Denmark
Steven S. Skiena
Department of Computer Science, Stony Brook University, Stony Brook, NY, USA
Iain Stewart
Department of Computer Science, Science Labs, University of Durham, Durham, UK
Mike Hinchey
Lero, Tierney Building, University of Limerick, Limerick, Ireland
Undergraduate Topics in Computer Science (UTiCS) delivers high-quality instructional content for undergraduates studying in all areas of computing and information science. From core foundational and theoretical material to final-year topics and applications, UTiCS books take a fresh, concise, and modern approach and are ideal for self-study or for a one- or two-semester course. The texts are all authored by established experts in their fields, reviewed by an international advisory board, and contain numerous examples and problems, many of which include fully worked solutions.
The UTiCS concept relies on high-quality, concise books in softback format, and generally a maximum of 275-300 pages. For undergraduate textbooks that are likely to be longer, more expository, Springer continues to offer the highly regarded Texts in Computer Science series, to which we refer potential authors.
More information about this series at http://www.springer.com/series/7592
Kingsley Sage
Concise Guide to Object-Oriented Programming An Accessible Approach Using Java
Kingsley Sage
School of Engineering and Informatics, University of Sussex, Falmer, East Sussex, UK
ISSN 1863-7310 e-ISSN 2197-1781
Undergraduate Topics in Computer Science
ISBN 978-3-030-13303-0 e-ISBN 978-3-030-13304-7
https://doi.org/10.1007/978-3-030-13304-7
Library of Congress Control Number: 2019931822
Springer Nature Switzerland AG 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
The twenty-first century continues to experience the relentless expansion of the IT revolution into our daily lives. We consume services, do our shopping on-line, listen to music streams and watch movies on demand. The impact of social media has had a profound impact on our society and has changed fundamentally the way we obtain and consume news, information and ideas. There is little sign of a slowdown in this dramatic shift in our relationship with technology. Vast research budgets are being applied to the development of autonomous vehicles, and in applying Artificial Intelligence to change the way we live. But it has also changed the demand for skills within our workforce. The demand for manual skills is in decline, and the demand for IT and programming skills is rising at an unprecedented rate.
In comparison to the industrialists of the nineteenth and twentieth centuries, the twenty-first-century entrepreneurs are experts in IT, programming, software design and development, and developing practical applications using concepts such as Artificial Intelligence for our daily lives. With this profound paradigm shift has come a need for the workforce of many industrialised nations to evolve. Governments recognise the need for a huge increase in the workforce with programming skills. In the United Kingdom, and in many other industrialised nations, core coding skills are now a part of the secondary school curriculum. Learning to program is no longer considered to be just a part of the traditional journey of the Computer Science undergraduate, but a broader skill that underpins an IT literate workforce for the modern age.
What is the Purpose of This Book?
When I was first approached to write this book, it was suggested that its purpose was to provide an accessible introduction to coding and the world of Object Oriented Programming (OOP). Standard texts on the subject often fall between those that provide only a very lightweight treatment of the subject (a little knowledge can be a frustrating thing), and those that run to 500 pages or more that are rather better suited as reference texts or as support on a lengthy period of study in depth. The challenge for this book is to provide an accessible introduction to the world of coding and OOP in a way that is helpful to the first-time coder and allows them to develop and to understand their knowledge and skills in a way that is relevant and practical. The examples developed for this book are intended to show how OOP skills can be used to create applications and programs that have everyday value, rather than examples that have been synthesised solely to demonstrate an academic point.
The reader should be able to use this book to develop a solid appreciation of OOP and how to code. The programming language used throughout is Java. Java has been chosen as it can be used across all computing platforms, because it has a commercial skill that has a clear on-going value derived from its adoption as a core language for smartphone applications on the Android platform, and as the language at the heart of the Java EE 8 Jakarta Enterprise scale framework. The book focusses on the core Java language and does not consider smartphone or EE 8 coding, as these require skills over and above what this book is about. However, a knowledge of core Java coding and some of the related issues also discussed in this book would form an appropriate pre-requisite for the further study of these topics.
Although this book uses Java as its illustrative programming language, many of the ideas may be translated directly into other OO languages such as C++, C# and others. Throughout this book, programming in Java is demonstrated using the BlueJ Integrated Development Environment (IDE). BlueJ is a well-established IDE for learning BlueJ and is widely used in schools and Universities. Eclipse is the closest product to an industry standard for the development of Java, but it is often found too complex for the task of teaching and learning.