Greenfoot Ch 2 Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Tcarteronw
T
Tcarteronw
Community Contributor
Quizzes Created: 38 | Total Attempts: 32,005
| Attempts: 881 | Questions: 21
Please wait...
Question 1 / 21
0 %
0/100
Score 0/100
1. Match the following:
Submit
Please wait...
About This Quiz
Book Quizzes & Trivia

Greenfoot Quiz 2 assesses knowledge on basic programming concepts using Greenfoot, including syntax, class naming, and method usage. It evaluates understanding of Java-based environment setup, correct coding practices,... see moreand logical reasoning in programming. see less

2. Which is the best example of how to use braces when creating a conditional statement?

Explanation

You can use no braces when you only have one statement in a conditional. However, it is best practice to always use braces in a conditional statement. If you have multiple statements and no braces, only the first line of the statement will execute.

Submit
3. Match the following:
Submit
4. Check all places that you can get information to create methods in Greenfoot

Explanation

The Greenfoot help menu, Java documentation, Greenfoot documentation, and Greenfoot website are all sources of information where one can find guidance on creating methods in Greenfoot. These resources provide documentation, tutorials, and examples that can assist in understanding and implementing methods effectively within the Greenfoot environment.

Submit
5. What kind of error will keep your program from compiling? For example, you forget to put a ";" at the end of a variable that you declare.

Explanation

Syntax errors occur when the code violates the rules of the programming language. These errors prevent the program from being compiled because the compiler cannot understand the code due to the syntax violation. Forgetting to put a semicolon at the end of a variable declaration is an example of a syntax error. Other examples include misspelling keywords, using incorrect punctuation, or not closing brackets properly.

Submit
6. Suppose the method is not in the same class or inherited from another class In general, the format is:
  • ClassName.methodName(parameters…) OR
  • objectName.methodName(parameters…)

Explanation

If the method is not in the same class or inherited from another class, the format to call the method is either ClassName.methodName(parameters) or objectName.methodName(parameters). This means that if the method is not in the same class or inherited, we cannot call the method directly without specifying the class name or object name. Therefore, the answer "True" is correct.

Submit
7. To debug your code, the following methods are the best to use.

Explanation

random guessing is generally inefficient and time consuming.

Submit
8.
  1. Suppose the method to call is defined in the same class or inherited from another class
In general, the format is: methodName(parameters…)

Explanation

The given statement is true because when a method is defined in the same class or inherited from another class, it can be called using the format "methodName(parameters...)" within the same class or any subclass. This allows for the execution of the method and the utilization of its functionality.

Submit
9. The terminal window appears automatically when the first System.out.println statement is executed.

Explanation

When the first System.out.println statement is executed, it prints the output to the console. As a result, the terminal window, which is the console where the output is displayed, appears automatically. Therefore, the statement "The terminal window appears automatically when the first System.out.println statement is executed" is true.

Submit
10. SetLocation(100, 150); The parameters of 100 and 150 tell you that  the y coordinate is 100 and the x coordinate is 150.

Explanation

setLocation(int x, int y);

Submit
11.
  1. Why should you use Comments tags?   Two primary reasons

Explanation

Using comment tags in code serves two primary purposes. Firstly, it allows you to explain the code you are writing, making it easier for other developers (or even yourself in the future) to understand the purpose and functionality of the code. This can greatly enhance the maintainability and readability of the codebase. Secondly, comments can be used to check for errors by temporarily disabling or commenting out certain sections of code. This can be useful when troubleshooting or debugging, as it helps isolate potential issues and narrow down the source of errors.

Submit
12. How do we know which format to use when declaring a methodName? Check for the static keyword.

Explanation

When declaring a methodName, we can determine which format to use by checking for the static keyword. The static keyword is used to define a method that belongs to the class itself rather than an instance of the class. If the method is declared with the static keyword, it can be called directly on the class without creating an instance of the class. Therefore, checking for the static keyword can help us determine the format to use when declaring a methodName.

Submit
13. What is the return value of the following method: private boolean atWorldEdge()

Explanation

The return value of the method atWorldEdge() is a boolean. This means that the method will either return true or false.

Submit
14. /* */ These tags are for single line code comments

Explanation

The given statement is false because the tags mentioned are not for single line code comments. In HTML, single line code comments are denoted by . The given tags are not recognized as comments in HTML.

Submit
15. What word is used to show that an class inherits methods and properties from a super class.

Explanation

The word "extends" is used in object-oriented programming to indicate that a class is inheriting methods and properties from a super class. Inheritance allows a subclass to inherit and reuse the code from its parent class, promoting code reusability and reducing redundancy. By using the "extends" keyword, the subclass can access and utilize all the public and protected members of the super class, providing a way to create more specialized classes based on existing ones.

Submit
16. Comments that describe your code are often concise and begin with action words. Assume the reader of your code already understands the language.

Explanation

The given correct answer is "True". This means that the statement or question being referred to is true or correct.

Submit
17. Write a statement that will declare an integer instance variable called count and set its initial value to 0. (2 marks)

Explanation

Variables have a data type and name. You initialize the variable by setting it equal to a value.

Submit
18. This kind of error will allow your program to compile but will give you information that is wrong.

Explanation

This kind of error refers to a logical error in programming. It means that the program will compile without any syntax errors, but the resulting output or information provided by the program will be incorrect. This type of error occurs when there is a mistake in the program's algorithm or logic, causing it to produce incorrect results.

Submit
19. If (atWorldEdge()); This is the correct way to write the if conditional.

Explanation

It should never have a " ; " at the end of the condition. It stops the statements from executing.

Submit
20. The best example for the correct way to name a class is

Explanation

The correct way to name a class is "BankAccount" because it follows the standard naming conventions for class names in most programming languages. The convention is to use camel case, where the first letter of each word is capitalized and there are no spaces or underscores between words. This naming convention improves readability and makes the code easier to understand for other developers.

Submit
21. What are the { } symbols called?

Explanation

The { } symbols are called braces or curly brackets. They can be used to define a block of code in programming languages, indicate the scope of a function or loop, or create a set in mathematical notation. Therefore, all the given answers are correct as they all refer to the same symbols.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 19, 2012
    Quiz Created by
    Tcarteronw
Cancel
  • All
    All (21)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Match the following:
Which is the best example of how to use braces when creating a...
Match the following:
Check all places that you can get information to create methods in...
What kind of error will keep your program from compiling? ...
Suppose the method is not in the same class or inherited from another...
To debug your code, the following methods are the best to use.
Suppose the method to call is defined in the same class or inherited...
The terminal window appears automatically when the first...
SetLocation(100, 150);...
Why should you use Comments tags?   Two primary reasons
How do we know which format to use when declaring a methodName?...
What is the return value of the following method: ...
/* */ These tags are for single line code comments
What word is used to show that an class inherits methods and...
Comments that describe your code are often concise and begin with...
Write a statement that will declare an integer instance variable...
This kind of error will allow your program to compile but will give...
If (atWorldEdge());...
The best example for the correct way to name a class is
What are the { } symbols called?
Alert!

Advertisement