Fundamentals Final (Ch 1-7)

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: 205 | Questions: 60
Please wait...
Question 1 / 60
0 %
0/100
Score 0/100
1. Match the correct data type with its definition
Submit
Please wait...
About This Quiz
Programming Fundamentals Quizzes & Trivia

This quiz titled 'Fundamentals Final (ch 1-7)' assesses foundational knowledge in programming, focusing on data types, operators, objects, methods, and method parameters. It is designed to test the... see moreunderstanding of core programming concepts, essential for learners in computer science. see less

2. Match the following value operator with its definition.
Submit
3. Match the following
Submit
4. Match the following
Submit
5. Match the following
Submit
6. Computers do not understand source code that we type in so it needs to be translated into machine code by a compiler before being executed.

Explanation

Computers operate using machine code, a low-level language that consists of binary instructions. However, humans typically write programs in high-level languages such as C++, Java, or Python. To bridge this gap, a compiler is used to translate the source code written by humans into machine code that the computer can understand and execute. Therefore, the statement that computers do not understand source code and require a compiler to translate it into machine code is true.

Submit
7. Objects will inherit methods from its superclasses.

Explanation

This statement is true because in object-oriented programming, inheritance allows objects to inherit methods and attributes from their parent or superclass. This means that an object can access and use the methods defined in its superclass without having to redefine them. Inheritance promotes code reuse and allows for creating hierarchies of classes, where subclasses inherit the behavior of their superclasses. Therefore, objects do inherit methods from their superclasses.

Submit
8. This is how you write an if-else statement that will display JCCC 45% of the time, else it will display Cavaliers. if (Greenfoot.getRandomNumber(100) < 45)     System.out.println("JCCC"); else     System.out.println("Cavaliers");

Explanation

The given code uses the Greenfoot.getRandomNumber(100) method to generate a random number between 0 and 99. If the generated number is less than 45, it will display "JCCC", otherwise it will display "Cavaliers". Since the condition is checking if the generated number is less than 45, which means it has a 45% chance of being true, the statement "JCCC" will be displayed approximately 45% of the time. Therefore, the correct answer is true.

Submit
9. Variable Declarations need a data type and a variable name

Explanation

Variable declarations in programming languages require both a data type and a variable name. The data type specifies the type of data that the variable can hold, such as integer, float, or string. The variable name is used to identify and refer to the variable in the code. Without a data type, the programming language would not know how to allocate memory for the variable, and without a variable name, the programmer would not be able to access or manipulate the variable. Therefore, both a data type and a variable name are necessary for variable declarations.

Submit
10. This statement  can be added to the IF statement to specify what should happen if the condition is false:

Explanation

The correct answer is "else" because in programming, the "else" statement is used in conjunction with the "if" statement to specify an alternative action to be taken if the condition in the "if" statement evaluates to false. It allows the program to execute a different set of instructions when the condition is not met.

Submit
11. Anything stored in an instance variable will be remembered as long as the object exists and can be accessed later.

Explanation

Instance variables are associated with objects and are stored in memory as long as the object exists. They can be accessed and used by the object's methods and can retain their values even after the method execution is completed. Therefore, anything stored in an instance variable will be remembered and accessible as long as the object exists.

Submit
12. Objects are created from

Explanation

Objects are created from classes. In object-oriented programming, a class is a blueprint or template that defines the properties and behaviors of an object. It is like a blueprint for creating objects. When we create an object, we are essentially creating an instance of a class, which allows us to access and use the properties and behaviors defined within the class. Therefore, classes are used to create objects.

Submit
13. The command that allows you to make a decision based on true or false conditions is a(n):

Explanation

The correct answer is "if statement". An if statement is a programming command that allows the program to make a decision based on true or false conditions. It is used to execute a block of code only if a certain condition is true. This helps in controlling the flow of the program and making it more dynamic and responsive to different scenarios.

Submit
14. Comments are ignored by the computer but necessary for documentation for the user and they are started with:

Explanation

not-available-via-ai

Submit
15. Putting this symbol in front of something means NOT:

Explanation

The exclamation mark (!) is used to indicate "NOT" in programming languages and logical expressions. It is commonly used to negate a condition or reverse the truth value of a statement. In this context, putting the exclamation mark in front of something means that the opposite or negation of that something is true.

Submit
16. When we need to repeat code or do a similar task repeatedly, we need a:

Explanation

When we need to repeat code or do a similar task repeatedly, we need a loop. A loop is a programming construct that allows us to execute a block of code multiple times. It helps in automating repetitive tasks and saves us from writing the same code multiple times. By using loops, we can iterate over a collection of data, perform calculations, or execute a set of instructions until a certain condition is met. Overall, loops provide a way to efficiently and effectively repeat code and perform repetitive tasks in programming.

Submit
17. A special expression that means "nothing" or "no object" is:

Explanation

The correct answer is "null." In programming, "null" is a special expression that represents the absence of a value or the lack of an object. It is often used to indicate that a variable or reference does not currently point to any valid data.

Submit
18. Java is very case dependent, so Body and body represent two different things.

Explanation

Java is a case-sensitive programming language, meaning that the capitalization of letters matters. In this case, "Body" and "body" are considered as two distinct things in Java. Therefore, the statement is true because Java treats "Body" and "body" as different identifiers.

Submit
19. The mechanism that is used to pass additional information to a method is called a:

Explanation

A parameter is a mechanism used to pass additional information to a method. It allows the method to accept values or variables that can be used within the method's code block. By providing parameters, we can make the method more flexible and reusable as it can work with different values each time it is called. Therefore, the correct answer is "parameter".

Submit
20. Methods with void return types represent

Explanation

Methods with void return types represent commands because they are used to perform a specific action or operation without returning any value. These methods are typically used to modify the state of an object or perform some side effect, such as printing output or updating a database. The absence of a return type indicates that the method's primary purpose is to carry out a task rather than compute or retrieve a value.

Submit
21. These symbols mean AND, which will join two conditions:

Explanation

The symbols "&&" represent the logical operator "AND" in programming. It is used to join two conditions and evaluates to true only if both conditions are true. In other words, it checks if both conditions are satisfied simultaneously.

Submit
22.  A method with a void return type does not return a value.  

Explanation

A method with a void return type does not return a value. In programming, the return type of a method determines the type of value that the method can return. When a method has a void return type, it means that the method does not return any value. This is useful for methods that perform actions or have side effects but do not need to return a result.

Submit
23.
Actors are classes that are placed into the world

Explanation

Actors are classes that are placed into the world. This means that in a programming context, actors are objects or instances of a class that can be placed or instantiated within a virtual or physical environment. They can interact with other actors and the environment, and perform actions or behaviors defined by their class. This is a common concept in game development, where actors can represent characters, objects, or other entities within the game world.

Submit
24. Write a line of code to change the element at index 3 to 5 in the scores array.

Explanation

The correct answer is "scores[3] = 5;" because it correctly assigns the value of 5 to the element at index 3 in the scores array.

Submit
25. This specifies what type of data a method call with return:

Explanation

The correct answer is "return type". In programming, a method is a block of code that performs a specific task. When a method is called, it can return a value or perform an action. The return type specifies the type of data that the method will return after it has completed its execution. It could be a primitive type like int or double, or a non-primitive type like a class or an array. The return type is important as it helps the programmer understand what kind of data they can expect to receive from the method.

Submit
26. True of False. Java is not case-sensitive

Explanation

Java is case-sensitive, meaning that it distinguishes between uppercase and lowercase letters. This means that variables, method names, and other identifiers must be written with the correct capitalization in order for the code to compile and run correctly. For example, "myVariable" and "myvariable" would be considered as two different variables in Java. Therefore, the correct answer is False.

Submit
27. When you need to call a method from a different class you must specify the class name before the method name using:

Explanation

When calling a method from a different class, the class name must be specified before the method name using dot notation. Dot notation is a way to access members (methods or variables) of a class by using the class name followed by a dot (.) and then the member name. This allows the program to identify which class the method belongs to and execute the correct method. Parenthetical citation, curly braces, and spaces are not used for this purpose.

Submit
28. To pass additional data to a method we specify a

Explanation

To pass additional data to a method, we specify a parameter. A parameter is a variable that is used to receive and store the additional data that is passed into the method when it is called. By specifying a parameter, we can provide the necessary information for the method to perform its task effectively.

Submit
29. Objects have several ___________ that are blocks of code that perform specific tasks or actions.

Explanation

Methods are blocks of code that are used to perform specific tasks or actions. They are associated with objects and can be called upon to execute a particular set of instructions. Methods can have parameters, which are variables that are passed into the method to provide it with necessary information. In this context, methods are the correct answer because they are the code blocks responsible for performing specific tasks or actions within objects.

Submit
30. In object-oriented programming a class is

Explanation

In object-oriented programming, a class serves as a model or template that defines the properties and behaviors of objects. It specifies the attributes (data) and methods (functions) that an object of that class can have. Objects are instances of a class, meaning they are created based on the class definition. Therefore, the correct answer is "a model or template from which objects are created."

Submit
31. This type of data structure allows us to store many values of the same type and access them using an index, like this whiteKeys[2], which would access the third element:

Explanation

An array is a data structure that allows us to store multiple values of the same type and access them using an index. In this case, the example given is whiteKeys[2], which would access the third element in the array. Arrays are commonly used when we need to store and manipulate a collection of values in a systematic way.

Submit
32. This is how you create a Java multi-line comment to place the following into a comment.   /* Replace the image on the screen and then move it right 10 pixels */

Explanation

The given code snippet demonstrates the creation of a multi-line comment in Java. The comment starts with /* and ends with */. It is used to provide explanatory or descriptive information about the code. In this case, the comment states that the image on the screen should be replaced and then moved right by 10 pixels. Since this is a valid way to create a multi-line comment in Java, the correct answer is True.

Submit
33. A bit of memory that belongs to an object to store information is called a:

Explanation

An instance variable is a bit of memory that belongs to an object and is used to store information. It is different from a method call, which is a way to invoke a method or function in an object. The return type, on the other hand, refers to the type of value that a method or function returns. Therefore, the correct answer is instance variable.

Submit
34. Good Java coding practice dictates that we should declare all of our variables:

Explanation

In Java, it is considered good coding practice to declare all variables at the top of the class. This is known as variable declaration at the class level. By declaring variables at the top of the class, it becomes easier to locate and understand all the variables used in the class. It also helps in avoiding any confusion or errors that may arise from declaring variables in different parts of the class. Additionally, declaring variables at the top of the class allows for better organization and readability of the code.

Submit
35. Write a statement that will declare an integer instance variable called count and set its initial value to 0.

Explanation

The correct answer is "public int count = 0;" because it declares an integer instance variable called "count" and initializes its initial value to 0. This statement follows the correct syntax for declaring and initializing an integer instance variable in Java.

Submit
36. Practice with logical operators Given: int age1 = 21; int age2 = 14; int age3 = 15; int birth = 0; String name = "JCCC"; age1 < age2 && age2 < age3

Explanation

age1 (21) F && T
F

Submit
37. Methods that belong to the class itself are marked with the keyword:

Explanation

Static methods belong to the class itself rather than to any specific instance of the class. They can be accessed using the class name without creating an object of the class. The keyword "static" is used to mark these methods.

Submit
38. By convention, class names in Java should always start with a:

Explanation

Class names in Java should always start with a capital letter. This is a convention followed by Java programmers to make the code more readable and distinguish class names from variables and methods. Starting class names with a capital letter helps to easily identify and differentiate them from other elements in the code. It is a widely accepted practice in the Java community and adhering to this convention improves the overall code consistency and maintainability.

Submit
39. This default Greenfoot method is automatically created in each new class and is what is executed when you click on Act or Run in the window:

Explanation

The correct answer is "act()". This method is automatically created in each new class in Greenfoot and is executed when you click on Act or Run in the window. It is responsible for defining the actions that an object should perform during each frame of the simulation.

Submit
40. Simplify the following expressions to either true or false: Given: x is an integer variable holding the value 3 y is an integer variable holding the value -5 z is an integer variable holding the value -4   (x > z) || (y < z) && !(y < x)

Explanation

The expression is evaluating whether the statement "(x > z) || (y
The expression consists of three parts connected by logical operators.

1) (x > z) - This part checks if the value of x is greater than the value of z. In this case, x is 3 and z is -4, so this part evaluates to true.

2) (y
3) !(y
Finally, the expression is evaluated using the logical operators. The "&&" operator has higher precedence than the "||" operator, so the expression is evaluated as follows:

(y
(x > z) || false = true || false = true

Therefore, the overall expression evaluates to true.

Submit
41. By convention, method names in Java should always start with a:

Explanation

In Java, it is a convention to start method names with a small letter but use capital letters for the beginning of words with no spaces. This convention is known as camel casing. By following this convention, it improves code readability and consistency. Starting method names with a capital letter is not a convention in Java.

Submit
42. Write a method signature for a method named "randomMove". The method has no parameters, and it does not return a value.

Explanation

The correct answer is "public void randomMove()". This is the correct method signature for a method named "randomMove" that has no parameters and does not return a value. The "public" keyword indicates that the method can be accessed from other classes. The "void" keyword indicates that the method does not return any value.

Submit
43. Write one statement that declares a local variable named city and initializes it to Overland Park.

Explanation

The correct answer is "String city = "Overland Park";" because it declares a local variable named "city" and initializes it with the value "Overland Park". This statement follows the correct syntax for declaring and initializing a string variable in Java.

Submit
44. Which of the following is not a data type in Java?

Explanation

The data types in Java include int, double, boolean, and String. However, "constant" is not a data type in Java. Constants in Java are typically declared using the "final" keyword and can have data types such as int, double, boolean, or String, but constant itself is not a data type.

Submit
45. Mark the arrays that are declared correctly by good programming standard.

Explanation

The arrays "int[] scores;" and "float[] rates;" are declared correctly by good programming standard. In Java, it is recommended to declare arrays using the square brackets immediately after the data type. Therefore, "int[] scores;" and "float[] rates;" follow this convention and are considered to be declared correctly. On the other hand, "int scores [];" and "float rates [];" also work in Java, but they are not considered as good programming practice.

Submit
46. The specification of a method, which shows its return type, name and parameters is called its:

Explanation

The specification of a method, which includes its return type, name, and parameters, is called its signature. The signature acts as a unique identifier for the method and helps distinguish it from other methods in the program. It provides crucial information about the method's functionality and how it can be used.

Submit
47. Given the following variable declarations, evaluate the following Boolean expression: int a= 7; int b = 12; int c = 12; int d = 7; (a ==c ||a ==b)

Explanation

The given Boolean expression is evaluating whether either a is equal to c or a is equal to b. In this case, a is not equal to c (7 is not equal to 12) and a is not equal to b (7 is not equal to 12), so the expression evaluates to False.

Submit
48. Another name for an objects is an:

Explanation

Another name for an object is an instance. In object-oriented programming, an instance refers to a specific occurrence or realization of a class. A class is a blueprint or template that defines the properties and behaviors of an object, while an instance is a unique entity created from that class. Therefore, the term "instance" is synonymous with "object" in this context.

Submit
49. A constant is a named value that is used like a variable, but can only be  changed by other classes.

Explanation

A constant is a named value that is used like a variable, but unlike a variable, it cannot be changed once it is assigned a value. It remains constant throughout the program and cannot be modified by any other classes or methods. Therefore, the given statement is incorrect as it states that a constant can be changed by other classes, which is not true.

Submit
50. An instruction that tells an object to perform a specific task it has programming code to do is called a:

Explanation

A method call is an instruction that tells an object to perform a specific task using programming code. It is used to invoke a method, which is a block of code that performs a particular action. By calling a method, the object executes the code within that method and carries out the desired task. Therefore, a method call is the correct term for this type of instruction.

Submit
51. Mark the following identifiers that are valid names to use in Java.

Explanation

Can not start with a digit and cannot have a dot.

Submit
52. A compiler

Explanation

A compiler is a software tool that translates source code, which is written in a high-level programming language, into executable code, which can be run on a computer. It performs various tasks such as lexical analysis, syntax analysis, semantic analysis, and code generation. The output of a compiler is a compiled program that can be executed by the computer's processor. Therefore, the correct answer is "translates source code into executable code".

Submit
53. Which is the best declaration for  a variable that will hold monthly rainfall. It is initialized to 0?

Explanation

The best declaration for a variable that will hold monthly rainfall and is initialized to 0 is "float totalMonthlyRainfall = 0.0 ;". This is because rainfall is typically measured in decimal values, so using a float data type allows for more precise calculations. Additionally, initializing the variable to 0 ensures that it starts with a default value before any rainfall data is recorded.

Submit
54. An assignment statement enables us to store something into a variable.  The symbol that allows us to do that is:

Explanation

The symbol "=" is used in an assignment statement to store a value into a variable. It is used to assign a specific value to a variable, allowing us to store and manipulate data in a program.

Submit
55. 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 convention of using PascalCase for class names. This convention suggests that each word in the class name should start with a capital letter and there should be no underscores or spaces between the words. Using this naming convention improves code readability and consistency.

Submit
56. Suppose you are given a variable named temperature that holds a value. This is how you would write an if-else statement that will display Above Freezing if temperature is greater than 32, Freezing if temperature is equal to 32, else it will display At or Below Freezing. if (temperature > 32) System.out.println("Above Freezing"); else (temperature == 32) System.out.println("Freezing"); else System.out.println("At or Below Freezing");

Explanation

The given if-else statement is not written correctly. In an if-else statement, the condition in the "else" part should not have a condition. It should simply be "else". Therefore, the correct answer is false.

Submit
57. What the value of x is at the end:        int i=0;      int x=0;             while (i < 4)         {             x = x + i;             i++;         }

Explanation

The value of x at the end of the code is 3. This is because the while loop runs 4 times, with i starting at 0 and incrementing by 1 each time. Inside the loop, x is updated by adding the current value of i to it. So, on the first iteration, x becomes 0+0=0, on the second iteration x becomes 0+1=1, on the third iteration x becomes 1+2=3, and on the fourth iteration x becomes 3+3=6. However, since the condition i

Submit
58. An identifier can be named in Java using letters, digits, underscores and the $ sign.  They may not begin with an underscore.

Explanation

they cannot begin with a digit

Submit
59. Declare and create a new array of 5 elements for a scores array.  

Explanation

The correct answer is "int[] scores = new int[5];". This is the correct way to declare and create a new array of 5 elements for a scores array in Java. The "int[]" specifies that the variable "scores" is an array of integers, and "new int[5]" creates a new array with a size of 5 elements.

Submit
60. Given the code below, what are the local variables?
public class MathStudent extends Actor {     protected String firstName;     protected String lastName;         public MathStudent()     {         firstName = "";         lastName = "";     }       public void countToFive()     {         int i = 1;         int limit = 5;         while (i <= 5)         {           System.out.println(i);           i = i + 1;         }     } }

Explanation

The local variables in the given code are "limit" and "i". These variables are declared and initialized within the method "countToFive" and are used within the while loop to control the iteration and print the value of "i" until it reaches the limit of 5. The variables "firstName" and "lastName" are instance variables of the class and are not considered local variables in this context.

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
  • Apr 27, 2014
    Quiz Created by
    Tcarteronw
Cancel
  • All
    All (60)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Match the correct data type with its definition
Match the following value operator with its definition.
Match the following
Match the following
Match the following
Computers do not understand source code that we type in so it needs to...
Objects will inherit methods from its superclasses.
This is how you write an if-else statement that will display JCCC 45%...
Variable Declarations need a data type and a variable name
This statement  can be added to the IF statement to specify what...
Anything stored in an instance variable will be remembered as long as...
Objects are created from
The command that allows you to make a decision based on true or false...
Comments are ignored by the computer but necessary for documentation...
Putting this symbol in front of something means NOT:
When we need to repeat code or do a similar task repeatedly, we need...
A special expression that means "nothing" or "no object" is:
Java is very case dependent, so Body and body represent two different...
The mechanism that is used to pass additional information to a method...
Methods with void return types represent
These symbols mean AND, which will join two conditions:
 A method with a void return type does not return a...
Actors are classes that are placed into the world
Write a line of code to change the element at index 3 to 5 in the...
This specifies what type of data a method call with return:
True of False. Java is not case-sensitive
When you need to call a method from a different class you must specify...
To pass additional data to a method we specify a
Objects have several ___________ that are blocks of code that perform...
In object-oriented programming a class is
This type of data structure allows us to store many values of the same...
This is how you create a Java multi-line comment to place the...
A bit of memory that belongs to an object to store information is...
Good Java coding practice dictates that we should declare all of our...
Write a statement that will declare an integer instance variable...
Practice with logical operators...
Methods that belong to the class itself are marked with the keyword:
By convention, class names in Java should always start with a:
This default Greenfoot method is automatically created in each new...
Simplify the following expressions to either true or false: ...
By convention, method names in Java should always start with a:
Write a method signature for a method named "randomMove"....
Write one statement that declares a local variable named city and...
Which of the following is not a data type in Java?
Mark the arrays that are declared correctly by good programming...
The specification of a method, which shows its return type, name and...
Given the following variable declarations, evaluate the following...
Another name for an objects is an:
A constant is a named value that is used like a variable, but can only...
An instruction that tells an object to perform a specific task it has...
Mark the following identifiers that are valid names to use in Java.
A compiler
Which is the best declaration for  a variable that will hold...
An assignment statement enables us to store something into a variable....
The best example for the correct way to name a class is
Suppose you are given a variable named temperature that holds a value....
What the value of x is at the end:...
An identifier can be named in Java using letters, digits, underscores...
Declare and create a new array of 5 elements for a scores array....
Given the code below, what are the local variables?...
Alert!

Advertisement