Method Scope QuizS2C Home « Method Scope 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.Quiz2
8 questions
Lesson 4 - Method ScopeIn this lesson we look at Java method scope and what scope and its definition mean.This quiz.
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 3

The quiz below tests your knowledge of the material learnt in Beginning Java - Lesson 4 - Method Scope.

Question 1 : What are variables created within method scope known as?
- Variables created within method scope known are known as local variables.
Question 2 : Parameters passed to a method are within method scope?
- Parameters passed to a method are included as part of the method scope.
Question 3 : What is wrong with the following snippet of code?

public static void main (String[] args) {
float aFloat = 12.34F;
double aDouble;
double bDouble = aFloat * aDouble; }
- Variable aDouble is not initialized (variable bDouble is dynamically initialized at runtime).
Question 4 : What is the lifetime of a local variable?
- A local variable exists until the method it is declared in finishes executing.
Question 5 : local variables declared within an inner scope are available to the outer scope?
- Outer scopes know nothing about local variables declared within an inner scope.
Question 6 : How do we create a block of code?
- We create a block of code using curly braces
Question 7 : Is the following snippet of code valid?

public static void main (String[] args) {
int a = 0;
while (a < 2) { int a = 0; a++; } }
- Variables declared in an inner scope cannot have the same name as variables declared in an outer scope.
Question 8 : Each time a scope is entered the local variables that are declared with an initializer are reset to the initializer value.?
- local variables that are declared with an initializer are reset to the initializer value each time the scope is entered .
Quiz Progress Bar Please select an answer

What's Next?

The next quiz on Java is all about Operators.