Chapter 2 Data Types

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Predefined N_______F_______class allows you to format values as currency or percentages

NumberFormat

Value Ranges per Type: char

One symbol in single quotes 'a'

Integer Types: A very small number (-128 to +127)

byte

Integer Types

byte, (A very small number (-128 to +127)) short, (A small number (-32768 to +32767)) int, (A large number (-2,147,483,648 to +2,147,483,647))

There are eight fundamental data types in Java Four of them represent integers:

byte, short, int, long

int cansPerPack = 6; //declare and initialize what is the variable name?

cansPerPack

There are eight fundamental data types in Java One of them represents characters:

char

Operators can be combined into

complex expressions

In Java, we use the final modifier to declare a

constant

int is a

data type

Multiple variables can be created in one

declaration

If you are interested in the remainder, use remainder operator (%) to get the remainder after

dividing the second operand into the first.

Unless specified otherwise, white space is used to separate the

elements of the input.

You can not use symbols such as %, ? in a

variable name

int total; total is a

variable name

The DecimalFormat class can be used to format a floating point value in

various ways.

% as an operator means

remainder

You might need to ask for input (prompt for input) and then

save what was entered.

Scanner scan = new Scanner (System.in); Once created, the Scanner object can be used to invoke various input methods, such as:

scan.nextLine();

variable declaration ends with a

semicolon

Integer Types: A small number (-32768 to +32767)

short

The constructor of the DecimalFormat class takes a ______ that represents a pattern for the formatted number.

string

A variable is a name to a

temporary storage location

The nextLine method reads all of the input until

the end of the line is found.

If both operands to the division operator (/) are integers,

the result is an integer (no rounding).

A constant is a variable except that it holds

the same value during its entire existence.

The difference between the various numeric types is their size, and therefore

the values they can store

A Scanner object can be set up to read input from various sources, including the user

typing values on the keyboard.

By convention constant names are all in

uppercase.

The compiler will issue an error if you try to change the ________ of a constant.

value

You can use _ in a variable name

$

short size

16 bits

float size

32 bits

int size

32 bits

int cansPerPack = 6; //declare and initialize The initial value is

6

How many bits in a long?

64 bits

how many bits in a double?

64 bits

byte size

8 bits

Value Ranges per Type Floating Point Types float:

A huge number with decimal places

Predefined D_____F______ class allows you to format values based on a pattern.

DecimalFormat

Reading Input - Three step process step 1

Import the Scanner class from its 'package' java.util

There are eight fundamental data types in Java And one of them represents boolean values:

boolean

Value Ranges per Type: Floating Point Types double:

Much more precise, for heavy math

Variable Declaration includes

Name of a variable Type (or size) of a variable

Value Ranges per Type: true or false

boolean

Scanner scan = new Scanner (System.in); The new operator creates the

Scanner object

Reading Input - Three step process step 2

Setup an object of the Scanner class

Keyboard input is represented by the ______.__ object

System.in

Reading Input - Three step process step 3

Use methods of the new Scanner object to get input (save input)

A variable name must start with

a letter or the underscore

Each formatter object has a method called format that returns a string with the specified information in the

appropriate format

Arithmetic expressions compute numeric results and make use of the

arithmetic operators:

There are eight fundamental data types in Java Two of them represent floating point numbers:

float, double

The NumberFormat class has static methods that return a

formatter object

The Java standard class library contains classes that provide

formatting capabilities.

The Scanner class is part of the java.util class library, and must be ________ into a program to be used.

imported

Integer Types: A large number (-2,147,483,648 to +2,147,483,647)

int

int cansPerPack = 6; //declare and initialize what is the data type?

int

Methods nextInt and nextDouble read

integer and double from the keyboard.

Both DecimalFormat and NumberFormat are part of what package?

java.text

The Scanner class is part of the ____.____ class library, and must be imported into a program to be used.

java.util

The next method of the Scanner class reads the next a string from the

keyboard.

a huge integer type would be a

long

A variable must have a

name, a type, (and may be an initial value)

An expression is a combination of one or more

operators and operands

Use the 'assignment statement' ( with an '=' ) to

place a new value into a variable

Formatting Output It is often necessary to format values in certain ways so that they can be

presented properly.

types of storage

primary storage and secondary storage

Predefined Scanner class

provides convenient methods for reading input values of various types.

Scanner scan = new Scanner (System.in); creates a Scanner object that

reads from the keyboard:


संबंधित स्टडी सेट्स

Chapter 3, Study Guide Questions

View Set

Andrew Carnegie & Samuel Gompers

View Set

Masculino & Femenino-Nacionalidades

View Set

A&P 1 Ch. 11 Functional Organization of Nervous System

View Set

Certified Ethical Hacker 312-50v11 EXAM STUDY

View Set

(2.1) The Biology Behind Our Behavior

View Set