Ticker

6/recent/ticker-posts

JAVA MCQ QUESTIONS AND ANSWERS PART - 2

JAVA MCQ QUESTIONS AND ANSWERS PART -2


1. Attribute of an object can include information about?

1. state
2. method
3. Behavior
4. procedures
Answer: 1

 

2. Which method of the thread class should be defined?

1. run()
2. start()
3. Both[A]and[B]
4. None of this above
Answer: 1

 

3. How constructor can be used for a servlet?

1. Initialization
2. Constructor function
3. Initialization and Constructor function
4. Setup() method
Answer: 3

 

4. Which of the following code is used to get an attribute in a HTTP Session object in servlets?

1. session.getAttribute(String name)
2. session.alterAttribute(String name)
3. session.updateAttribute(String name)
4. session.setAttribute(String name)
Answer: 1

 

5. Which method is used to get three-letter abbreviation for locale’s country in servlets?

1. Request.getISO3Country()
2. Locale.getISO3Country()
3. Response.getISO3Country()
4. Local.retrieveISO3Country()
Answer: 1

 

6. Which of the following code retrieves the body of the request as binary data?

1. DataInputStream data = new InputStream()
2. DataInputStream data = response.getInputStream()
3. DataInputStream data = request.getInputStream()
4. DataInputStream data = request.fetchInputStream()
Answer: 3

 

7. When destroy() method of a filter is called?

1. The destroy() method is called only once at the end of the life cycle of a filter
2. The destroy() method is called after the filter has executed doFilter method
3. The destroy() method is called only once at the begining of the life cycle of a filter
4. The destroyer() method is called after the filter has executed
Answer: 1

 

8. Which of these collection class has the ability to grow dynamically?

1. Array
2. Arrays
3. ArrayList
4. None of These
Answer: 3

 

9. How is the dynamic interception of requests and responses to transform the information done?

1. servlet container
2. servlet config
3. servlet context
4. servlet filter
Answer: 4

 

10. What are the different types of session tracking mechanism supported by Servlets?

1. URL tracking
2. cookies
3. Hidden Form fields
4. all of the above
Answer: 4

 

11. Which method is used to specify before any lines that uses the PintWriter?

1. setPageType()
2. setContextType()
3. setContentType()
4. None of the above
Answer: 2

 

12. Which of the following code retrieves the MIME type of the body of the request?

1. new MimeType()
2. request.getContentType()
3. response.getContentType()
4. None
Answer: 2

 

13. The life cycle of a servlet is managed by

1. servlet context
2. servlet container
3. the supporting protocol (such as http or https)
4. doPost
Answer: 2

 

14. Which method shows the client what server is receiving?

1. goGet
2. doOption
3. doTrace
4. 1,4
Answer: 1

 

15. Which of the following are class? 1.ServletContext 2.Servlet 3.GenericServlet 4.HttpServlet

1. 1,2,3,4
2. 1,2
3. 3,4
4. session.addCookiecookie
Answer: 3

 

16. Which of the following code can be used to write a cookie?

1. request.addCookiecookie
2. response.addCookiecookie
3. Header.addCookiecoo kie
4. None
Answer: 2

 

17. Which of these method can be used to increase the capacity of ArrayList object manually?

1. Capacity()
2. increaseCapacity()
3. increasecapacity()
4. ensureCapacity()
Answer: 4

 

18. Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?

1. getData()
2. getBytes()
3. getArray()
4. recieveBytes()
Answer: 1

 

19. Which of these data member of HttpResponse class is used to store the response from a http server?

1. status
2. address
3. statusResponse
4. statusCode
Answer: 4

 

20. What does setAutoCommit(false) do?

1. commits transaction after each query
2. explicitly commits transaction
3.does not commit transaction automatically after each query
4. never commits transaction
Answer: 3

 

21. Which of the following is used to call stored procedure?

1. Statement
2. PreparedStatement
3. CallableStatment
4. CalledStatement
Answer: 3

 

22. Which of the following is used to limit the number of rows returned?

1. setMaxRows(int i)
2. setMinRows(int i)
3. getMaxrows(int i)
4. getMinRows(int i)
Answer: 1

 

23. Which class provides system independent server side implementation?

1. Socket
2. ServerSocket
3. Server
4. ServerReader
Answer: 2

 

24. Which of these is a return type of getAddress method of DatagramPacket class?

1. DatagramPacket
2. DatagramSocket
3. InetAddress
4. ServerSocket
Answer: 3

 

25. Which of these is wrapper around everything associated with a reply from an http server?

1. HTTP
2. HttpResponse
3. Httpserver
4. httpserver
Answer: 1

 

26. Suspend thread can be revived by using_______

1. start() method
2. Suspend() method
3. resume() method
4. yield() method
Answer: 3

 

27. Choose the CORRECT statement.

1. To write JSP code you require a browser.
2. To test the JSPs you need a server engine.
3. JSPs looks like HTML script
4. JSP combines HTML and JDK tools
Answer: 3


ALSO, SEE JAVA MCQ

Java Multiple Choice Questions

"java mcq questions and answers"

"java mcq questions and answers topic wise"

"core java mcq questions and answers"

"advance java mcq questions and answers"

"basic java mcq questions and answers"

"java programming mcq questions and answers"

"java 8 mcq questions and answers"

"java oops mcq questions and answers"