InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Does close() implicitly flush() the stream.(a) True(b) FalseThis question was posed to me during an interview.I need to ask this question from AutoCloseable, Closeable and Flushable Interfaces in portion Session Management, JSP & API of Java |
|
Answer» The correct ANSWER is (a) True |
|
| 2. |
Which version of java added Flushable interface?(a) java SE 7(b) java SE 8(c) java SE 6(d) java SE 5This question was posed to me at a job interview.Enquiry is from AutoCloseable, Closeable and Flushable Interfaces topic in portion Session Management, JSP & API of Java |
|
Answer» Right OPTION is (d) java SE 5 |
|
| 3. |
What is the use of Flushable interface?(a) Flushes this stream by writing any buffered output to the underlying stream(b) Flushes this stream and starts reading again(c) Flushes this connection and closes it(d) Flushes this stream and throws FlushExceptionI got this question during an online exam.I want to ask this question from AutoCloseable, Closeable and Flushable Interfaces topic in portion Session Management, JSP & API of Java |
|
Answer» CORRECT answer is (a) Flushes this stream by writing any BUFFERED output to the underlying stream The BEST EXPLANATION: Flushable interface provides flush() method which Flushes this stream by writing any buffered output to the underlying stream. |
|
| 4. |
What is the difference between AutoCloseable and Closeable?(a) Closeable is an interface and AutoCloseable is a concrete class(b) Closeable throws IOException; AutoCloseable throws Exception(c) Closeable is a concept; AutoCloseable is an implementation(d) Closeable throws Exception; AutoCloseable throws IOExceptionI had been asked this question in homework.The doubt is from AutoCloseable, Closeable and Flushable Interfaces in section Session Management, JSP & API of Java |
|
Answer» The CORRECT option is (b) Closeable throws IOEXCEPTION; AUTOCLOSEABLE throws Exception |
|
| 5. |
It is a good practise to not throw which exception in close() method of autocloseable?(a) IOException(b) CustomException(c) InterruptedException(d) CloseExceptionThis question was addressed to me during an online interview.My doubt stems from AutoCloseable, Closeable and Flushable Interfaces in portion Session Management, JSP & API of Java |
|
Answer» Correct OPTION is (c) InterruptedException |
|
| 6. |
Which of the below is a child interface of Autocloseable?(a) Closeable(b) Close(c) Auto(d) CloneableThe question was asked in my homework.The query is from AutoCloseable, Closeable and Flushable Interfaces in division Session Management, JSP & API of Java |
|
Answer» Right answer is (a) Closeable |
|
| 7. |
What is the alternative of using finally to close resource?(a) catch block(b) autocloseable interface to be implemented(c) try block(d) throw ExceptionI have been asked this question in my homework.I'd like to ask this question from AutoCloseable, Closeable and Flushable Interfaces topic in division Session Management, JSP & API of Java |
|
Answer» RIGHT option is (B) autocloseable interface to be implemented The best EXPLANATION: Autocloseable interface provides close() method to close this resource and any other UNDERLYING RESOURCES. |
|
| 8. |
What does Class.forName(“myreflection.Foo”).getInstance() return?(a) An array of Foo objects(b) class object of Foo(c) Calls the getInstance() method of Foo class(d) Foo objectThis question was posed to me in an online quiz.This key question is from Reflection API topic in division Session Management, JSP & API of Java |
|
Answer» CORRECT option is (d) Foo object To EXPLAIN: CLASS.forName(“myreflection.Foo”) returns the class object of Foo and getInstance() would return a NEW object. |
|
| 9. |
Autocloseable was introduced in which Java version?(a) java SE 7(b) java SE 8(c) java SE 6(d) java SE 4I had been asked this question in an online interview.The question is from AutoCloseable, Closeable and Flushable Interfaces topic in division Session Management, JSP & API of Java |
|
Answer» Right OPTION is (a) java SE 7 |
|
| 10. |
How to get the class object of associated class using Reflection?(a) Class.forName(“className”)(b) Class.name(“className”)(c) className.getClass()(d) className.getClassName()The question was asked in examination.The doubt is from Reflection API topic in chapter Session Management, JSP & API of Java |
|
Answer» RIGHT option is (a) Class.forName(“CLASSNAME”) The explanation is: forName(String className) returns the Class OBJECT associated with the class or INTERFACE with the given string name. |
|
| 11. |
How method can be invoked on unknown object?(a) obj.getClass().getDeclaredMethod()(b) obj.getClass().getDeclaredField()(c) obj.getClass().getMethod()(d) obj.getClass().getObject()This question was posed to me in exam.Query is from Reflection API topic in division Session Management, JSP & API of Java |
|
Answer» The correct answer is (C) obj.getClass().getMethod() |
|
| 12. |
How private field can be called using reflection?(a) getDeclaredFields(b) getDeclaredMethods(c) getMethods(d) getFieldsThis question was addressed to me by my school principal while I was bunking the class.I'd like to ask this question from Reflection API topic in portion Session Management, JSP & API of Java |
|
Answer» The CORRECT ANSWER is (a) GETDECLAREDFIELDS |
|
| 13. |
How private method can be called using reflection?(a) getDeclaredFields(b) getDeclaredMethods(c) getMethods(d) getFieldsThe question was posed to me during an interview.This key question is from Reflection API topic in chapter Session Management, JSP & API of Java |
|
Answer» Correct choice is (B) getDeclaredMethods |
|
| 14. |
What is used to get class name in reflection?(a) getClass().getName()(b) getClass().getFields()(c) getClass().getDeclaredFields()(d) new getClass()I got this question in an online interview.The question is from Reflection API topic in section Session Management, JSP & API of Java |
|
Answer» RIGHT answer is (a) GETCLASS().getName() EXPLANATION: getClass().getName() is USED to get a class name from object in REFLECTION. |
|
| 15. |
What is not the advantage of Reflection?(a) Examine a class’s field and method at runtime(b) Construct an object for a class at runtime(c) Examine a class’s field at compile time(d) Examine an object’s class at runtimeI got this question by my college director while I was bunking the class.My question is taken from Reflection API in division Session Management, JSP & API of Java |
|
Answer» RIGHT choice is (C) Examine a class’s field at compile time Explanation: Reflection inspects classes, INTERFACES, FIELDS and METHODS at a runtime. |
|
| 16. |
Which of the following is not a marker interface?(a) Serializable(b) Cloneable(c) Remote(d) ReaderThis question was posed to me in a job interview.Question is from Reflection API in portion Session Management, JSP & API of Java |
|
Answer» RIGHT choice is (d) Reader The best explanation: Reader is not a MARKER interface. Serializable, Cloneable and Remote INTERFACES are marker interface. |
|
| 17. |
What are the components of a marker interface?(a) Fields and methods(b) No fields, only methods(c) Fields, no methods(d) No fields, No methodsThis question was posed to me in semester exam.I'm obligated to ask this question of Reflection API topic in section Session Management, JSP & API of Java |
|
Answer» CORRECT answer is (d) No fields, No methods The EXPLANATION is: Marker interface in JAVA is an EMPTY interface in Java. |
|
| 18. |
Can and be used alternatively in JSP?(a) True(b) FalseThe question was asked in an online interview.My enquiry is from JSP Elements in chapter Session Management, JSP & API of Java |
|
Answer» Correct CHOICE is (b) False |
|
| 19. |
Java code is embedded under which tag in JSP?(a) Declaration(b) Scriptlet(c) Expression(d) CommentThis question was posed to me in semester exam.My doubt stems from JSP Elements in chapter Session Management, JSP & API of Java |
|
Answer» CORRECT ANSWER is (b) Scriptlet The explanation: Scriptlet is used to EMBED java CODE in JSP. |
|
| 20. |
Which tag is used to set a value of a JavaBean?(a) (b) (c) (d) This question was posed to me in a job interview.The query is from JSP Elements in section Session Management, JSP & API of Java |
|
Answer» Right choice is (a) |
|
| 21. |
What temporarily redirects response to the browser?(a) (b) (c) response.sendRedirect(URL)(d) response.setRedirect(URL)The question was posed to me at a job interview.This interesting question is from JSP Elements topic in section Session Management, JSP & API of Java |
|
Answer» Right CHOICE is (c) response.sendRedirect(URL) |
|
| 22. |
“out” is implicit object of which class?(a) javax.servlet.jsp.PrintWriter(b) javax.servlet.jsp.SessionWriter(c) javax.servlet.jsp.SessionPrinter(d) javax.servlet.jsp.JspWriterI have been asked this question in a job interview.Asked question is from JSP Elements in chapter Session Management, JSP & API of Java |
|
Answer» The correct choice is (d) javax.servlet.jsp.JspWriter |
|
| 23. |
Which object stores references to the request and response objects?(a) sessionContext(b) pageContext(c) HttpSession(d) sessionAttributeThe question was asked in an online quiz.The doubt is from JSP Elements topic in section Session Management, JSP & API of Java |
|
Answer» The correct ANSWER is (b) PAGECONTEXT |
|
| 24. |
Which attribute uniquely identification element?(a) ID(b) Class(c) Name(d) ScopeThis question was addressed to me by my school principal while I was bunking the class.This question is from JSP Elements topic in chapter Session Management, JSP & API of Java |
|
Answer» RIGHT option is (a) ID The EXPLANATION is: ID attribute is used to uniquely IDENTIFY action element. |
|
| 25. |
Which of the following action variable is used to include a file in JSP?(a) jsp:setProperty(b) jsp:getProperty(c) jsp:include(d) jsp:pluginThis question was addressed to me during an online exam.This question is from JSP Elements in section Session Management, JSP & API of Java |
|
Answer» RIGHT option is (c) JSP:include Best EXPLANATION: jsp:include action variable is used to include a file in JSP. |
|
| 26. |
Which one of the following is correct for directive in JSP?(a) (b) (c) (d) This question was addressed to me by my school teacher while I was bunking the class.This intriguing question originated from JSP Elements topic in section Session Management, JSP & API of Java |
|
Answer» Correct OPTION is (a) <%@directive%> |
|
| 27. |
Which is not a directive?(a) include(b) page(c) export(d) useBeanI got this question in homework.This is a very interesting question from JSP topic in section Session Management, JSP & API of Java |
|
Answer» The CORRECT CHOICE is (c) export |
|
| 28. |
“request” is instance of which one of the following classes?(a) Request(b) HttpRequest(c) HttpServletRequest(d) ServletRequestI got this question by my college director while I was bunking the class.My doubt stems from JSP topic in section Session Management, JSP & API of Java |
|
Answer» CORRECT CHOICE is (C) HttpServletRequest Explanation: REQUEST is OBJECT of HttpServletRequest. |
|
| 29. |
Which one is the correct order of phases in JSP life cycle?(a) Initialization, Cleanup, Compilation, Execution(b) Initialization, Compilation, Cleanup, Execution(c) Compilation, Initialization, Execution, Cleanup(d) Cleanup, Compilation, Initialization, ExecutionI had been asked this question in examination.My enquiry is from JSP in division Session Management, JSP & API of Java |
|
Answer» Correct OPTION is (c) Compilation, INITIALIZATION, Execution, CLEANUP |
|
| 30. |
Default value of autoFlush attribute is?(a) true(b) falseI have been asked this question during an online exam.The above asked question is from JSP topic in division Session Management, JSP & API of Java |
|
Answer» RIGHT option is (a) true The explanation is: Default VALUE “true” DEPICTS automatic BUFFER flushing. |
|
| 31. |
Which option is true about session scope?(a) Objects are accessible only from the page in which they are created(b) Objects are accessible only from the pages which are in same session(c) Objects are accessible only from the pages which are processing the same request(d) Objects are accessible only from the pages which reside in same applicationThis question was addressed to me during an interview.This interesting question is from JSP in chapter Session Management, JSP & API of Java |
|
Answer» Right answer is (b) Objects are accessible only from the pages which are in same SESSION |
|
| 32. |
_jspService() method of HttpJspPage class should not be overridden.(a) True(b) FalseThis question was posed to me in an interview for job.I'd like to ask this question from JSP topic in division Session Management, JSP & API of Java |
|
Answer» The correct answer is (a) True |
|
| 33. |
Which tag should be used to pass information from JSP to included JSP?(a) Using tag(b) Using tag(c) Using tag(d) Using tagThis question was addressed to me in an interview for job.The above asked question is from JSP in division Session Management, JSP & API of Java |
|
Answer» The correct OPTION is (a) Using <%jsp:PAGE> tag |
|
| 34. |
Application is instance of which class?(a) javax.servlet.Application(b) javax.servlet.HttpContext(c) javax.servlet.Context(d) javax.servlet.ServletContextThis question was posed to me in a national level competition.My doubt stems from JSP in portion Session Management, JSP & API of Java |
|
Answer» CORRECT ANSWER is (d) javax.servlet.ServletContext To explain I would SAY: APPLICATION object is WRAPPER around the ServletContext object and it is an instance of a javax.servlet.ServletContext object. |
|
| 35. |
Which page directive should be used in JSP to generate a PDF page?(a) contentType(b) generatePdf(c) typePDF(d) contentPDFI have been asked this question during an internship interview.I would like to ask this question from JSP topic in chapter Session Management, JSP & API of Java |
|
Answer» Right choice is (a) contentType |
|
| 36. |
Which method creates unique fields in the HTML which are not shown to the user?(a) User authentication(b) URL writing(c) HTML Hidden field(d) HTML invisible fieldThis question was posed to me in unit test.This interesting question is from Session Management topic in division Session Management, JSP & API of Java |
|
Answer» Right option is (C) HTML Hidden field |
|
| 37. |
How can we invalidate a session?(a) session.discontinue()(b) session.invalidate()(c) session.disconnect()(d) session.falsify()I got this question by my school principal while I was bunking the class.My doubt stems from Session Management topic in portion Session Management, JSP & API of Java |
|
Answer» Correct ANSWER is (B) SESSION.invalidate() |
|
| 38. |
SessionIDs are stored in cookies.(a) True(b) FalseI got this question in semester exam.Origin of the question is Session Management topic in portion Session Management, JSP & API of Java |
|
Answer» CORRECT CHOICE is (a) True To ELABORATE: SessionIDs are stored in COOKIES, URLs and hidden form fields. |
|
| 39. |
What is the maximum size of cookie?(a) 4 KB(b) 4 MB(c) 4 bytes(d) 40 KBThis question was posed to me in an online interview.The above asked question is from Session Management topic in section Session Management, JSP & API of Java |
|
Answer» CORRECT option is (a) 4 KB The explanation is: The 4K is the maximum size for the ENTIRE cookie, including NAME, value, expiry date etc. To support most browsers, it is suggested to keep the name under 4000 BYTES, and the overall cookie size under 4093 bytes. |
|
| 40. |
Which of the following is not true about session?(a) All users connect to the same session(b) All users have same session variable(c) Default timeout value for session variable is 20 minutes(d) New session cannot be created for a new userThe question was asked during a job interview.This interesting question is from Session Management topic in division Session Management, JSP & API of Java |
|
Answer» The correct CHOICE is (c) Default timeout VALUE for session variable is 20 minutes |
|
| 41. |
Which of the following leads to high network traffic?(a) URL rewriting(b) Hidden form fields(c) SSL sessions(d) CookiesThe question was posed to me in an online interview.This key question is from Session Management in chapter Session Management, JSP & API of Java |
|
Answer» CORRECT answer is (a) URL rewriting Explanation: WRL rewriting requires large DATA TRANSFER to and from the server which leads to network traffic and ACCESS may be slow. |
|
| 42. |
Which of the below is not a session tracking method?(a) URL rewriting(b) History(c) Cookies(d) SSL sessionsI got this question in final exam.This intriguing question originated from Session Management topic in section Session Management, JSP & API of Java |
|
Answer» The correct choice is (B) HISTORY |
|
| 43. |
Which of the following is stored at client side?(a) URL rewriting(b) Hidden form fields(c) SSL sessions(d) CookiesI had been asked this question by my school principal while I was bunking the class.My doubt stems from Session Management in section Session Management, JSP & API of Java |
|
Answer» CORRECT ANSWER is (d) Cookies Explanation: Cookies are stored at CLIENT side. HENCE, it is advantageous in some cases where CLIENTS disable cookies. |
|
| 44. |
Which of the following is used for session migration?(a) Persisting the session in database(b) URL rewriting(c) Create new database connection(d) Kill session from multiple sessionsThe question was posed to me in quiz.My query is from Session Management topic in division Session Management, JSP & API of Java |
|
Answer» Right OPTION is (a) Persisting the SESSION in database |
|