# Java ![rw-book-cover](https://m.media-amazon.com/images/I/81ppUpOId3L._SY160.jpg) ## Metadata - Author: Herbert Schildt and Danny Coward - Full Title: Java - Category: #books ## Highlights - Bytecode is a highly optimized set of instructions designed to be executed by what is called the Java Virtual Machine (JVM), which is part of the Java Runtime Environment (JRE). In essence, the original JVM was designed as an interpreter for bytecode. ([Location 648](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=648)) - Encapsulation is a programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse. ([Location 749](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=749)) - Within an object, code, data, or both may be private to that object or public. Private code or data is known to and accessible by only another part of the object. That is, private code or data cannot be accessed by a piece of the program that exists outside the object. When code or data is public, other parts of your program can access it even though it is defined within an object. Typically, the public parts of an object are used to provide a controlled interface to the private elements of the object. ([Location 752](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=752)) - Java’s basic unit of encapsulation is the class. ([Location 756](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=756)) - Objects are instances of a class. Thus, a class is essentially a set of plans that specify how to build an object. ([Location 758](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=758)) - The code and data that constitute a class are called members of the class. Specifically, the data defined by the class are referred to as member variables or instance variables. The code that operates on that data is referred to as member methods or just methods. Method is Java’s term for a subroutine. ([Location 759](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=759)) - Polymorphism (from Greek, meaning “many forms”) is the quality that allows one interface to access a general class of actions. ([Location 763](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=763)) - Polymorphism helps reduce complexity by allowing the same interface to be used to specify a general class of action. ([Location 774](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=774)) - Inheritance is the process by which one object can acquire the properties of another object. ([Location 777](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=777)) - Without the use of hierarchies, each object would have to explicitly define all of its characteristics. Using inheritance, an object need only define those qualities that make it unique within its class. ([Location 784](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=784)) - The first thing that you must learn about Java is that the name you give to a source file is very important. ([Location 826](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=826)) - In Java, a source file is officially called a compilation unit. It is a text file that contains (among other things) one or more class definitions. ([Location 828](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=828)) - The keyword static allows main( ) to be called before an object of the class has been created. This is necessary because main( ) is called by the JVM before any objects are made. The keyword void simply tells the compiler that main( ) does not return a value. ([Location 885](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=885)) - Java contains two general categories of built-in data types: object-oriented and non-object-oriented. ([Location 1190](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1190)) - The term primitive is used here to indicate that these types are not objects in an object-oriented sense but rather are normal binary values. ([Location 1193](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1193)) - literals refer to fixed values that are represented in their human-readable form. ([Location 1288](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1288)) - Literals are also commonly called constants. ([Location 1289](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1289)) - As you may know, in programming it is sometimes easier to use a number system based on 8 or 16 instead of 10. The number system based on 8 is called octal, and it uses the digits 0 through 7. ([Location 1306](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1306)) - The base 16 number system is called hexadecimal and uses the digits 0 through 9 plus the letters A through F, which stand for 10, 11, 12, 13, 14, and 15. ([Location 1308](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1308)) - This means that objects declared in the outer scope will be visible to code within the inner scope. ([Location 1378](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1378)) - relational operator and logical operator, relational refers to the relationships that values can have with one another, and logical refers to the ways in which true and false values can be connected together. Since the relational operators produce true or false results, they often work with the logical operators. ([Location 1438](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1438)) - The only difference between the normal and short-circuit versions is that the normal operands will always evaluate each operand, but short-circuit versions will evaluate the second operand only when necessary. ([Location 1462](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1462)) - When compatible types are mixed in an assignment, the value of the right side is automatically converted to the type of the left side. ([Location 1511](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1511)) - otherwise integer division. ([Location 1599](https://readwise.io/to_kindle?action=open&asin=B0CW1GK2Z3&location=1599))