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.
Questions
What is the role of ServletConfig interface in java servlet?
- This interface is used to read data from a client request.
- This interface is used to write data from a client request.
- This interface is used to declare the life cycle method of the servlet.
- This interface is used to provide access information and the log events to the servlet in its environment.
- This interface is used to initialize the parameters to the servlet.
Which of the following is/are not method(s) of HttpServletRequest interface in java servlet?
- String getServletPath()
- HttpSession getSession()
- Void addCookie(Cookie cookie)
- None of the above
- Both (2) and (3)
Which of the following is not a method of Cookies class in java servlet?
- String getDomain
- int getMaxAge
- String getName
- Object clone()
- None of the above
Which of the following is not a valid constructor of scroll pane in java swing?
- JScrollPane(Component comp, int vsb, int hsb)
- JScrollPane(int vsb, int hsb)
- JScrollPane(Component comp)
- None of the above
- Both (2) and (3)
What is the role of JFrame class in java swing?
- It is used to create a primary window of an application.
- It is used to create the scrollable window.
- It is used to create the tabbed window.
- It is used to create the tabular format controls in window.
- None of the above
Which of the following methods of the HttpSession interface of java servlet is used to remove the session from the context ?
- void invalidate()
- void removeAttribute(String attr)
- void setAttribute(String attr, Object val))
- both (1) and (2)
- none of the above
Which of the following statements is true about scroll pane in java swing?
- It represents a rectangular area to view the specified components.
- It is used to represent file folders, which have the options to be selected.
- It is used to provide a combination of a drop down list and a text box.
- It represents the hierarchical view of data.
- None of the above
Which of the following is a valid signature of setEnabled() method of JButton class in java swing?
- setEnabled(String s)
- setEnabled(int a)
- setEnabled(ActionListener a)
- setEnabled(boolean b)
- none of the above
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?
- Grid layout
- Border layout
- Card layout
- None of the above
- Both (2) and (3)
Which of the following layout manger classes defines the components in a line?
- Flow layout
- Border layout
- Grid layout
- Card layout
- Both (1) and (4)
What is the use of ItemEvent class in event handling in java?
- This event class is used to determine that the particular item is selected or deselected.
- This event class is used to determine that the specific action is performed on an item.
- This event class is used to determine that the values of the scrolling components are changed by the user.
- This event class is used to determine that the particular item loses or gains the focus.
- None of the above
Which of the following is not a method of Hashtable class in java collection framework?
- Void clear()
- Object clone()
- Object remove(Object key)
- String toString()
- None of the above
Which of the following statements is false in C language?
- Auto keyword is necessary to declare the automatic variables.
- By default, the variables declared are called automatic variables.
- Static variables can be accessed till the end of the program.
- External variables can be accessed till the end of the program.
- None of the above
Which of the following Map classes extends the HashMap class in java collection framework?
- AbsractMap
- TreeMap
- WeakHashMap
- LinkedHashMap
- None of the above
Which of the following is a false statement in java?
- An class can implement any number of interfaces.
- An interface contains public and abstract methods.
- A class can extend more than one abstract class.
- An interface can not implement other interface.
- None of the above
Which of the following is/are example(s) of checked exception in java?
- IOException
- ClassNotFoundException
- SQLException
- All of the above
- Only (1) and (2)
Which of the following is not an interface in java collection framework?
- Set
- Collection
- Map
- Map.Entry
- None of the above
Which of the following methods is used to split the string in java?
- Split
- StringTokenizer
- Replace
- Both (1) and (2)
- None of the above
Which of the following methods of the Object class cannot be overriden in java?
- equals()
- finalize()
- toString()
- wait()
- getClass()
What does toString() method in java do?
- This method is used to convert the string values into integers.
- This method is used to get the string representation of the number values.
- This method is used to get the string values from the char array.
- This method is used to split the string.
- None of the above
Which of the following constructors of the HashMap class throws NullPointerException in java collection framework?
- public HashMap(int initialCapacity, float loadFactor)
- public HashMap()
- public HashMap(Map<!--? extends K,? extends V--> m)
- both (1) and (3)
- none of the above
Which of the following methods of the Thread class is used to wait for a thread to complete?
- sleep
- join
- start
- isAlive
- none of the above
Which of the following methods of ListIterator class throws NoSuchElementFoundException in java collection framework?
- object next()
- void remove()
- boolean hasNext()
- boolean hasPrevious()
- none of the above
What does entrySet() method in the Map class in java collection framework do?
- It returns the set containing the entries in the map.
- It returns the set containing the keys in the map.
- It returns the set containing the values of the keys in the map.
- This method is not defined in the map class.
- None of the above
Which of the following interfaces is/are called collection interfaces in java?
- List
- Set
- SortedSet
- All of the above
- Only (1) and (2)
Which of the following is/are true statements in java?
- A final method cannot be overridden.
- A static method cannot be overridden.
- A method which is not overriden, cannot be inherited too.
- All of the above
- Only (1) and (2)
What does nextElement() method return in StringTokenizer class?
- It returns the next token as a String.
- It returns the next token as an Object.
- It returns the number of tokens left to be parsed.
- It returns true if one or more tokens remain in the string.
- None of the above
Which of the following classes does/do not contain menu bar in AWT (Abstract window Toolkit) in java?
- Panel
- Window
- Frame
- All of the above
- Only (1) and (2)
Which of the following statements is/are true about applet in java?
- Applet is a program embedded in the web page.
- Applet has less response time.
- Applet can run under many platforms Linux, Windows, Mac, etc.
- All of the above.
- Only (1) and (3) are true.
Which of the following is the immediate superclass of Applet class in java?
- Frame
- Panel
- Window
- Dialog
- Container
Which of the following is not a valid expression type in switch (expression)?
- Char
- Float
- Int
- Short
- Long