Data Types and Variables

¡Supera tus tareas y exámenes ahora con Quizwiz!

What character starts and stops the text string input into the println() function?

"

What text string is printed to the screen with this statement? System.out.println("#\"##\\#");

#"##\#

What is the smallest possible integer value that can be stored in a 𝗯𝘆𝘁𝗲 data type?

-128

What is the smallest possible integer value that can be stored in a 𝗶𝗻𝘁 data type?

-2,147,483,648

What is the smallest possible integer value that can be stored in a 𝘀𝗵𝗼𝗿𝘁 data type?

-32,768

What is the smallest possible integer value that can be stored in a 𝗹𝗼𝗻𝗴 data type?

-9,223,372,036,854,775,808

After the following statement, what value is stored in the myInteger variable? int myInteger;

0

What is the value of 𝗿𝗲𝘀𝘂𝗹𝘁𝟭 after this code runs? 𝗶𝗻𝘁 value1 = 10; 𝗶𝗻𝘁 value2 = 4; 𝗱𝗼𝘂𝗯𝗹𝗲 result1 = value1 / value2;

2.0

How many copies of the value 42 are created by this code? 𝗶𝗻𝘁 𝗺𝘆𝗜𝗻𝘁𝟭 = 𝟰𝟮; 𝗶𝗻𝘁 𝗺𝘆𝗜𝗻𝘁𝟮 = 𝗺𝘆𝗜𝗻𝘁𝟭; 𝗶𝗻𝘁 𝗺𝘆𝗜𝗻𝘁𝟯 = 𝗺𝘆𝗜𝗻𝘁𝟮;

3

After the following code is run: 𝗱𝗼𝘂𝗯𝗹𝗲 num1 = 9.6; 𝗶𝗻𝘁 num2 = (𝗶𝗻𝘁)num1; What is the value in 𝗻𝘂𝗺𝟮?

9

Which of the following variable names is invalid?

All of these are valid{_myScore; My_1_Score; MyScore}

What is the best naming style to use for a variable that contains a count of the number of frogs in a pond?

All styles are equally valid; just be consisten{frog_count; frogCount; FrogCount}

Which data type can hold exactly two different values?

Boolean

Which data type would you use to hold a true or false value?

Boolean

What is the smallest data type that can hold the value 126?

Byte

Which of the following data types takes up the most bytes of computer memory?

Double

What keyword do you use to ensure a variable can never change values while your program is running?

Final

If you needed to hold the integer value 36,493, which numeric data type would you use?

Int

What are the two main categories of numeric data types as stored in computers?

Integer and Floating Point

What's wrong with always using the largest possible data type to store your data?

Larger data types take more memory

What properties on the Java numeric wrapper classes hold the largest and smallest possible values for that data type?

MAX_VALUE and MIN_VALUE

Which object is used to write output to the console?

System.out

How would you print the following string to the console? "𝗡𝗼𝗻𝗲𝘀𝗲𝗻𝗰𝗲", 𝘀𝗵𝗲 𝘀𝗮𝗶𝗱!

System.out.println("\"Nonsense\", she said!");

What governs a numeric data type's precision and range?

The number of bytes in memory the data occupies

Which of the following variable names is invalid?

They are all invalid.

Which escape character can be used to insert a backslash in a string?

\\

Which statement correctly assigns the character value 'x' to the 𝗰𝗵𝗮𝗿 variable myChar?

char myChar = 'x';

Which assignment statement correctly assigns a decimal value to the variable "myFloat" that was already declared as a float data type?

myFloat = 2.1F;

What is the difference between the print() and println() functions?

println() will automatically wrap to the next line; print() will not


Conjuntos de estudio relacionados

Difference between hardware and software

View Set

Chapter 13 Chapter Test (84% correct)

View Set

Motivation and Emotion, Development Psychology, Test question, Test question

View Set

Java OCA 1Z0-808 - Operators and Statements

View Set

Vocab Unit 8B Remote Learning, Vocab Unit 8A - Remote Learning 4/20/20

View Set

PE: Principles of Training (SPORT & FITT)

View Set

7G1 Math Exam Review First Semester

View Set

HSC4501: EXAM 3 STUDY GUIDE, iCLICKERS, AND HW ASSIGNMENTS

View Set

Properties of Numbers & Fractions

View Set