Primitive Variables QuizS2C Home « Primitive Variables Quiz

The questions in this Java quiz are on the topics covered in the Java - Beginning Java section of the site. The table below lists the lesson used for each quiz, a description of the lesson content and the quiz number and questions associated with that lesson.

Beginning Java Quizzes Summary

Click on a lesson in the table to go to that lesson for a refresher on the topics for that quiz.

Click on a quiz in the table to go straight to the quiz for a particular lesson.

Beginning Java Lessons Description Quiz Info.
Lesson 2 - Code Structure & SyntaxFor this lesson we look at the code structure of a Java source file and look at some syntax.Quiz1
8 questions
Lesson 3 - Primitive VariablesThis lesson is about the primitive variable data types available in Java.This quiz.
8 questions
Lesson 4 - Method ScopeIn this lesson we look at Java method scope and what scope and its definition mean.Quiz3
8 questions
Lesson 5 - OperatorsThis lesson is the first of two about the symbols used in Java for mathematical and logical manipulation.Quiz4
6 questions
Lesson 6 - Bitwise OperatorsIn our second lesson on operators we look at the Java bitwise operators.Quiz5
6 questions
Lesson 7 - Conditional StatementsIn this lesson we look at the conditional statements available in Java.Quiz6
8 questions
Lesson 8 - Loop StatementsThis lesson is all about the loop statements available in Java.Quiz7
8 questions

Beginning Java Quiz 2

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

Question 1 : Which is a valid declaration of a char type?
- A char type must be initialized as a numeric or a single character enclosed in single quotes.
Question 2 : An int can fit into a short?
- Integer types can fit into larger integer types but not smaller. So an int will not fit into a short.
Question 3 : Pick out the valid identifier?
- Identifiers can only start with a letter, the $ symbol or the _ symbol.
Question 4 : What are the two floating point primitive types?
- The two floating point primitive types are double and float.
Question 5 : Will the following code compile?

short s 65; byte b= 65; int i = s + b;
- Variable i is dynamically initialized at runtime from s and b so is fine.
Question 6 : What other integer types can a short fit into?
- A short can fit into an int and a long
Question 7 : What happens when we compile the following statement?

float f = 16.54;
- Doesn't compile as the compiler thinks we are passing a double to a float.
Question 8 : We can use numerics in any position of an identifier?
- You can't start an identifer with a numeric.
Quiz Progress Bar Please select an answer

What's Next?

The next quiz on Java is all about method scope.