Previous Quiz Questions 9-11

¡Supera tus tareas y exámenes ahora con Quizwiz!

True or False - To initialize a project in Git, the command "git init" is implemented. a. True b. False

a. True

True or False: All POM files require the project element and three mandatory fields: groupId, artifactId, and version. a. True b. False

a. True

True or False: Git is an example of a version control system. a. True b. False

a. True

True or False: In the Spring Framework, the CrudRepository interface defines CRUD methods like save(), findAll(), findById(),deleteById(). a. True b. False

a. True

True or False: The compiler does not check for ArrayIndexOutOfBoundsException, i.e. - it is an unchecked, runtime exception. a. True b. False

a. True

True or False: The servletconfig object refers to the single servlet whereas servletcontext object refers to the whole web application. a. True b. False

a. True

True or False: The web container calls the destroy method when it needs to remove the servlet such as stopping the server or undeploying the project. a. True b. False

a. True

True or False: When parameters are passed by value, the variable is not affected regardless of the change made to the parameter inside the method. a. True b. False

a. True

What is the correct date format accepted in SQL? a. YYYY-MM-DD b. YYYY-DD-MM c. MM-DD-YYYY d. DD-MM-YYYY

a. YYYY-MM-DD

A loop can be exited by using what keyword? a. break b. switch c. continue d. new

a. break

A driver is a concrete ____ that implements the java.sql.Driver interface. a. class b. interface c. method d. servlet

a. class

If I have the following array int[] numbers = {2.2, 5.1, 7.3, 8.5}, how do I grab number 7.3? Select one: a. Numbers[] b. Numbers[2] c. Numbers[1] d. Numbers[7.3]

b. Numbers[2]

Which is the correct way to find the upper bound of int[ ] num = new int[7] ? a. num.size b. num.sizeOf() c. num.length d. num.lengthOf()

c. num.length

What output will be produced by the following code? int[] anArray = new int[3]; { for(int i = 0; i < anArray.length; i++) { anArray[i] = 2 * i; } for (int i = 0; i < anArray.length; i++) { System.out.print(anArray[i] + " "); } } a. 024 b. 123 c. 248 d. 012

a. 024

How many times will the following code print "Welcome to Java"? int count = 0; do { System.out.println("Welcome to Java"); } while (count++ < 10); a. 11 b. 0 c. 8 d. 10 e. 9

a. 11

Which of the following is an advantage of using an array list over an array in Java? a. Array lists can be added to b. Array lists can hold a range of data types c. Array lists are passed by value d. Array lists' processing time is shorter

a. Array lists can be added to

The switch statement works with which of the following primitive data types: a. Byte Short Int Char b. Byte Short Int Char Float Double c. Byte Short Int d. Byte Short Int Long Char

a. Byte Short Int Char

What are the different ways to close a connection using JDBC? a. Close the connection object with the statement "conn.close()" b. Put statements in a try-block and it will automatically close after execution c. Both A and B d. None of the above

a. Close the connection object with the statement "conn.close()"

What does the following do in MySQL?DROP DATABASE testDB; a. Drops all tables in the "testDB" database and deletes it. b. Prompts you to rename the database "testDB". c. Duplicates the records in the database "testDB". d. Inserts a database below your current selection called "testDB".

a. Drops all tables in the "testDB" database and deletes it.

If you need to send a password (or any sensitive piece of data), never use which method? a. GET method b. MAIN method c. POST method d. SET method

a. GET method

What is one difference between git and github? a. GitHub is for hosting projects on the web and git is locally installed b. GitHub is a software whereas Git is a service. c. GitHub is open-source and strictly a command-line interface d. Github is a service whereas git is hosting repositories

a. GitHub is for hosting projects on the web and git is locally installed

What is a PreparedStatement? a. It is used to create and execute a parameterized query in the Java program. b. It represents SQL Blob value in Java program. c. It represents SQL Clob value in Java program d. It is used to execute SQL stored procedures.

a. It is used to create and execute a parameterized query in the Java program.

What does JDBC stand for? a. Java Database Connectivity b. Java Data Basic Connection c. Join Database Connect d. Java Data Connection

a. Java Database Connectivity

Which of the following stack type implementations maintains its nodes so that they contain a pointer to their immediate successor: a. Linked List Stack implementation b. Dynamic Stack implementation c. Array Stack Implementation d. Array List Stack Implementation

a. Linked List Stack implementation

Which one of these components is NOT the three primary components to make Java applications run on multiple machines? a. Multi threading b. Servlets c. JSP d. JDBC

a. Multi threading

Members of a class specified as .................... are accessible only to methods of that class. a. Private b. Protected c. Final d. Public e. Static

a. Private

Choose the correct answer for selecting different values from the customer's table: ______ _______ Country FROM Customers; a. Select, Distinct b. Delete, All c. Update, File d. Pick, Different

a. Select, Distinct

TRUE OR FALSE: localStorage is a property that allows JavaScript sites and apps to save key/value pairs in a web browser with no expiration date. a. True b. False

a. True

The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets. a. True b. False

a. True

True or False - Once you have navigated to the correct folder, you can create an empty repository in that folder with the command "git init". a. True b. False

a. True

Which of the following statements is true of public String getServletInfo()? a. returns information about servlet such as writer, copyright, version etc b. is invoked only once and indicates that servlet is being destroyed. c. returns the object of ServletConfig. d. initializes the servlet. It is the life cycle method of servlet and invoked by the web container only once.

a. returns information about servlet such as writer, copyright, version etc

Which method must you use to store a key and value to a web browser? a. setItem() b. removeItem( c. getItem d. key()

a. setItem()

Suppose x = 1, y = -1, and z = 1. What is the printout of the following statement? if (x > 0) if (y > 0) System.out.println("x > 0 and y > 0"); else if (z > 0) System.out.println("x < 0 and z > 0"); a. x < 0 and z > 0 b. x > 0 and y > 0 c. x < 0 and z < 0 d. No printout

a. x < 0 and z > 0

What is the correct URL mapping that is required in the HelloServlet class to map to the above JSP page.<h1>Hello JSP and Servlet!</h1><form action="helloServlet" method="post">Enter your name: <input type="text" name="yourName" size="20"></form>@WebServlet("XXXX")public class HelloServlet extends HttpServlet {....} a. "/HelloServlet" b. "/helloServlet" c. "/HttpServlet" d. "/yourName"

b. "/helloServlet"

What is the correct order of the Servlet life cycle? a. 1.-Servlet class is loaded 2.-Servlet instance is created. 3.-Call the Service Method 4.-Call the init method 5.- Call the destroy method. b. 1.-Servlet class is loaded. 2.-Servlet instance is created. 3.-Call the init method. 4.-Call the service method. 5.- Call the destroy method. c. 1.-Servlet instance is created 2.-Servlet class is loaded. 3.-Call the init method 4.-Call the service method 5.- Call the destroy method. d. None of the above

b. 1.-Servlet class is loaded. 2.-Servlet instance is created. 3.-Call the init method. 4.-Call the service method. 5.- Call the destroy method.

What is the value of sum after the following loop terminates? int sum = 0; int item = 0; do { item++; sum += item; if (sum >= 4) continue; } while (item < 5); a. 17 b. 15 c. 18 d. 16

b. 15

Which of the following is true? a. A finally block is executed before the catch block but after the try block. b. A finally block is executed whether an exception is thrown or not. c. A finally block is executed, only after the catch block is executed. d. A finally block is executed, only if an exception occurs. e. None of the above.

b. A finally block is executed whether an exception is thrown or not.

The DAO (Data Access Object) works with the _______ layer in the MVC Architecture. a. Model b. Controller c. View

b. Controller

What does this java code do: Connection connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword); a. Call the super class to drop the tables DDBB b. Create an object with the JDBC connection parameters c. Establish connection with the internet d. All of the above

b. Create an object with the JDBC connection parameters

True or False - Since an enum is a special "class", you cannot have an enum inside a class. a. True b. False

b. False

True or False: Checked exceptions are a subclass of Runtime Exception. They are mostly caused by programmers writing incorrect code. a. True b. False

b. False

True or False: JSP stands for Java Server Pages and these pages are considered as Processing logic. a. True b. False

b. False

True or False: The persistence.xml file is used to configure dependencies for the Maven project. a. True b. False

b. False

What does DriverManager do in java? a. It is used to manage Connection Pool b. It provides basic service to manage a set of JDBC Drivers c. It is used to access the result row-by-row d. It creates a connection (session) with a specific Database

b. It provides basic service to manage a set of JDBC Drivers

SELECT _______ FROM Products; Use an SQL function to select the record with the highest value of the Price column a. LARGE(PRICE) b. MAX(PRICE) c. MIN(price) d. None of the above

b. MAX(PRICE)

An interface is similar to an abstract class, because it has no fields and all abstract _________. a. Classes b. Methods c. Constructors d. Fields

b. Methods

Which two exceptions should be thrown in this doGet method? public void doGet(HttpServletRequest request, HttpServletResponse response) throws _______, ________ { PrintWriter out = response.getWriter(); out.println("Hello World!"); } a. ArithmeticException, InputMismatchException b. ServletException, IOException c. NullPointerException, SQLException d. ServletException, NullPointerException

b. ServletException, IOException

The ________________ method terminates a Java program. a. System.exit(null); b. System.exit(0); c. System.terminate(null); d. System.terminate(0);

b. System.exit(0);

Analyze the following code and determine the result upon compiling and running the application: class Main { public static void main(String[] args) { int x = 5; int y = 0; try { int result = x / y; System.out.println("Result = " + result); } catch (Exception ex) { System.out.println("There was a general exception."); } catch (ArithmeticException ex) { System.out.println("Bad arithmetic! Cannot divide by 0!"); }}} a. The terminal will output both "There was a general exception." AND "Bad arithmetic! Cannot divide by 0!" b. The terminal will output "There was a general exception." c. The terminal will output "Bad arithmetic! Cannot divide by 0!" d. The terminal will output a StackTrace message with a significant description of the error.

b. The terminal will output "There was a general exception."

Which of these statements is not part of the servlet life cycle? a. init method is invoked b. clone method is invoked c. service method is invoked d. destroy method is invoked

b. clone method is invoked

To create a new branch named "test" in Git run the command _____. a. git checkout test b. git checkout -b test c. git branch -b test d. git branch test

b. git checkout -b test

To use an interface in Java, use the keyword ______. a. extends b. implements c. public d. static

b. implements

A "Shape" superclass you are working with has a variable that needs to be accessed directly by a subclass. This variable must also remain inaccessible to unrelated classes. Which keyword would allow this variable to only be accessed from "Shape" and its subclasses? a. public b. protected c. private d. extends

b. protected

Which method type does NOT require a return. a. double b. void c. String d. int

b. void

A Servlet is a Java _______ running on the server, which interprets requests made by the client and generates a response. a. JDK b. IDE c. API d. IDK

c. API

___________________ provides a user interface to collect data from the user and submit the data to a servlet for processing. a. flat files b. Story c. HTML Forms d. JavaScript

c. HTML Forms

Which SQL statement is used to insert new data in a database? a. ADD RECORD b. INSERT NEW c. INSERT INTO d. ADD NEW

c. INSERT INTO

A good example of Abstract Data Structure is: a. Try-Catch b. Loop c. Linked List d. All of the above e. None of the above

c. Linked List

In Java a throwable class is? a. A disposable class b. Not hierarchical c. Parent class of Exceptions and Errors d. Child class of Exception

c. Parent class of Exceptions and Errors

Which is NOT a Model-View-Controller Layer? a. The Controller Layer b. The Model Layer c. The Web Layer d. The View Layer

c. The Web Layer

What is byte code in the context of Java? a. The type of code generated by a Java Virtual Machine. b. It is another name for a Java source file. c. The type of code generated by a Java compiler. d. It is the code written within the instance methods of a class. e. It is another name for comments written within a program.

c. The type of code generated by a Java compiler.

Which normal form removes more subtle dependencies called "transient dependencies" ? a. First Normal Form b. Second Normal Form c. Third Normal Form d. Fourth Normal Form

c. Third Normal Form

There are various types of drivers in JDBC. How do you determine which driver is to be used? a. Pick the driver you are the most comfortable with. b. You do not need to pick a driver, it is automatically matched by your operating system. c. Use the driver in accordance with the database you are interacting with. d. None of the above

c. Use the driver in accordance with the database you are interacting with.

What is the missing command to complete this statement: mysql> INSERT INTO store ________(-> 1, "1234 Delaware Avenue", "Ashley"); a. DESCRIBE b. SELECT c. VALUES d. UPDATE

c. VALUES

A web browser sends an HTTP request to a a. database b. other source c. controller d. Model

c. controller

Which of the following statements are true about ServletContext? a. The ServletContext object provides configuration information that is passed between all the servlets in the application. b. The servletContext is shared memory segment for a web application c. The ServletContext object can be accessed via getServletContext() method. d. All of the above

d. All of the above

What is the term for a special java method that is used to initialize objects. a. Builder b. Contractor c. Assembler d. Constructor

d. Constructor

Servlets are used to do what ? a. handle the request obtained from the webserver b. send a response back to the webserver c. process the request and produce the response d. all of the above

d. all of the above

A web browser sends an HTTP request to a ________? a. database b. other source c. model d. controller

d. controller

In the class ListQueue, which method calls the list method remove? a. pop() b. peek() c. enqueue() d. dequeue()

d. dequeue()

Suppose you are creating a java servlet to handle the user form request below: <h1>User Form</h1> <form action="formServlet" method="post"> Name: <input type="text" name="name" size="20"> <input type="submit" value="Call Servlet" /> </form> Which method(s) can be used to process the HTTP request for this form? a. doGet b. doPut c. getServletInfo d. doPost e. A and D

d. doPost

In the command prompt, what is the correct syntax to push changes on a document from Git to the main branch on GitHub? a. git push -u origin test b. git commit -m "added new task" c. git push -u main origin d. git push -u origin main

d. git push -u origin main

All are considered to be Access modifiers in Java except? a. Default b. Public c. Protected d. Private e. Abstract

e. Abstract

Class diagrams are used for a. Describing the static view of the system. b. Showing the collaboration among the elements of the static view. c. Describing the functionalities performed by the system. d. Construction of software applications using object oriented languages. e. All of the above.

e. All of the above.


Conjuntos de estudio relacionados

Peds Exam 2 - Elsevier Practice Questions

View Set

Semi Unit 1 Sports and Entertainment Marketing

View Set