Java Programming Fundamentals

This quiz covers core Java programming concepts including servlets, Swing GUI, collections framework, multithreading, applets, event handling, and basic C language concepts.

31 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the role of ServletConfig interface in java servlet?

  1. This interface is used to read data from a client request.
  2. This interface is used to write data from a client request.
  3. This interface is used to declare the life cycle method of the servlet.
  4. This interface is used to provide access information and the log events to the servlet in its environment.
  5. This interface is used to initialize the parameters to the servlet.
Question 2 Multiple Choice (Single Answer)

Which of the following is/are not method(s) of HttpServletRequest interface in java servlet?

  1. String getServletPath()
  2. HttpSession getSession()
  3. Void addCookie(Cookie cookie)
  4. None of the above
  5. Both (2) and (3)
Question 3 Multiple Choice (Single Answer)

Which of the following is not a method of Cookies class in java servlet?

  1. String getDomain
  2. int getMaxAge
  3. String getName
  4. Object clone()
  5. None of the above
Question 4 Multiple Choice (Single Answer)

Which of the following is not a valid constructor of scroll pane in java swing?

  1. JScrollPane(Component comp, int vsb, int hsb)
  2. JScrollPane(int vsb, int hsb)
  3. JScrollPane(Component comp)
  4. None of the above
  5. Both (2) and (3)
Question 5 Multiple Choice (Single Answer)

What is the role of JFrame class in java swing?

  1. It is used to create a primary window of an application.
  2. It is used to create the scrollable window.
  3. It is used to create the tabbed window.
  4. It is used to create the tabular format controls in window.
  5. None of the above
Question 6 Multiple Choice (Single Answer)

Which of the following methods of the HttpSession interface of java servlet is used to remove the session from the context ?

  1. void invalidate()
  2. void removeAttribute(String attr)
  3. void setAttribute(String attr, Object val))
  4. both (1) and (2)
  5. none of the above
Question 7 Multiple Choice (Single Answer)

Which of the following statements is true about scroll pane in java swing?

  1. It represents a rectangular area to view the specified components.
  2. It is used to represent file folders, which have the options to be selected.
  3. It is used to provide a combination of a drop down list and a text box.
  4. It represents the hierarchical view of data.
  5. None of the above
Question 8 Multiple Choice (Single Answer)

Which of the following is a valid signature of setEnabled() method of JButton class in java swing?

  1. setEnabled(String s)
  2. setEnabled(int a)
  3. setEnabled(ActionListener a)
  4. setEnabled(boolean b)
  5. none of the above
Question 9 Multiple Choice (Single Answer)

Which of the following layout managers is used to manage the components in such a manner that only one component is visible at a time?

  1. Grid layout
  2. Border layout
  3. Card layout
  4. None of the above
  5. Both (2) and (3)
Question 10 Multiple Choice (Single Answer)

Which of the following layout manger classes defines the components in a line?

  1. Flow layout
  2. Border layout
  3. Grid layout
  4. Card layout
  5. Both (1) and (4)
Question 11 Multiple Choice (Single Answer)

What is the use of ItemEvent class in event handling in java?

  1. This event class is used to determine that the particular item is selected or deselected.
  2. This event class is used to determine that the specific action is performed on an item.
  3. This event class is used to determine that the values of the scrolling components are changed by the user.
  4. This event class is used to determine that the particular item loses or gains the focus.
  5. None of the above
Question 12 Multiple Choice (Single Answer)

Which of the following is not a method of Hashtable class in java collection framework?

  1. Void clear()
  2. Object clone()
  3. Object remove(Object key)
  4. String toString()
  5. None of the above
Question 13 Multiple Choice (Single Answer)

Which of the following statements is false in C language?

  1. Auto keyword is necessary to declare the automatic variables.
  2. By default, the variables declared are called automatic variables.
  3. Static variables can be accessed till the end of the program.
  4. External variables can be accessed till the end of the program.
  5. None of the above
Question 14 Multiple Choice (Single Answer)

Which of the following Map classes extends the HashMap class in java collection framework?

  1. AbsractMap
  2. TreeMap
  3. WeakHashMap
  4. LinkedHashMap
  5. None of the above
Question 15 Multiple Choice (Single Answer)

Which of the following is a false statement in java?

  1. An class can implement any number of interfaces.
  2. An interface contains public and abstract methods.
  3. A class can extend more than one abstract class.
  4. An interface can not implement other interface.
  5. None of the above
Question 16 Multiple Choice (Single Answer)

Which of the following is/are example(s) of checked exception in java?

  1. IOException
  2. ClassNotFoundException
  3. SQLException
  4. All of the above
  5. Only (1) and (2)
Question 17 Multiple Choice (Single Answer)

Which of the following is not an interface in java collection framework?

  1. Set
  2. Collection
  3. Map
  4. Map.Entry
  5. None of the above
Question 18 Multiple Choice (Single Answer)

Which of the following methods is used to split the string in java?

  1. Split
  2. StringTokenizer
  3. Replace
  4. Both (1) and (2)
  5. None of the above
Question 19 Multiple Choice (Single Answer)

Which of the following methods of the Object class cannot be overriden in java?

  1. equals()
  2. finalize()
  3. toString()
  4. wait()
  5. getClass()
Question 20 Multiple Choice (Single Answer)

What does toString() method in java do?

  1. This method is used to convert the string values into integers.
  2. This method is used to get the string representation of the number values.
  3. This method is used to get the string values from the char array.
  4. This method is used to split the string.
  5. None of the above
Question 21 Multiple Choice (Single Answer)

Which of the following constructors of the HashMap class throws NullPointerException in java collection framework?

  1. public HashMap(int initialCapacity, float loadFactor)
  2. public HashMap()
  3. public HashMap(Map<!--? extends K,? extends V--> m)
  4. both (1) and (3)
  5. none of the above
Question 22 Multiple Choice (Single Answer)

Which of the following methods of the Thread class is used to wait for a thread to complete?

  1. sleep
  2. join
  3. start
  4. isAlive
  5. none of the above
Question 23 Multiple Choice (Single Answer)

Which of the following methods of ListIterator class throws NoSuchElementFoundException in java collection framework?

  1. object next()
  2. void remove()
  3. boolean hasNext()
  4. boolean hasPrevious()
  5. none of the above
Question 24 Multiple Choice (Single Answer)

What does entrySet() method in the Map class in java collection framework do?

  1. It returns the set containing the entries in the map.
  2. It returns the set containing the keys in the map.
  3. It returns the set containing the values of the keys in the map.
  4. This method is not defined in the map class.
  5. None of the above
Question 25 Multiple Choice (Single Answer)

Which of the following interfaces is/are called collection interfaces in java?

  1. List
  2. Set
  3. SortedSet
  4. All of the above
  5. Only (1) and (2)
Question 26 Multiple Choice (Single Answer)

Which of the following is/are true statements in java?

  1. A final method cannot be overridden.
  2. A static method cannot be overridden.
  3. A method which is not overriden, cannot be inherited too.
  4. All of the above
  5. Only (1) and (2)
Question 27 Multiple Choice (Single Answer)

What does nextElement() method return in StringTokenizer class?

  1. It returns the next token as a String.
  2. It returns the next token as an Object.
  3. It returns the number of tokens left to be parsed.
  4. It returns true if one or more tokens remain in the string.
  5. None of the above
Question 28 Multiple Choice (Single Answer)

Which of the following classes does/do not contain menu bar in AWT (Abstract window Toolkit) in java?

  1. Panel
  2. Window
  3. Frame
  4. All of the above
  5. Only (1) and (2)
Question 29 Multiple Choice (Single Answer)

Which of the following statements is/are true about applet in java?

  1. Applet is a program embedded in the web page.
  2. Applet has less response time.
  3. Applet can run under many platforms Linux, Windows, Mac, etc.
  4. All of the above.
  5. Only (1) and (3) are true.
Question 30 Multiple Choice (Single Answer)

Which of the following is the immediate superclass of Applet class in java?

  1. Frame
  2. Panel
  3. Window
  4. Dialog
  5. Container
Question 31 Multiple Choice (Single Answer)

Which of the following is not a valid expression type in switch (expression)?

  1. Char
  2. Float
  3. Int
  4. Short
  5. Long