(Tomorrow 9/26/25) Java Ch. 2 Pt. 1

0.0(0)
studied byStudied by 1 person
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/35

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

36 Terms

1
New cards

Write a program that computes the area of a circle

knowt flashcard image
2
New cards

What is the purpose of declaring a variable?

To allocate memory for the variable’s data.

3
New cards

Import the Java scanner library implicitly.

import java.util.* ;

4
New cards

Import the Java scanner library explicitly.

import java.util.Scanner;

5
New cards

Create an instance of a scanner.

Scanner input = new Scanner(System.in);

6
New cards

Receive a double value from user input.

double d = input.nextDouble();

7
New cards

Identifier

the name of a variable

8
New cards

Identifiers can consist of what characters

Letters

Digits

Underscores

Dollar signs

9
New cards

An identifier cannot start with a…

Digit

10
New cards

An identifier cannot be the same as a…

reserved keyword

11
New cards

How long can an identifier be?

Any length

12
New cards

Declare an integer variable.

int x;

13
New cards

Declare a double variable.

double x;

14
New cards

Declare a character variable.

char x;

15
New cards

Assign the letter “B” to a declared character variable “ch“.

ch = ‘B’;

16
New cards

Declare and assign a variable in one line.

int x = 1;

17
New cards

Named constant

A variable whose value cannot be changed once it is assigned.

18
New cards

What is the keyword for declaring named constants?

final

19
New cards

Naming convention for named constants.

-All uppercase

-Underscores for spaces

ex: TAX_RATES

20
New cards

When should a value be assigned to a named constant?

Immediately after it is declared.

21
New cards

Naming convention for identifiers and methods.

-No spaces

-use all lowercase for the first word, and capitalize all subsequent words.

22
New cards

Write the remainder of 20 divided by 3 in Java.

20%3;

ans: 2

23
New cards

5/2 will result in…

2

24
New cards

5.0/2 will result in…

2.5

25
New cards

Today is Saturday, and your friends want to meet up in 10 days. Write a statement to determine what day of the week that will be.

knowt flashcard image
26
New cards

Write a program that prompts a user to enter any number of seconds, reads it and then calculates the minutes and remaining seconds from it.

knowt flashcard image
27
New cards

Storage size of byte data type.

8-bit signed.

28
New cards

Storage size of short data type.

16-bit signed.

29
New cards

Storage size of float data type.

32-bit |EEE 754

30
New cards

Storage size of double data type.

64-bit |EEE 754

31
New cards

Are values of the float data type stored accurately?

No, values are approximates.

32
New cards

Are values of the int data type stored accurately?

Yes

33
New cards

What is the result of:

System.out.println(1.0 - 0.9);

0.09999999999999998, not 0.1

34
New cards

Calculate 2 to the power of 3

Math.pow(2, 3)

35
New cards

Literal

A value that appears directly in the program.

ex: in int i = 34, the literal is 34

36
New cards

What is the result:

byte b = 1000

Compilation error. 1000 is too large to store with the byte data type.