0% found this document useful (0 votes)
49 views3 pages

Where Storage Lives: High-Precision Numbers

A parameterized type allows a class to be customized for different types. For example, a parameterized container class could be customized to only accept and retrieve Shape objects. Exception handling predates object-oriented programming, though exceptions are usually represented by objects in OO languages. The Java runtime must know the lifetime of all stack variables to limit program flexibility, so Java objects are stored in the heap rather than the stack. Primitive types include high-precision numbers and boolean types which are treated as one-bit values and support bitwise operations except for bitwise NOT. Casting from a derived type to a base type is called upcasting and is always safe, while casting from a base type to a derived type requires runtime checks.

Uploaded by

Neha Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views3 pages

Where Storage Lives: High-Precision Numbers

A parameterized type allows a class to be customized for different types. For example, a parameterized container class could be customized to only accept and retrieve Shape objects. Exception handling predates object-oriented programming, though exceptions are usually represented by objects in OO languages. The Java runtime must know the lifetime of all stack variables to limit program flexibility, so Java objects are stored in the heap rather than the stack. Primitive types include high-precision numbers and boolean types which are treated as one-bit values and support bitwise operations except for bitwise NOT. Casting from a derived type to a base type is called upcasting and is always safe, while casting from a base type to a derived type requires runtime checks.

Uploaded by

Neha Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Downcasting and the runtime checks require extra time for the running program and extra effort

from the programmer. A parameterized type is a class that the compiler can automatically customize to work with particular types. For example, with a parameterized container, the compiler could customize that container so that it would accept only Shapes and fetch only Shapes.

Its worth noting that exception handling isnt an object-oriented feature, although in object-oriented languages the exception is normally represented by an object. Exception handling existed before objectoriented languages.

Where storage lives


Registers.

The stack. The Java system must know, while it is creating the program, the exact lifetime of all the items that are stored on the stack. This constraint places limits on the flexibility of your programs, so while some Java storage exists on the stackin particular, object referencesJava objects themselves are not placed on the stack.

The heap. This is a general-purpose pool of memory (also in the RAM area) where all Java objects live. Constant storage. Non-RAM storage. If data lives completely outside a program, it can exist while the program is not running, outside the control of the program. The two primary examples of this are streamed objects, in which objects are turned into streams of bytes, generally to be sent to another machine, and persistent objects, in which the objects are placed on disk so they will hold their state even when the program is terminated.

Primitive types:

High-precision numbers

Bitwise operators can be combined with the = sign to unite the operation and assignment: &=, |= and ^= are all legitimate. (Since ~ is a unary operator, it cannot be combined with the = sign.)

The boolean type is treated as a one-bit value, so it is somewhat different. You can perform a bitwise AND, OR, and XOR, but you cant perform a bitwise NOT (presumably to prevent confusion with the logical NOT).

For booleans, the bitwise operators have the same effect as the logical operators except that they do not short circuit.

Shift operators

Casting from a derived type to a base type moves up on the inheritance diagram, so its commonly referred to as upcasting. Upcasting is always safe because youre going from a more specific type to a more general type.

final data
It can be a compile-time constant that wont ever change.

2. It can be a value initialized at run time that you dont want changed.
In the case of a compile-time constant, the compiler is allowed to fold the constant value into any calculations in which its used; that is, the calculation can be performed at compile time, eliminating some run-time overhead.

Blank finals
Java allows the creation of blank finals, which are fields that are declared as final but are not given an initialization value.

final methods

Polymorphism:
separation of interface from implementation, to decouple what from how. to decouple what from how.

covariant return types, which means that an overridden method in a derived class can return a type derived from the type returned by the callbacks. With a callback, some other object is given a piece of information that allows it to call back into the originating object at some later point. base-class method:

A closure is a callable object that retains information from the scope in which it was created.

You might also like