4Classes in Selected Languages
This chapter presents classes and objects provided by various languages, based on the model studied in Chapter 3. Java’s classes are examined in section 4.1, providing an instantiation of the model presented in section 3.2. Section 4.2 depicts the object mechanism of C++, which is a slightly more complex implementation of the model examined in section 3.2. Object-oriented features of OCaml are presented in section 4.3 and they provide an interpretation of the model, which is pretty different from those of Java and C++. This chapter ends with a presentation of classes and objects of Python, also examining some other features in order to say a little more about this language used in this book, to implement semantics of functional and imperative features in Volume 1.
4.1. Classes in Java
4.1.1. General presentation
The programming language Java was created in 1995 by Sun Microsystems and is now distributed by Oracle Corporation. The version used here is Java SE (Standard Edition) 10.0.2. Elements of concrete syntax and terms used here come from the reference manual [GOS 19] and the documentation provided by Oracle.
Java is a language based on classes (class)
(Ans. 1.2). It is statically typed (Ans. 1.1), allows explicit type conversions (cast)
but also implicit ones: adding a value of type String
to a value of type int
converts this integer into a String
and returns a String
. Hence, the language is not strongly typed, an expression possibly having ...
Get Concepts and Semantics of Programming Languages 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.