Java Programming Language Quiz Coding

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 Cvktech
C
Cvktech
Community Contributor
Quizzes Created: 10 | Total Attempts: 48,860
| Attempts: 1,408 | Questions: 20
Please wait...
Question 1 / 20
0 %
0/100
Score 0/100
1. Which of the following design patterns is used to separate the task of writing the GUI screens and business logic? Select 1 correct option.

Explanation

The Model View Controller (MVC) design pattern is used to separate the task of writing the GUI screens and business logic. In MVC, the model represents the data and business logic, the view represents the GUI screens, and the controller acts as an intermediary between the model and the view, handling user input and updating the model and view accordingly. This separation of concerns allows for easier maintenance and testing of the application.

Submit
Please wait...
About This Quiz
Java Programming Language Quiz Coding - Quiz

This Java programming language quiz assesses knowledge on various Java concepts including servlets, collections, HTTP protocol, and syntax. It is designed for learners to test their understanding of core Java programming components and error handling.

Personalize your quiz and earn a certificate with your name on it!
2. If i want to use the name of the person across multiple pages then we have to store that person name in ___

Explanation

To use the name of a person across multiple pages, it is necessary to store that person's name in the session. The session is a mechanism that allows the server to store information about a user's interactions with a website. By storing the person's name in the session, it can be accessed and used on different pages throughout the user's session. This ensures that the person's name remains available and consistent as they navigate through the website.

Submit
3. --Controller Servlet in struts

Explanation

The correct answer is ActionServlet. In the Struts framework, the Controller Servlet is responsible for receiving and handling all the incoming requests. It acts as a front controller, receiving requests from the client and dispatching them to the appropriate Action classes. The ActionServlet is the default controller servlet provided by the Struts framework. It initializes the framework, manages the request processing flow, and delegates the request handling to the appropriate Action classes.

Submit
4. Http protocol is a _____________

Explanation

The given question is asking about the nature of the HTTP protocol. The correct answer is "stateless." This means that the HTTP protocol does not retain any information or state between requests. Each request is treated as an independent transaction, and the server does not remember any previous requests or interactions with the client. This allows for a more scalable and efficient system, as the server does not need to store and manage session data for each client.

Submit
5. Using which class object we can call Stored Procedures inJDBC

Explanation

CallableStatement is the correct answer because it is a JDBC interface that provides methods to call stored procedures in a database. It allows the execution of SQL statements that may contain input and output parameters. CallableStatement extends the PreparedStatement interface and provides additional methods specifically for calling stored procedures. Therefore, using a CallableStatement object, we can easily call and execute stored procedures in JDBC.

Submit
6. Using which object we can reduce the network traffing in JDBC

Explanation

PreparedStatement can reduce network traffic in JDBC because it allows the database to compile and optimize the SQL statement only once, and then reuse the compiled statement with different parameter values. This reduces the amount of data that needs to be sent over the network for each execution of the statement, resulting in improved performance and reduced network traffic.

Submit
7. Identify the implicit objects available to EL expressions.

Explanation

The implicit objects available to EL expressions include requestScope, pageScope, header, and pageContext. These objects provide access to various information and functionalities within the application. The requestScope object allows access to attributes stored in the request scope, the pageScope object allows access to attributes stored in the page scope, the header object allows access to HTTP request headers, and the pageContext object provides access to the page context. Therefore, all of the above options are correct.

Submit
8. Which of the following is a Legacy class in collections

Explanation

Vector is considered a legacy class in collections because it was one of the original classes introduced in Java's early versions. It is part of the Java Collections Framework but has been largely replaced by the more modern ArrayList class. Vector is synchronized, which means it is thread-safe, but this can also lead to performance issues in multi-threaded environments. Therefore, it is generally recommended to use ArrayList instead of Vector in most cases.

Submit
9. Which of the following are correct as per MVC architecture

Explanation

In MVC architecture, the controller is responsible for handling user input and updating the model and view accordingly. Having multiple controllers in a web application can lead to confusion and inconsistency in handling user requests. Therefore, it is recommended to have only one controller in a web application to ensure proper coordination and organization of the application's functionality.

Submit
10. Your web application named "FWorks" uses SpecialMath.class. This is an unbundled class and is not contained in any jar file. Where will you keep this class file? Select 1 correct option.

Explanation

The correct answer is FWorks/WEB-INF/classes. This is because in a web application, the classes that are not contained in any jar file are typically stored in the WEB-INF/classes directory.

Submit
11. Which of the collection classes will follow the InsertionOrder

Explanation

All three collection classes mentioned (ArrayList, LinkedHashSet, and Vector) follow the InsertionOrder. This means that the elements in these collections are stored and retrieved in the order in which they were inserted. In ArrayList, elements are stored in an array and can be accessed using their index. In LinkedHashSet, elements are stored in a hash table with a linked list running through it, preserving the order of insertion. Vector is similar to ArrayList but is synchronized, making it thread-safe. Therefore, all three classes maintain the insertion order of elements.

Submit
12. Public class Wow {  public static void go(short n) {System.out.println("short");}  public static void go(Short n) {System.out.println("SHORT");}  public static void go(Long n) {System.out.println(" LONG");}  public static void main(String [] args) {  Short y = 6;  int z = 7;  go(y);  go(z);  }  } What is the result?

Explanation

The code will not compile because there is no matching method signature for the argument passed in the second call to the "go" method. The argument "z" is of type int, and there is no method that accepts an int as an argument. Therefore, the code will not compile.

Submit
13.  Which object is responsible for reading confiuguration file in hibernate

Explanation

The Configuration object is responsible for reading the configuration file in Hibernate. It is used to configure and bootstrap Hibernate, including reading the hibernate.cfg.xml file which contains the necessary configuration settings for the Hibernate framework. The Configuration object is used to create a SessionFactory, which in turn is used to create Session objects for interacting with the database.

Submit
14. Public class Hello { String title;  int value; public Hello() {  title += " World";  }  public Hello(int value) {  this.value = value;  title = "Hello";  Hello();  }  } and:  Hello c = new Hello(5); System.out.println(c.title); What is the result?

Explanation

The code will not compile because there is a syntax error in the constructor. The line "Hello();" is attempting to call the constructor within the constructor, which is not allowed.

Submit
15. Public class Yippee2 {  static public void main(String [] yahoo) {  for(int x = 1; x < yahoo.length; x++) {  System.out.print(yahoo[x] + " ");  } . }  } and the command line invocation: java Yippee2 a b c What is the result?

Explanation

The code starts iterating through the yahoo array from index 1 (since x is initialized to 1) and prints each element followed by a space. So, the output will be "b c" as it skips the first element "a" and starts printing from the second element "b" followed by "c".

Submit
16. Public class Test {  public static void main(String [] args) {  int x = 5; boolean b1 = true;  boolean b2 = false; f ((x == 4) && !b2 )  System.out.print("1 "); System.out.print("2 ");. if ((b2 = true) && b1 )  System.out.print("3 "); }  } What is the result?

Explanation

The result is "2 3" because the first if statement evaluates to false since the condition (x == 4) is false. Therefore, the code inside the if statement is not executed. The second if statement evaluates to true since the assignment b2 = true returns true, and b1 is true. Therefore, the code inside the second if statement is executed, resulting in the output "3 ". Finally, the "2 " is printed outside of any if statements, resulting in the final output "2 3".

Submit
17. Public static void parse(String str) {  try {  float f = Float.parseFloat(str);  } catch (NumberFormatException nfe) {  f = 0;  } finally {  System.out.println(f);  }  }  public static void main(String[] args) {  parse("invalid");  } What is the result?

Explanation

The code in the main method calls the parse method and passes the string "invalid" as an argument. In the parse method, there is a try-catch block that attempts to parse the string as a float using the Float.parseFloat method. If the parsing fails and a NumberFormatException is thrown, the catch block sets the value of f to 0. However, since the variable f is declared within the try block, it is not accessible outside of it. Therefore, when the code tries to print the value of f in the finally block, a compilation error occurs because f is not recognized. Hence, the correct answer is "Compilation fails."

Submit
18.  Regarding the processing of a BodyTag handler, in which of the following cases a BodyContent object will be "pushed" into the pageContext? Select 1 correct option.

Explanation

If the doStartTag() returns SKIP_BODY, a BodyContent object will be "pushed" into the pageContext.

Submit
19. What will be the output of the following JSP page?      <% a = 100; %>    <% int a = 200; %>    <%! int a = 300; %>    a = <%= a %>, <%= this.a %>  

Explanation

The output of the JSP page will be "a = 200, 100". This is because the first declaration of "a" assigns it the value of 100. The second declaration of "a" is a local variable within the tags and assigns it the value of 200. The third declaration of "a" is a global variable within the tags and assigns it the value of 300. The final line of code outputs the values of "a" using the tags, which will output the value of the local variable "a" (200) followed by the value of the global variable "a" (100).

Submit
20. <% int a = 10; %> <%! int a = 20; %> <%! int b = 30; %> The value of b multiplied by a is <%= b * a %>

Explanation

The given code snippet includes two scriptlet declarations, and . These scriptlet declarations are used to declare variables that can be accessed throughout the entire page. Therefore, the variable "a" is declared twice, once with a value of 10 and once with a value of 20. However, the variable "b" is only declared once with a value of 30. When the expression is evaluated, it will use the value of "b" (30) multiplied by the value of "a" (10), resulting in 300. Therefore, the correct answer is "The value of b multiplied by a is 300."

Submit
View My Results

Quiz Review Timeline (Updated): Jul 22, 2024 +

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

  • Current Version
  • Jul 22, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 25, 2011
    Quiz Created by
    Cvktech
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following design patterns is used to separate the task of...
If i want to use the name of the person across multiple pages then we...
--Controller Servlet in struts
Http protocol is a _____________
Using which class object we can call Stored Procedures inJDBC
Using which object we can reduce the network traffing in JDBC
Identify the implicit objects available to EL expressions.
Which of the following is a Legacy class in collections
Which of the following are correct as per MVC architecture
Your web application named "FWorks" uses SpecialMath.class....
Which of the collection classes will follow the InsertionOrder
Public class Wow {...
 Which object is responsible for reading confiuguration file in...
Public class Hello {...
Public class Yippee2 {...
Public class Test {...
Public static void parse(String str) {...
 Regarding the processing of a BodyTag handler, in which of the...
What will be the output of the following JSP page?...
<% int a = 10; %>...
Alert!

Advertisement