Core Java Interview Questions and Answers Pdf - 1

Question: 1

What is the difference between a Scrollbar and a Scrollpane?

A Scrollbar is a component, but not a container.

A Scrollpane is a container.

A Scrollpane handles its own events and performs its own scrolling.

Question: 2

How can we get all public methods of an object dynamically?

getMethods(): It return an array of method objects corresponding to the public methods of this class.

getFields(): It returns an array of Field objects corresponding to the public Fields (variables) of this class.

getConstructors: It returns an array of constructor objects corresponding to the public constructors of this class.

Question: 3

Which method will cause a Frame to be displayed?

.show()                                                                                  

.setVisible()

Question: 4

Explain the purpose of component’s requestFocus method?

The purpose of the requestFocnus() is to get the focus on the particular component  and also on the window that contains the component.

Question: 5

Which method returns the preferred size of a component?

getPreferredSize()

Related Questions