1.
JSP. What is wrong with this code?AccountingAllocation allocation = new AccountingAllocation("001"); it = allocatedFrom.iterator();while (it.hasNext()) { if (allocation == null) continue; System.out.println("Value = " + allocation.getValue()); }
Correct Answer
B. Endless loop because it.next() is missing.
Explanation
The code provided creates an instance of the AccountingAllocation class and assigns it to the "allocation" variable. Then, it initializes an iterator called "it" using the allocatedFrom collection. The while loop checks if the iterator has a next element, and if so, it prints the value of the "allocation" variable. However, the code does not call the "it.next()" method inside the loop, which means the iterator will always point to the same element, causing an endless loop.
2.
JSP. What is wrong with this statement on a JSP page?<%=session.getAttribute("NominalReportTitle");%>
Correct Answer
A. You need to delete the ; character
Explanation
The statement on the JSP page is incorrect because it includes a semicolon character (;) at the end. In JSP, the semicolon is not required at the end of an expression. Therefore, to fix the statement, the semicolon should be deleted.
3.
JSP. What is the key difference between using a < jsp:forward > and HttpServletResponse.sendRedirect()?
Correct Answer
A. Forward executes on the server while sendRedirect() executes on the client.
Explanation
The key difference between using a and HttpServletResponse.sendRedirect() is that the forward executes on the server while sendRedirect() executes on the client. This means that when using , the server handles the redirection internally without involving the client, while with sendRedirect(), the server sends a response to the client with a new URL, and the client then initiates a new request to that URL.
4.
JSP. When a JSP page is compiled, what is it turned into ?
Correct Answer
B. Servlet
Explanation
When a JSP page is compiled, it is turned into a Servlet. JSP (JavaServer Pages) is a technology that allows the creation of dynamic web pages. During the compilation process, the JSP page is translated into a Java Servlet, which is a server-side component that generates dynamic content. The Servlet is then executed by the web server to produce the desired output. Therefore, the correct answer is Servlet.
5.
JSP. What is wrong with the following code ? <%if(strPassword.equals("boss")){< jsp:forward page="Welcome.jsp" flush="true" / >}else{}%>
Correct Answer
D. Actions cannot be used within scriptlet blocks
Explanation
The given code is incorrect because actions, such as jsp:forward, cannot be used within scriptlet blocks. In this code, the jsp:forward action is being used within the scriptlet block, which is not allowed. Actions should be used outside of the scriptlet block.
6.
JSP. What is wrong with the following code ?<%Cookie c = new Cookie("UserName", "Alastair Gulland");response.addCookie(c);%>
Correct Answer
C. Although no error will be reported the use of the action means that the response object can't be used to create cookies.
Explanation
The use of the `` action in the code indicates that it is written in JSP scriptlet. However, the correct way to create cookies in JSP is by using the `` action. So, although no error will be reported, the use of the `` action means that the response object cannot be used to create cookies.
7.
JSP. The < jsp:include /> action can pass parameters to the page which it is including. How does this second page obtain thevalue of these parameters ?
Correct Answer
B. Using the < jsp:getParam /> action
Explanation
The second page obtains the value of the parameters passed by the action by using the action. This action retrieves the value of the specified parameter from the request object and makes it available for use in the second page. The action allows the second page to access and utilize the passed parameters effectively.
8.
JSP. What is the difference between doing an include or a forward with a RequestDispatcher ?
Correct Answer
D. He forward method transfers control to the designated resource, while the include method invokes the designated resource, substitutes its output dynamically in the display, and returns control to the calling page.
Explanation
The explanation provided correctly states that the forward method transfers control to the designated resource, while the include method invokes the designated resource, substitutes its output dynamically in the display, and returns control to the calling page. This means that when using the forward method, the control is completely transferred to the new resource, whereas when using the include method, the output of the new resource is included in the current display and the control is returned to the calling page.
9.
JSP. Choose the statement that best describes the relationship between JSP and servlets:
Correct Answer
D. JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage.
Explanation
JSPs (JavaServer Pages) are built on servlet semantics, meaning they are designed to be a higher-level abstraction of servlets. JSPs are compiled into servlets before they are executed, allowing them to take advantage of the powerful features provided by servlets. This relationship between JSP and servlets allows developers to write dynamic web pages using the simplicity and ease of JSP syntax, while still leveraging the functionality and flexibility of servlets. Therefore, the correct answer is that JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage.
10.
JSP. Which jar file should be mandatory be there in the CLASSPATH for working with Servlet.
Correct Answer
A. Javax.servlet.*
Explanation
The correct answer is javax.servlet.*. This is because the javax.servlet package contains the necessary classes and interfaces for working with servlets, such as HttpServletRequest and HttpServletResponse. By including javax.servlet.* in the CLASSPATH, the necessary dependencies will be available for the servlet to function properly.
11.
JSP. Which of the following statements is true regarding the scope of the ‘session’ in JSP?
Correct Answer
E. All above
Explanation
The given correct answer states that all the statements regarding the scope of the 'session' in JSP are true. According to the answer, objects with session scope can be accessed from pages processing requests in the same session, it is not legal to define an object with session scope from a non-session-aware page, all references to the object are released after the session ends, and references to objects with session scope are stored in the session object associated with the page activation. Therefore, all of the above statements are true regarding the scope of the 'session' in JSP.
12.
JSP. Which packages in the java provide the writing of the Servlet
Correct Answer
A. Javax
Explanation
The correct answer is javax because the javax package in Java provides classes and interfaces for writing servlets. Servlets are Java programs that run on a web server and handle client requests and server responses. The javax.servlet package, which is part of the javax package, contains the necessary classes and interfaces for creating and managing servlets. Therefore, javax is the correct answer as it specifically refers to the package that enables the writing of servlets in Java.
13.
Some Operating Systems have a limitation on the Max Length of the URL, which are normally _______ characters.
Correct Answer
A. 255
Explanation
Some operating systems have a limitation on the maximum length of a URL, which is typically 255 characters. This means that URLs longer than 255 characters may not be supported or may cause issues when trying to access a webpage or resource. It is important to be aware of this limitation when designing and working with URLs to ensure compatibility and proper functioning across different operating systems.
14.
JSP. Which of the following statement is true for the tag. (Multiple choice)
Correct Answer(s)
A. Can include dynamically generated output.
B. Provides benefit of automatic recompilation.
C. Can be used to incorporate contents from static documents
Explanation
The given correct answer is a combination of three statements that are true for the JSP tag. The first statement, "Can include dynamically generated output," means that JSP allows for the inclusion of dynamic content within the page. The second statement, "Provides benefit of automatic recompilation," implies that JSP pages are automatically recompiled when changes are made, saving time and effort. The third statement, "Can be used to incorporate contents from static documents," suggests that JSP can include static content from other documents, enhancing the flexibility of the page.
15.
JSP. Java Server Pages specification includes (Multiple choice)
Correct Answer(s)
A. JSP standard directives
B. JSP standard actions.
C. Script language declarations, scriplets and expressions.
D. A portable tag extension mechanism.
Explanation
The correct answer includes all the components of the JSP specification. JSP standard directives are used to define page settings and import classes, JSP standard actions are used to perform specific tasks, script language declarations, scriplets, and expressions are used to embed Java code in the JSP page, and a portable tag extension mechanism allows for the creation of custom tags.
16.
JSP. Which of the following correctly defines JSP technology
Correct Answer
A. JSP page is a text-based document that describes how to process a request to create a response.
Explanation
The correct answer is "JSP page is a text-based document that describes how to process a request to create a response." This answer accurately defines JSP technology by stating that a JSP page is a text-based document that provides instructions on how to process a request and generate a response. This aligns with the purpose of JSP, which is to dynamically generate web content by combining HTML, XML, and Java code.
17.
JSP. Which of the following statements is true about the scope of ‘application’ in JSP ?
Correct Answer(s)
A. Objects with application scope are accessible from pages processing requests that are in the same application as they one in which they were created.
B. All references to the object shall be released when the runtime environment reclaims the ServletContext.
C. Objects with application scope can be defined (and reached) from pages that are not session-aware
D. References to objects with application scope are stored in the application object associated with a page activation
18.
JSP. The wrapper function like <%! String blanknull(String s) { return (s == null) ? "" : s; } %> then use it inside your JSP form, like < input type="text" name="shoesize" value="<%=blanknull(shoesize)% >" > prevents the word _______ from apperaring in an HTML page.
Correct Answer(s)
null
Explanation
The wrapper function "blanknull" checks if the input string is null. If it is null, it returns an empty string, otherwise it returns the input string itself. By using this function in the JSP form, specifically in the value attribute of the input tag for the "shoesize" field, it ensures that if the "shoesize" variable is null, the value attribute will be set to an empty string. This prevents the word "null" from appearing in the HTML page.
19.
JSP. Which of the following points is true regarding the general and selling point of Servlet (Multiple choice)
Correct Answer(s)
A. A Servlet can handle multiple requests concurrently, and synchronize requests.
B. Servlet support systems such as online real-time conferencing.
C. Servlet can forward requests to other servers and Servlet.
D. Servlet can be used to balance load among several servers that mirror the same content, and to partition a single logical service over xseveral servers, according to task type or organizational boundaries.
Explanation
Servlets are Java-based server-side components that can handle multiple requests concurrently and synchronize requests. They also support systems such as online real-time conferencing. Additionally, servlets have the ability to forward requests to other servers and servlets. They can also be used to balance the load among several servers that mirror the same content and partition a single logical service over several servers based on task type or organizational boundaries.
20.
JSP. Calling of which of the following method causes unpredictable results in the Servlet.
Correct Answer
D. System.exit(0);
Explanation
Calling the method System.exit(0) causes unpredictable results in the Servlet. This method terminates the Java Virtual Machine (JVM) and shuts down the entire application, including the Servlet container. As a result, any ongoing processes or requests handled by the Servlet may be abruptly terminated, leading to unpredictable behavior. It is generally not recommended to use System.exit(0) in a Servlet as it can disrupt the normal functioning of the application.
21.
JSP. Request.getServerName () is used to get the name of the server on which the Jsp is running
Correct Answer
A. True
Explanation
The statement is true because the method Request.getServerName() is indeed used to retrieve the name of the server on which the JSP (JavaServer Pages) is currently running. This method returns a string that represents the host name of the server.
22.
JAVASCRIPT. Inside which HTML element do we put the JavaScript?
Correct Answer
C. < script >
Explanation
The correct answer is < script >. This is because JavaScript code is typically placed within < script > tags in an HTML document. These tags are used to define a section of JavaScript code that will be executed by the browser.
23.
JAVASCRIPT. What is the correct JavaScript syntax to write "Hello World"?
Correct Answer
B. document.write("Hello World")
Explanation
The correct JavaScript syntax to write "Hello World" is "document.write("Hello World")". This is because the document.write() function is used to write content directly to the HTML document.
24.
JAVASCRIPT. How do you call a function named "myFunction"?
Correct Answer
B. MyFunction()
Explanation
In JavaScript, to call a function named "myFunction", you use the syntax "myFunction()". The parentheses after the function name indicate that you are invoking or calling the function.
25.
JAVASCRIPT. How do you write a conditional statement for executing some statements only if "i" is equal to 5?
Correct Answer
C. if (i==5)
Explanation
The correct answer is "if (i==5)". In JavaScript, the conditional statement "if" is used to execute a block of code only if the specified condition is true. In this case, the condition is "i==5", which checks if the value of variable "i" is equal to 5. If the condition is true, the code inside the if statement will be executed.
26.
JAVASCRIPT. How do you write a conditional statement for executing some statements only if "i" is NOT equal to 5?
Correct Answer
B. If (i != 5)
Explanation
The correct answer is "if (i != 5)". This is the correct conditional statement to execute some statements only if "i" is NOT equal to 5. The "!=" operator is used to check if two values are not equal. In this case, it checks if the value of "i" is not equal to 5. If it is not equal, the statements inside the if block will be executed.
27.
JAVASCRIPT. What is the correct JavaScript syntax for opening a new window called "window5" ?
Correct Answer
B. window.open("http://www.ex-designz.net","window5")
Explanation
The correct JavaScript syntax for opening a new window called "window5" is "window.open("http://www.ex-designz.net","window5")". This syntax uses the "window.open()" method to open a new window with the specified URL and name.
28.
JAVASCRIPT. How do you find the client's browser name?
Correct Answer
B. navigator.appName
Explanation
The client's browser name can be found using the "navigator.appName" property in JavaScript. This property returns the name of the browser that the client is using. Therefore, "navigator.appName" is the correct answer to find the client's browser name.
29.
JAVASCRIPT. Which of the following JavaScript statements use arrays?
Correct Answer
A. setTimeout("a["+i+"]",1000)
Explanation
The correct answer is setTimeout("a["+i+"]",1000). This statement uses an array by accessing the element at index 'i' in the array 'a'. The setTimeout function allows for a delay of 1000 milliseconds before executing the code inside the quotation marks. In this case, the code is accessing an element in the array 'a' using the value of 'i' as the index.
30.
JAVASCRIPT. How do you get the value of this field< input name="account" id="accountField" value="0001" />
Correct Answer
A. Document.getElementById('accountField').value;
Explanation
The correct answer is "document.getElementById('accountField').value;" because it uses the getElementById method to select the element with the id "accountField" and then retrieves the value of that element.
31.
JAVASCRIPT. Which one is a correct javascript function declaration?
Correct Answer
A. Function testFunc(){}
Explanation
The correct javascript function declaration is "function testFunc(){}".br> This is the correct syntax for declaring a function in JavaScript. The keyword "function" is followed by the name of the function (testFunc in this case), and then a pair of parentheses and curly braces. Any code that needs to be executed when the function is called is placed inside the curly braces.
32.
LINUX. Which file does Linux use to resolve hostnames?
Correct Answer
C. /etc/host.conf
Explanation
Linux uses the /etc/host.conf file to resolve hostnames. This file contains configuration information for the resolver library, which is responsible for resolving domain names to IP addresses. The /etc/host.conf file specifies the order in which the resolver library should query different sources for hostname resolution, such as DNS servers or the local hosts file. By configuring this file, administrators can control how Linux resolves hostnames and customize the resolution process according to their needs.
33.
LINUX. What are the file attributes for executing Perl programs?
Correct Answer
B. 755
Explanation
The file attributes for executing Perl programs are 755. This means that the owner of the file has read, write, and execute permissions, while the group and others have only read and execute permissions. This allows the owner to execute the Perl program, while others can only read and execute it.
34.
LINUX. What is bash?
Correct Answer
D. A command shell
Explanation
Bash is a command shell in Linux. It is a program that provides a command-line interface for users to interact with the operating system. It allows users to execute commands, run scripts, and manage files and directories. Bash is one of the most commonly used command shells in Linux systems and is known for its powerful features and scripting capabilities.
35.
LINUX. From a command prompt, what does the command "ls" do?
Correct Answer
B. Lists the contents of the directory
Explanation
The command "ls" in Linux is used to list the contents of a directory. It displays the files and directories present in the current working directory. This command is commonly used to navigate and explore the file system in Linux.
36.
LINUX. Which command creates a file system?
Correct Answer
C. Mkfs
Explanation
The command "mkfs" is used in Linux to create a file system on a storage device or partition. It is commonly used to format a newly created partition or to reformat an existing one with a different file system type. This command initializes the file system metadata and structures, making the storage device ready for use. Therefore, "mkfs" is the correct command to create a file system in Linux.
37.
LINUX. What is the default administrator username?
Correct Answer
D. Root
Explanation
The default administrator username in Linux is "root". This is because "root" is the superuser account that has complete control over the system. It has the highest level of privileges and can perform any task on the system, including managing users, installing software, and modifying system files. Other options like "administrator", "admin", "superuser", and "head" are not the default administrator usernames in Linux.
38.
LINUX. Which of the following are valid Linux wildcards? (Choose the best answer)
Correct Answer
A. * and ?
Explanation
The valid Linux wildcards are * and ?. The * wildcard represents any number of characters, while the ? wildcard represents a single character. These wildcards are commonly used in Linux command line operations to match multiple files or directories based on specific patterns.
39.
LINUX. You are working in Linux when a program hits a flaw and stops running. Which command can be used to end the process?
Correct Answer
A. Kill
Explanation
The correct answer is "kill". In Linux, the "kill" command is used to terminate a process. When a program hits a flaw and stops running, using the "kill" command allows you to forcefully end the process. This command sends a signal to the specified process, instructing it to terminate. By using the "kill" command followed by the process ID, you can effectively stop a program that is not responding or causing issues.
40.
LINUX. A user is logged into the Linux workstation, what is the best way to login to root from a shell prompt?
Correct Answer
C. Su
Explanation
The best way to login to root from a shell prompt in Linux is by using the "su" command. This command stands for "switch user" and allows the user to switch to the root user account without logging out. By typing "su" followed by the root password, the user gains administrative privileges and can perform tasks that require root access.
41.
LINUX. The command "pwd" displays the directory
Correct Answer
A. True
Explanation
The command "pwd" stands for "print working directory" and when executed in a Linux system, it displays the current directory that the user is in. Therefore, the statement "The command 'pwd' displays the directory" is true.
42.
LINUX. To move files, use the "move" command.
Correct Answer
B. False
Explanation
The given statement is false because in Linux, the command used to move files is not "move" but "mv". The "mv" command is used to rename or move files and directories.
43.
LINUX. What will be the result of this command: a=a; b=m$a; echo $b;
Correct Answer
A. Ma
Explanation
The command "a=a" assigns the value "a" to the variable "a". The command "b=m$a" assigns the value of "a" to the variable "b" with the prefix "m". Finally, the command "echo $b" prints the value of "b", which is "ma".
44.
LINUX. How can you extract a zipped tar file?
Correct Answer
A. Tar xfzv file.tar.gz
Explanation
The correct answer is "tar xfzv file.tar.gz". This command extracts a zipped tar file by using the "tar" command with the options "x" (extract), "f" (file), "z" (gzip compression), and "v" (verbose mode). It specifies the file to be extracted as "file.tar.gz".