Java Chapter 2 (Elementary Programming)

Description

college Computer Science Note on Java Chapter 2 (Elementary Programming), created by hermodh3290 on 31/08/2015.
hermodh3290
Note by hermodh3290, updated more than 1 year ago
hermodh3290
Created by hermodh3290 over 8 years ago
18
1

Resource summary

Page 1

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 floating point numbers of two different precisions. Java provides two floating-point types (float and double) that represent floating point number 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 += (additional 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 a widening a type. Casting a variable of a type with a large range to a variable with a smaller range is known as a 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.

Show full summary Hide full summary

Similar

Java Week 5 Object Oriented Programming
Troy Bowlin
Computing Hardware - CPU and Memory
ollietablet123
SFDC App Builder 2
Parker Webb-Mitchell
Data Types
Jacob Sedore
Intake7 BIM L1
Stanley Chia
Software Processes
Nurul Aiman Abdu
Design Patterns
Erica Solum
CCNA Answers – CCNA Exam
Abdul Demir
Abstraction
Shannon Anderson-Rush
Spyware
Sam2
HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush