Greenfoot Ch 2 Quiz

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Tcarteronw
T
Tcarteronw
Community Contributor
Quizzes Created: 38 | Total Attempts: 29,972
Questions: 21 | Attempts: 845

SettingsSettingsSettings
Greenfoot Quizzes & Trivia

Survey of skills over ch 2 notes, projects and readings.


Questions and Answers
  • 1. 

    What are the { } symbols called?

    • A.

      Braces

    • B.

      Curly brackets

    • C.

      Statements

    • D.

      All answers are correct

    Correct Answer
    D. All answers are correct
    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.

    Rate this question:

  • 2. 

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

    • A.

      BankAccount

    • B.

      Bank account

    • C.

      BankAccount

    • D.

      Bank_Account

    Correct Answer
    C. BankAccount
    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.

    Rate this question:

  • 3. 

    Check all places that you can get information to create methods in Greenfoot

    • A.

      Greenfoot help menu

    • B.

      Java documentation

    • C.

      Greenfoot documentation

    • D.

      Greenfoot web site

    Correct Answer(s)
    A. Greenfoot help menu
    B. Java documentation
    C. Greenfoot documentation
    D. Greenfoot web site
    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.

    Rate this question:

  • 4. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    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.

    Rate this question:

  • 5. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    setLocation(int x, int y);

    Rate this question:

  • 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…)

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    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.

    Rate this question:

  • 7. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    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.

    Rate this question:

  • 8. 

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

    • A.

      To explain code you are writing

    • B.

      To check for errors

    • C.

      It makes your code prettier

    Correct Answer(s)
    A. To explain code you are writing
    B. To check for errors
    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.

    Rate this question:

  • 9. 

    /* */ These tags are for single line code comments

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    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.

    Rate this question:

  • 10. 

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

    • A.

      True

    • B.

      False

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

    Rate this question:

  • 11. 

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

    • A.

      Use the debugger and set breakpoints

    • B.

      Use "System.out.println" to output information you would like to check

    • C.

      Randomly guess and fix it by trial and error

    Correct Answer(s)
    A. Use the debugger and set breakpoints
    B. Use "System.out.println" to output information you would like to check
    Explanation
    random guessing is generally inefficient and time consuming.

    Rate this question:

  • 12. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    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.

    Rate this question:

  • 13. 

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

    • A.

      If (condition) { statement(s); }

    • B.

      If (condition) statement(s);

    Correct Answer
    A. If (condition) { statement(s); }
    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.

    Rate this question:

  • 14. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    It should never have a " ; " at the end of the condition. It stops the statements from executing.

    Rate this question:

  • 15. 

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

    • A.

      Public count = 0;

    • B.

      Public int count = 0;

    • C.

      Public void count = 0;

    • D.

      Public void count();

    Correct Answer
    B. Public int count = 0;
    Explanation
    Variables have a data type and name. You initialize the variable by setting it equal to a value.

    Rate this question:

  • 16. 

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

    Correct Answer
    extends
    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.

    Rate this question:

  • 17. 

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

    • A.

      Private

    • B.

      Boolean

    • C.

      AtWorldEdge()

    • D.

      Option 4

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

    Rate this question:

  • 18. 

    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.

    • A.

      Syntax

    • B.

      Logic

    • C.

      Run-time

    Correct Answer
    A. Syntax
    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.

    Rate this question:

  • 19. 

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

    • A.

      Syntax

    • B.

      Logic

    • C.

      Run-time

    Correct Answer
    B. Logic
    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.

    Rate this question:

Quiz Review Timeline +

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
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.