Type Conversions and Characters

Ace your homework & exams now with Quizwiz!

If outputting multiple character variables with one statement, the argument for System.out.print() should start with ____________

"" + [example: System.out.print ("" + a + b + c)]

Goal output: Say "Hello" System.out.print(_____);

"Say \" Hello\""

ASCII can represent 255 items, whereas Unicode can represent over _______________ items

64,000

7 is stored as _______

7 without quotes is an integer literal, and so is stored as 7. In contrast, '7' with quotes is a character literal, and would be stored as 55 (per the ASCII table).

________________ is an early standard for encoding characters as numbers.

ASCII

Assume char variable userKey is already declared. Write a statement that assigns userKey with the letter a.

userKey = 'a'; (notice the single quotes used in assignment of value to char)

\n

newline

What does this assign? char myChar = '\''

single quote

A character literal is surrounded with __________ _______, as in myChar = 'm'

single quotes

\t

tab

A __________ ____________ explicitly converts a value of one type to another type.

type cast

A _________ ______________________ is a conversion of one data type to another, such as an int to a double.

type conversion

Under the hood, a char variable stores a ____________ . Ex: 'a' is stored as 97. In an output statement, the compiler outputs the number's corresponding character.

number

What does this assign? char myChar = '\\'

one backslash \

For assignments, the _________ side type is converted to the left side type IF the conversion is possible without loss of precision.

right (this side is changed to match the left)

Given string "a\"b", the first character is stored in memory as 97 (the numeric value for 'a'). What is stored for the second character?

You don't need to look this up on an ASCII chart, the point of the question is to point out that: The compiler treats \" as a single character, a double quote ", whose ASCII value is 34. So the next character asked about n the question is " not the letter b.

A variable of char type, as in char myChar;, can store a ___________ _______________________ like the letter m.

single character (letter, punctuation, special character)

Goal output: OK bye(Assume a tab exists between OK and bye). System.out.print(_____);

OK\tbye (No spaces are needed. Upon seeing the \, the compiler looks at the next character. Seeing the t, the compiler inserts a single tab character.)

What is this an example of? arrowBody = '-'; arrowHead = '>';

These are two lines that assign value to char arrowBody and char arrowHead. This is an example of assigning values to char variables that have been declared.

Many earlier programming languages like C or C++ use ASCII. Java uses a more recent standard called __________________.

Unicode

How do you get one character to fill in a char value from user input, such as keyboard (system.in) ?

myChar = scnr.next().charAt(0); (example: middleInitial = scnr.next().charAt(0); assuming the char middleInitial has already been declared)

A common error is to use double quotes rather than single quotes around a character literal, as in myChar = "x", yielding a ________ _________

compiler error

Similarly, a common error is to forget the quotes around a character literal, as in middleInitial = x, usually yielding a _________ _________ (unless x is also a declared variable, then perhaps yielding a logic error).

compiler error

What does this assign? char myChar = '\"'

double quote

________ - ___ - ___________ conversion may lose precision, so is not automatic.

double-to-int

For an arithmetic operator like + or *, if _____________ operand is a double, the other is automatically converted to double, and then a floating-point operation is performed.

either

The compiler automatically performs several common conversions between int and double types, such automatic conversion known as __________ ________________________.

implicit conversion


Related study sets

Unit 3: Private Sources of Funds

View Set

Ch 58: Drug therapy for Substance Abuse Disorders

View Set

Ch36: Pain Management in Children

View Set

Leading Marines - Admin and Communication (Constitution, The Promotion System, Interact with Social Media)

View Set

Expansionary and Contractionary Policy

View Set

Greenberg Text: Chapters 16, 5, 6, 7, 8, 9, & 10 (FINAL) Good Luck FAM :) lets go !!! <3

View Set

Updated Microsoft MTA 98-361 Exam Questions V9.02 | Killtest

View Set

General Electrical Requirements, Definitions, Services, and Branch Circuits and Feeder Requirements

View Set