Day 2 Flashcards
What does it mean to initialize a variable?
It means giving a value to that variable
Are constants variables or not?
How to define it?
• Yes. It’s a variable whose value can not be changed.
• “Final” keyword is used to define a constant.
What’s the preferred convention used to name a constant?
We use Snake case convention where all words are in upper case and between each word we put an underscore.
What’s an identifier in java?
It’s the naming. Generally any naming for classes, methods & variables. There are naming rules for identifiers.
What are the only special characters allowed for identifiers?
$ dollar sign
_ underscore
Which of these identifiers are correct according to rules?
1. Carrot6Piece
2. $diana
3. sad bitch
4. 2002best_year
1 & 2 are correct. Numbers are allowed within the identifier but not at the beginning
3 & 4 are wrong.
3. No spaces are allowed
4. Numbers are not allowed at the start of a name.
What’s the difference between the following?
“@”
‘7’
”@” is a String.
‘7’ is a character. Character is a type of data.
What type of data is True or False?
They are Booleans
What type of data is a class?
Calsses can be considered of “User Defined Type” in which a programmer create their own data type.