Book Image

Introduction to JVM Languages

Book Image

Introduction to JVM Languages

Overview of this book

Anyone who knows software development knows about the Java Virtual Machine. The Java Virtual Machine is responsible for interpreting Java byte code and translating it into actions. In the beginning, Java was the only programming language used for the JVM. But increasing complexity of the language and the remarkable performance of the JVM created an opening for a new generation of programming languages. If you want to build a strong foundation with the Java Virtual Machine and get started with popular modern programming languages, then this book is for you. The book will begin with a general introduction of the JVM and its features, which are common to the JVM languages, helping you get abreast with its concepts. It will then dive into explaining languages such as Java, Scala, Clojure, Kotlin, and Groovy and will show how to work with each language, their features, use cases, and pros and cons. By writing example projects in those languages and focusing on each language’s strong points, it will help you find the programming language that is most appropriate for your particular needs. By the end of the book, you will have written multiple programs that run on the Java Virtual Machine and know about the differences between the various languages.
Table of Contents (21 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

OOP in Java


As discussed in the previous chapters, while Java has primitive types, everything else is an object. While Java is not considered a pure OOP language because of its support for primitive types, it is still a serious OOP language.

To use Java effectively, you should know OOP. Don't worry if your OOP knowledge is rusty. While this chapter does not teach it, we will try to refresh your memory along the way. This chapter concentrates on all OOP-related subjects:

  • Defining classes
  • Defining packages
  • Adding class members: variables and methods
  • Constructors and deconstructors
  • Inheritance
  • Interfaces
  • Abstract classes
  • Upcasting and downcasting

Defining classes

As we have seen in the examples from previous chapters, a class can simply be defined with Java's class keyword, followed by the class name and brackets { }. The brackets visually show the programmer what code is part of the class:

    class ClassName {
    }

The preceding code will compile. It complies with all Java's syntax rules. Removing any...