Java 2 Final Exam Preview

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 Viet Ho
Viet Ho, Software development
Viet, a versatile software developer, proficient in the development stack, excels in front-end with Svelte, TypeScript, and JavaScript. He's skilled in CSS, CSS libraries, Spring framework, Java, Golang, and MySQL. He thrives in Agile teamwork.
Quizzes Created: 2 | Total Attempts: 434
| Attempts: 136 | Questions: 40
Please wait...
Question 1 / 40
0 %
0/100
Score 0/100
1. Like ________, a recursive method must have some way to control the number of times it repeats.

Explanation

A recursive method, like a loop, must have some way to control the number of times it repeats. In both cases, there needs to be a condition or base case that determines when the repetition should stop. Without this control, the recursive method or loop would continue indefinitely, resulting in an infinite loop or recursion. Therefore, a loop is a suitable comparison to explain the need for a control mechanism in a recursive method.

Submit
Please wait...
About This Quiz
Java 2 Final Exam Preview - Quiz


Made by Viet Ho at
Saint Paul College, Fall 2017

2. HTML describes the content and layout of a Web page, and creates links to other files and Web pages, but does not have sophisticated abilities such as performing math calculations and interacting with the user.

Explanation

HTML is a markup language used to structure the content and layout of a web page. It is responsible for creating links to other files and web pages. However, HTML does not have advanced capabilities like performing mathematical calculations or interacting with the user. Therefore, the statement that HTML does not have sophisticated abilities is true.

Submit
3. In a transaction, all updates to database must be successfully executed.

Explanation

In a transaction, all updates to the database must be successfully executed in order to maintain data integrity and consistency. This means that if any part of the transaction fails, all changes made within that transaction must be rolled back to ensure that the database remains in a valid state. Therefore, the statement "all updates to the database must be successfully executed" is true.

Submit
4. The browser creates an instance of the applet class automatically.

Explanation

When a web page containing an applet is loaded, the browser automatically creates an instance of the applet class. This means that the applet class is instantiated without any explicit code or action from the programmer. This automatic creation allows the applet to start running and be displayed within the web page. Therefore, the statement "The browser creates an instance of the applet class automatically" is true.

Submit
5. Which of the following will load the applet, TestApplet?

Explanation

The correct answer is . This is the correct syntax for loading an applet in HTML. The "code" attribute specifies the name of the applet class file, and the "width" and "height" attributes determine the dimensions of the applet display area. The other options provided ("load" tag and incorrect attribute names) do not follow the correct syntax for loading an applet.

Submit
6. The data that is stored in a table is organized in:

Explanation

The data stored in a table is organized in rows. In a database table, each row represents a single record or instance of data. Each row consists of multiple columns, which define the different attributes or properties of the data. Rows are used to store individual data entries and are organized in a tabular format, making it easy to retrieve and manipulate specific data based on various criteria. Folders, pages, and files are not typically used to organize data in a table.

Submit
7. Applet restrictions are:

Explanation

Applet restrictions are necessary to prevent malicious code from attacking or spying on unsuspecting users. These restrictions are put in place to ensure the security of the user's system and data. They are determined by the web browser and are enabled only if the applet is running on a web server. In Java 7, these restrictions are optional, but it is still highly recommended to have them in place to protect the user's privacy and security.

Submit
8. In an entity relationship diagram, the primary keys are denoted with:

Explanation

In an entity relationship diagram, the primary keys are denoted with (PK). This notation is commonly used to indicate the attribute or set of attributes that uniquely identify each entity in a database table. The use of (PK) helps to distinguish the primary key from other attributes and provides clarity in the diagram.

Submit
9. Recursive algorithms are usually less efficient than:

Explanation

Recursive algorithms are usually less efficient than iterative algorithms because recursive algorithms involve repeated function calls and memory allocation, which can lead to a higher overhead. In contrast, iterative algorithms use loops to repeatedly execute a set of instructions, eliminating the need for function calls and reducing memory usage. This makes iterative algorithms more efficient in terms of time and space complexity compared to recursive algorithms. Quantum algorithms and pseudocode algorithms are not directly related to the efficiency comparison between recursive and iterative algorithms, so they are not the correct answer.

Submit
10. This term is used for methods that directly call themselves.

Explanation

Direct recursion is the term used for methods that directly call themselves. In this type of recursion, a function calls itself within its own code. This allows the function to repeat its execution until a certain condition is met, making it a powerful tool for solving problems that can be broken down into smaller, similar subproblems. By calling itself, the function creates a recursive loop that continues until the base case is reached, at which point the recursion stops.

Submit
11. Look at the following method: public static int Test2(int x, int y){    if (x < y)    {        return -5;    }    else    {        return (Test2(x - y, y + 5,) + 6);    }}What is the base case for the method?

Explanation

The base case for the method is x

Submit
12. What Java class is a Swing component that displays data in a two‑dimensional table?

Explanation

JTable is the correct answer because it is a Java class that is specifically designed to display data in a two-dimensional table format. It is a part of the Swing component library and provides various features for customizing the appearance and behavior of the table. JTable allows users to view and manipulate tabular data efficiently, making it a suitable choice for displaying data in a table format in Java applications.

Submit
13. An applet does not have to be on a Web server in order to be executed.

Explanation

An applet is a small program that is designed to be executed within a web browser. While it is common for applets to be hosted on a web server and accessed through a web page, it is not a requirement. Applets can also be executed locally on a user's computer without the need for a web server. Therefore, the statement that an applet does not have to be on a web server in order to be executed is true.

Submit
14. The DBMS works directly with the data and sends the results of operations:

Explanation

The correct answer is "Back to the application" because the DBMS (Database Management System) is responsible for managing and manipulating data within a database. After performing operations on the data, such as queries or updates, the DBMS sends the results back to the application that requested the operation. This allows the application to process and display the data to the user or perform further actions based on the results.

Submit
15. The number of times that a method calls itself is known as the:

Explanation

The correct answer is "Depth of recursion" because the depth of recursion refers to the number of times a method calls itself. It represents how many levels of nested recursive calls are made within the method. The depth increases with each recursive call, as the method continues to call itself until a base case is reached.

Submit
16. Appending the azribute ;create=true to the database URL:

Explanation

By appending the attribute ";create=true" to the database URL, it indicates that a new database should be created. This means that a completely new and separate database will be created, which can be used to store and manage data. The other options, such as creating a new table, row, or column, are specific to an existing database and are not applicable in this context.

Submit
17. Which Statement interface method should be used to execute an INSERT statement?

Explanation

The correct answer is "executeUpdate" because this method is specifically designed to execute INSERT statements in the Statement interface. It is used to execute SQL statements that do not return any result, such as INSERT, UPDATE, or DELETE statements. This method returns an integer value indicating the number of rows affected by the statement, which is useful for checking the success of the INSERT operation.

Submit
18. In an HTML document, the tags:

Explanation

The tags in an HTML document have various functions. They can be used to format the text, place images in the document, and define actions when the user clicks on a link. Therefore, the correct answer is "All of these" as all of these functions can be achieved using HTML tags.

Submit
19. In SQL, this statement is used to change the contents of an existing row in a table:

Explanation

The UPDATE statement in SQL is used to modify the contents of an existing row in a table. It allows you to change the values of one or more columns in a specific row based on certain conditions, such as using a WHERE clause to specify which row(s) to update. This statement is commonly used in database management systems to update records and keep the data up to date.

Submit
20. The term "commit" refers to undoing changes to a database.

Explanation

The term "commit" actually refers to saving or finalizing changes to a database, not undoing them. When changes are made to a database, they are typically held in a temporary state until the user explicitly commits them, at which point they become permanent and cannot be easily undone. Therefore, the correct answer is False.

Submit
21. Look at the following pseudo code algorithm:algorithm Test14(int x)     if (x < 8)         return (2 * x)     else         return (3 * Test14(x - 8) + 8) end Test14 What is the base case for the algorithm?

Explanation

The base case for the algorithm is when x is less than 8. In this case, the algorithm returns 2 * x.

Submit
22. By default, ResultSet objects allows you to move the cursor:

Explanation

The correct answer is "Forward only" because ResultSet objects in Java allow you to move the cursor only in a forward direction. This means that you can iterate through the ResultSet in a sequential manner from the first row to the last row, but you cannot move the cursor backward or jump to a specific row directly. This behavior is the default setting for ResultSet objects unless you explicitly specify a different type of scrolling behavior.

Submit
23. Which of one the following SQL data types would be the best choice for storing financial data?

Explanation

The DOUBLE data type would be the best choice for storing financial data because it allows for the storage of decimal numbers with a high degree of precision. Financial data often involves calculations with decimal values, such as currency amounts or interest rates, and the DOUBLE data type can accurately represent and perform calculations with these values. INT, REAL, and VARCHAR are not ideal choices for financial data as they may not provide the necessary precision or data range required for accurate calculations and storage.

Submit
24. A column in one table that references a primary key in another table is known as what?

Explanation

A column in one table that references a primary key in another table is known as a foreign key. This is because it establishes a relationship between the two tables, where the foreign key in one table refers to the primary key in another table. The foreign key ensures referential integrity, meaning that it enforces the consistency and validity of data between the related tables.

Submit
25. A qualified column name takes the following form:

Explanation

A qualified column name refers to a specific column in a database table. It consists of the table name followed by a dot and the column name. This format helps to uniquely identify the column within the database and avoid any ambiguity. In the given options, the answer "TableName.ColumnName" correctly represents a qualified column name.

Submit
26. How many times will the following method call itself if the value 10 is passed as an argument?public static void message(int n){    if (n > 0)    {        System.out.println("Print this line.\n");        message(n + 1);    }} 

Explanation

The given method is a recursive method that calls itself as long as the value passed as an argument is greater than 0. Since the method calls itself with an incremented value of n each time, and there is no condition to stop the recursion, it will continue to call itself indefinitely, resulting in an infinite number of method calls.

Submit
27. What SQL operator can be used to disqualify search criteria in a WHERE clause?

Explanation

The SQL operator "NOT" can be used to disqualify search criteria in a WHERE clause. It allows for the exclusion of certain conditions or values from the search results. By using "NOT" before a condition, it negates the condition and returns the opposite result. This operator is useful when you want to exclude specific records that meet certain criteria from your query results.

Submit
28. Like a loop, a recursive method must have:

Explanation

A recursive method must have some way to control the number of times it repeats itself because without a control mechanism, the method would continue to call itself indefinitely, leading to infinite recursion. This control mechanism could be a condition or a base case that determines when the recursion should stop. By having a control mechanism, the recursive method can ensure that it terminates after a certain number of repetitions, preventing infinite recursion and allowing the program to execute correctly.

Submit
29. Look at the following pseudocode algorithm: Algorithm gcd(x, y)    if (x < y)        gcd(y, x)    else        if (y = 0)            return x        else            return gcd(y, x mod y)end gcdWhat is the base case for the algorithm gcd?

Explanation

The base case for the algorithm gcd is when y is equal to 0. This is because when y is 0, it means that x is the greatest common divisor (gcd) of x and y. In this case, the algorithm can terminate and return the value of x as the gcd.

Submit
30. What SQL operator can be used to perform a search for a substring?

Explanation

The LIKE operator in SQL is used to perform pattern matching searches within a string. It allows for searching for a specific substring or pattern within a larger string. This operator is commonly used in conjunction with the '%' wildcard character to represent any number of characters. Therefore, the LIKE operator is the correct choice for performing a search for a substring in SQL.

Submit
31. Which of the following is not a restriction placed on applets?

Explanation

Applets are small applications that run within a web browser. They are designed to be restricted in certain ways to ensure security. The given answer states that applets cannot display a window, which is true. Applets are not allowed to create their own windows or pop-up windows on the user's system. This restriction is in place to prevent applets from interrupting or interfering with the user's browsing experience or potentially displaying malicious content.

Submit
32. If you try to store duplicate data in a primary key column:

Explanation

If you try to store duplicate data in a primary key column, an error will occur. This is because a primary key is a unique identifier for each record in a table, and it must be unique. If duplicate data is attempted to be stored in the primary key column, it violates the uniqueness constraint and the database management system will throw an error to prevent the duplication.

Submit
33. An applet using a Swing GUI extends which class?

Explanation

An applet using a Swing GUI extends the JApplet class. The JApplet class is a part of the Swing framework in Java and is specifically designed for creating applets with a graphical user interface. The JApplet class provides additional functionality and features compared to the standard Applet class, making it more suitable for creating applets with a Swing GUI. The JSwing and JFrame classes are not correct choices as they are not specifically designed for creating applets.

Submit
34. When the applet viewer opens an HTML document with more than one applet tag:

Explanation

When the applet viewer opens an HTML document with more than one applet tag, it displays each applet in a separate window. This means that each applet will be opened in its own individual window, allowing the user to interact with each applet separately.

Submit
35. What term refers to data that describes other data?

Explanation

Meta data refers to data that describes other data. It provides information about the characteristics and properties of the data, such as its structure, format, and meaning. Meta data helps in understanding and managing the data, making it easier to organize, search, and analyze. It can include information like data types, field names, data sources, data relationships, and data definitions. By providing context and understanding to the data, meta data enhances its usability and ensures its accuracy and consistency.

Submit
36. Which of the following is not a valid AWT class?

Explanation

The AWT (Abstract Window Toolkit) is a set of classes and methods in Java used for creating graphical user interfaces (GUIs). The classes in AWT are used to create various GUI components. Panel, Applet, and TextArea are all valid AWT classes used for creating different GUI components. However, JMenu is not a valid AWT class. JMenu is actually a class in the Swing package, which is an extension of AWT and provides more advanced GUI components. Therefore, JMenu is not a valid AWT class.

Submit
37. Which Statement interface method should be used to execute a SELECT statement?

Explanation

The correct method to execute a SELECT statement in the Statement interface is executeQuery. This method is specifically designed to execute SQL queries and retrieve the result set generated by the query. It returns a ResultSet object that contains the data retrieved from the database. The other options mentioned, executeSQL, executeStatement, and executeUpdate, are not valid methods in the Statement interface and do not serve the purpose of executing a SELECT statement.

Submit
38. Look at the following pseudocode algorithm:algorithm Test14(int x)    if (x < 8)        return (2 * x)    else        return (3 * Test14(x - 8) + 8)end Test14What is the recursive case for the algorithm?

Explanation

The recursive case for the algorithm is x >= 8. This means that when the input value x is greater than or equal to 8, the algorithm will recursively call itself with the new input value x - 8. This recursive call will continue until the base case is reached, which is when x is less than 8.

Submit
39. What is the default concurrency level of a ResultSet object?

Explanation

The default concurrency level of a ResultSet object is "Read-only". This means that by default, a ResultSet object is not updatable and cannot be modified. It is used to retrieve data from a database and allows only read operations on the data. Other options such as "Public", "Updatable", and "Private" do not accurately describe the default concurrency level of a ResultSet object.

Submit
40. Which of the following shows how a single quote is represented as part of a string in SQL?

Explanation

In SQL, a single quote is represented as part of a string by using two consecutive single quotes. This is known as escaping the single quote character. So, the correct representation of a single quote as part of a string in SQL is ' '.

Submit
View My Results

Quiz Review Timeline (Updated): Apr 5, 2024 +

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

  • Current Version
  • Apr 05, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 13, 2017
    Quiz Created by
    Viet Ho
Cancel
  • All
    All (40)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Like ________, a recursive method must have some way to control the...
HTML describes the content and layout of a Web page, and creates...
In a transaction, all updates to database must be successfully...
The browser creates an instance of the applet class automatically.
Which of the following will load the applet, TestApplet?
The data that is stored in a table is organized in:
Applet restrictions are:
In an entity relationship diagram, the primary keys are denoted with:
Recursive algorithms are usually less efficient than:
This term is used for methods that directly call themselves.
Look at the following method: public static int Test2(int x, int...
What Java class is a Swing component that displays data in a...
An applet does not have to be on a Web server in order to be executed.
The DBMS works directly with the data and sends the results of...
The number of times that a method calls itself is known as the:
Appending the azribute ;create=true to the database URL:
Which Statement interface method should be used to execute an INSERT...
In an HTML document, the tags:
In SQL, this statement is used to change the contents of an existing...
The term "commit" refers to undoing changes to a database.
Look at the following pseudo code algorithm:algorithm Test14(int...
By default, ResultSet objects allows you to move the cursor:
Which of one the following SQL data types would be the best choice for...
A column in one table that references a primary key in another table...
A qualified column name takes the following form:
How many times will the following method call itself if the value 10...
What SQL operator can be used to disqualify search criteria in a WHERE...
Like a loop, a recursive method must have:
Look at the following pseudocode algorithm: Algorithm gcd(x,...
What SQL operator can be used to perform a search for a substring?
Which of the following is not a restriction placed on applets?
If you try to store duplicate data in a primary key column:
An applet using a Swing GUI extends which class?
When the applet viewer opens an HTML document with more than one...
What term refers to data that describes other data?
Which of the following is not a valid AWT class?
Which Statement interface method should be used to execute a SELECT...
Look at the following pseudocode algorithm:algorithm Test14(int...
What is the default concurrency level of a ResultSet object?
Which of the following shows how a single quote is represented as part...
Alert!

Advertisement