0% found this document useful (0 votes)
12 views2 pages

Java Programming Basics Explained

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Java Programming Basics Explained

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

8/15/24, 9:35 PM Chapter Summary - Elementary Programming

CHAPTER 2 SUMMARY

ELEMENTARY PROGRAMMING

Identifiers are names for naming elements such as variables, constants,


methods, classes, packages in a program.

An identifier is a sequence of characters that consists of letters, digits,


underscores (_), and dollar signs ($). An identifier must start with a letter
or an underscore. It cannot start with a digit. An identifier cannot be a
reserved word. An identifier can be of any length.

Variables are used to store data in a program. To declare a variable is to tell


the compiler what type of data a variable can hold.

There are two types of import statements: specific import and wildcard
import. The specific import specifies a single class in the import
statement; the wildcard import imports all the classes in a package.

In Java, the equal sign (=) is used as the assignment operator.

A variable declared in a method must be assigned a value before it can be


used.

A named constant (or simply a constant) represents permanent data that


never changes.

A named constant is declared by using the keyword final.

Java provides four integer types (byte, short, int, and long) that
represent integers of four different sizes.

localhost:63342/2024_07_PG1_sevvalyurtseven/src/summary/chapter2/[Link]?_ijt=nji6nebr8r45mpi05hte5l5igl&_ij_reload=RELOAD_ON_S… 1/2
8/15/24, 9:35 PM Chapter Summary - Elementary Programming

Java provides two floating-point types (float and double) that represent
floating-point numbers of two different precisions.

Java provides operators that perform numeric operations: + (addition), –


(subtraction), * (multiplication), / (division), and % (remainder).

Integer arithmetic (/) yields an integer result.

The numeric operators in a Java expression are applied the same way as in
an arithmetic expression.

Java provides the augmented assignment operators += (addition


assignment), –= (subtraction assignment), *= (multiplication
assignment), /= (division assignment), and %= (remainder
assignment).

The increment operator (++) and the decrement operator (––)


increment or decrement a variable by 1.

When evaluating an expression with values of mixed types, Java


automatically converts the operands to appropriate types.

You can explicitly convert a value from one type to another using the
(type)value notation.

Casting a variable of a type with a small range to a variable of a type with a


larger range is known as widening a type.

Casting a variable of a type with a large range to a variable of a type with a


smaller range is known as narrowing a type.

Widening a type can be performed automatically without explicit casting.


Narrowing a type must be performed explicitly.

In computer science, midnight of January 1, 1970, is known as the UNIX


epoch.

localhost:63342/2024_07_PG1_sevvalyurtseven/src/summary/chapter2/[Link]?_ijt=nji6nebr8r45mpi05hte5l5igl&_ij_reload=RELOAD_ON_S… 2/2

You might also like