Java and JSP Programming Fundamentals
Test your knowledge of Java programming, JSP, Servlets, and web development concepts including collections, exceptions, and session management.
Questions
Which of the following methods is not defined in Set interface java collection framework?
- IsEmpty()
- Clear()
- Contains
- Iterator()
- indexOf()
Which of the following methods of the Set interface returns the number of elements in the java collection framework?
- Size()
- Contains()
- Add()
- Iterator()
- Remove()
What does invalidate() method of session in JSP (Java Server Pages) do?
- This method is used to unbind any object associated with the current session.
- This method is used to remove the object, binds with the specified name.
- This method is used to bind an object to the session with the specified name.
- This method is used to create a new session.
- None of the above
Which of the following exceptions is shown by the method remove (int index) in the List interface in java collection framework?
- UnsupportedOperationException
- IndexOutOfBoundsException
- NullPointerException
- All of the above
- Only (1) and (2)
Which of the following methods are defined in Cookie class?
- getDomain()
- getMaxAge()
- getName()
- getComment()
- none of the above
Which of the following statement(s) is/are true?
- Static variables can not be serialized.
- Static variables can be serialized.
- Declaring a variable as volatile means that the variable will be shared in multithreaded environment.
- All of the above
- Only (1) and (3)
Which of the following is called ''NoSuchFieldException' in java?
- This exception is thrown when a program tries to reference, on a class or object, a field that does not exist.
- This exception is thrown when a program tries to reference, on a class or object, a method that does not exist.
- This exception is thrown when a program attempts to access a field or method which is not accessible from the location where the reference is made.
- This exception is thrown when an invalid value is passed to a string-to-number conversion method.
- None of the above
Which of the following is not a method of HttpServletResponse Object in JSP (Java Server Pages)?
- String encodeURL(String url)
- void setLocale(Locale loc)
- addCookie(Cookie cookie)
- void reset()
- boolean isSecure()
Which of the following methods of the ServletContext interface returns a url of the resource of the specific mapped path?
- getResource
- getResourcePaths
- getContext
- both (1) and (2)
- none of the above
Which of the following methods is used to read form data from the client in JSP?
- getParameter()
- getParameterNames()
- getInputStream()
- all of the above
- none of the above
Which of the following method(s) does the out object contain in JSP?
- print()
- println()
- flush()
- all of the above.
- only (2) and (3)
Which of the following statements is true about transient variable in java?
- We can not serialize the transient variables.
- Transient variables can be used in multithreading environment.
- Transient variables can not be static or final.
- All of the above
- Only (1) and (2)
Which of the following is not a HTTP response header?
- Content-Type
- Content-Length
- Content-Language
- Content-Location
- Redirect
What does flushBuffer() method of HttpServletResponse object in JSP (Java Server Pages)?
- This method is used to force any content in the buffer to be written to the client.
- This method is used to clear any data that exists in the buffer as well as the status code and headers.
- This method is used to set the preferred buffer size for the body of the response.
- This method is used to set the character encoding (MIME charset) of the response being sent to the client.
- None of the above
Which of the following is true about ServletContext interface in servlet?
- This interface defines a set of methods that a servlet uses to communicate with its servlet container.
- There is only one servlet context object in the entire web application.
- There is one servlet context per servlet in the web application.
- All of the above
- Only (1) and (2)
Which of the following implicit objects belong to ServletContext interface in JSP (Java Server Pages)?
- Request
- Response
- Out
- Application
- None of the above
Which of the following is the right syntax of the setAttribute() method of the session object in JSP?
- setAttribute(String name)
- setAttribute(Object value)
- setAttribute(String name, Object value)
- setAttribute(String name, String value)
- none of the above
Which of the following is/are the action elements in jsp?
- include
- setProperty
- body
- all of the above
- only (1) and (2)
Which of the following is not the value of scope attribute in jsp?
- Page
- Request
- Session
- Response
- Application
Which of the following is not a server side language?
- Java
- Java Script
- PHP
- Perl
- None of the above
Which of the following is not a reserved keyword in java?
- short
- static
- super
- void
- thread
Which of the following is/are the true statement(s) in java?
- Static methods can call other static methods.
- We can not use super keyword in case of static methods.
- We can not override the static method.
- All of the above
- Only (1) and (3)
Which of the following is not a true statement?
- A java bean has no argument constructor.
- A java bean implements the serializable interface.
- setProperty() method is used for the write-only attribute in java bean.
- A java bean is like a java class.
- None of the above
Which of the following is not true about method overriding in java?
- In method overriding, the super class and the subclass have a same method name with the same parameters type.
- In method overriding, the superclass and subclass have the same return type.
- Overriding is a form of runtime polymorphism in java.
- We can override the static methods in java.
- All of the above
Which of the following methods of the Object class are declared as final in java?
- getClass()
- notify()
- wait()
- all of the above
- only (1) and (2) are true
Which of the following is not a method of Object class in java?
- clone()
- finalize()
- getClass()
- valueOf()
- none of the above
Which of the following is a method of Throwable class in java?
- printStackTrace()
- String toString()
- getClause()
- String getMessage()
- All of the above
Which of the following is a checked exception in java?
- ClassCastException
- ArrayIndexboundOfException
- IllegalStateException
- IndexOutOfBoundsException
- None of the above
Which of the following methods of the Throwable class returns null, if there is no underlying exception found?
- getClause()
- getMessage()
- getLocalizedMessage()
- both (1) and (2)
- none of the above
Which of the following methods of the Throwable class returns the description of the exception in java?
- getClause()
- getMessage()
- printStackTrace()
- String toString()
- None of the above