Java Variables QuizJ8 Home « Java Variables Quiz

Fundamentals Quiz 2

The quiz below tests your knowledge of the material learnt in Fundamentals - Lesson 3 - Java Variables.

Question 1 : Whenever you declare a variable in Java, you have to give it a type?
- Java is a strongly typed language and as such cares about the type of the variables we declare, so the type must be declared.
Question 2 : You cannot use numbers in an identifier name?
- You can use numbers after the first character of an identifier name, you just can't start with it.
Question 3 : Pick out the valid identifier?
- Identifiers can only start with a letter, the $ symbol or the _ symbol.
Question 4 : Which of the following Java literals are octal types?
- <code>05</code> and <code>012</code> are octal type Java literals.
Question 5 : Pick out the valid identifier?
- The only valid identifer is <code>eventually</code> as all the other answers are keywords which can't be used as identifiers.
Question 6 : Which character is used to escape a character?
- The \ (backslash) character is used to escape a character, e.g. \' Escape a single quote
Question 7 : Which of the following Java literals are hexadecimal types?
- <code>0xF</code> and <code>0xFA</code> are hexadecimal type Java literals.
Quiz Progress Bar Please select an answer


What's Next?

The next quiz on Java is about the boolean & char primitive data types.