0

Java

Description: Concept Based Questions
Number of Questions: 15
Created by:
Tags: Concept Based Questions Java Basics
Attempted 0/15 Correct 0 Score 0

How many container classes are there in java AWT?

  1. 6

  2. 5

  3. 4

  4. 3

  5. 2


Correct Option: B
Explanation:

This is the correct answer, there are 5 container classes for AWT components. Container classes are used to contain other GUI components.These container classes are :-WindowPanelAppletFrameDialogSo this is the correct answer.

How many maximum arguments can be passed to the FlowLayout Constructor?

  1. 5

  2. 4

  3. 3

  4. 2

  5. 1


Correct Option: C
Explanation:

This is the correct answer, we can pass minimum 0 arguments and maximum 3 arguments to the FlowLayout constructor. These 3 arguments are :-FlowLayout(int alignment, int horizontalgap, int verticalgap)Alignment:- it can be FlowLayout.LEFT, FlowLayout.RIGHT or FlowLayout.CENTERHorizontalgap : - it specifies the horizontal gap between the components.Verticalgap : - It specifies the vertical gap between the components.So this answer is correct.

How many maximum arguments can we pass to the GridLayout constructor?

  1. 6

  2. 5

  3. 4

  4. 3

  5. 2


Correct Option: C
Explanation:

This is the correct answer. We can pass maximum 4 arguments to the GridLayout constructor. These arguments are :-GridLayout(int rows, int columns, int HorizontalGap, int VerticalGap)This will create a gridlayout with specified number of row and columns and with a specific horizontal and vertical gap between the componenets.So this answer is correct.

How many layout managers are present in java?

  1. 10

  2. 9

  3. 8

  4. 7

  5. 6


Correct Option: C
Explanation:

This is the correct choice, there are 8 Layout Managers in java. These are :-1. BorderLayout2. BoxLayout3. CardLayout4. FlowLayout5. GridBagLayout6. GridLayout7. GroupLayout8. SpringLayoutSo this is correct choice.

What is the third argument passed to constructor of Font class?

  1. Int size

  2. String name

  3. Int style

  4. Int alignment

  5. Int Color


Correct Option: A
Explanation:

This is the correct answer, we can pass 3 arguments to the constructor of Font Class. These arguments are :-Font(String name, int style, int size)For example :-Font(“SanSerif”, Font.BOLD,20)The third argument specifies the size of the font.So this is the correct answer.

How many maximum arguments can be passed to the BorderLayout Constructor?

  1. 5

  2. 4

  3. 3

  4. 2

  5. 1


Correct Option: D
Explanation:

This is the correct answer we can pass maximum 2 arguments to the BorderLayout Constructor. These arguments are :-BorderLayout(int horizontalgap, int verticalgap)This will create a BorderLayout with specified horizontal and vertical gap between the components.So this is the correct answer.

What is the third argument passed to the Constructor of GridLayout?

  1. Int rows

  2. Int columns

  3. Int HorizontalGap

  4. Int VerticalGap

  5. Int Alignmnent


Correct Option: C
Explanation:

This is the correct answer. We can pass maximum 4 arguments to the GridLayout constructor. These arguments are :-GridLayout(int rows, int columns, int HorizontalGap, int VerticalGap)This will create a gridlayout with specified number of row and columns and with a specific horizontal and vertical gap between the componenets.So the third argument is HorizontalGap.So this answer is correct.

Which of the following is/are not known as the helper class in java AWT?

  1. LayoutManager

  2. Colour

  3. Font

  4. Dimensions

  5. Graphics


Correct Option: B
Explanation:

This is the correct answer, there is no helper class in java AWT named Colour. The correct spelling are Color. This class deals with the colours of the GUI components.So this is the correct answer.

What is the Default Layout Manager of the Panel p1 that we have created?

JPanel p1 = new JPanel()

  1. BorderLayout

  2. CardLayout

  3. FlowLayout

  4. GridLayout

  5. BoxLayout


Correct Option: C
Explanation:

This is the correct answer because when we create a panel, its default Layout Manager is FlowLayout.So in this case the Panel p1 will have FlowLayout.So this answer is correct.

How many arguments are passed to the constructor of Font Class?

  1. 5

  2. 4

  3. 3

  4. 2


Correct Option: C
Explanation:

This is the correct answer, we can pass 3 arguments to the constructor of Font Class. These arguments are :-Font(String name, int style, int size)For example :-Font(“SanSerif”, Font.BOLD,20)So this is the correct answer.

Which of the following argument is the third argument passed to the constructor of the FlowLayout?

  1. Int horizontalGap

  2. Int VerticalGap

  3. Int Alignment

  4. Int Rows

  5. Int Columns


Correct Option: B
Explanation:

This is the correct answer, we can pass 3 arguments to the FlowLayout constructor. These 3 arguments are :-FlowLayout(int alignment, int horizontalgap, int verticalgap)Alignment:- it can be FlowLayout.LEFT, FlowLayout.RIGHT or FlowLayout.CENTERHorizontalgap : - it specifies the horizontal gap between the components.Verticalgap : - It specifies the vertical gap between the components.So the third argument is VerticalGao, so this answer is correct.

Which of the following is/are the helper class in java AWT?

  1. Window

  2. Applet

  3. Panel

  4. Dimension

  5. Dialog


Correct Option: D
Explanation:

This answer is correct, because Dimensions is the one of the Helper Classes present in Java AWT. This class encapsulates the width and the height of the component in a single object.So this is correct choice.

What is the Second Argument passed to the Constructor of GridLayout?

  1. Int rows

  2. Int columns

  3. Int horizontalGap

  4. Int VerticalGap

  5. Int Alignment


Correct Option: B
Explanation:

This is the correct answer. We can pass maximum 4 arguments to the GridLayout constructor. These arguments are :-GridLayout(int rows, int columns, int HorizontalGap, int VerticalGap)This will create a gridlayout with specified number of row and columns and with a specific horizontal and vertical gap between the componenets.So the second argument is Columns.So this answer is correct.

What is the third argument passed to the Constructor of BorderLayout?

  1. Int alignment

  2. Int horizontalGap

  3. Int VerticalGap

  4. Int Rows

  5. None of these


Correct Option: E
Explanation:

This is the correct answer we can pass maximum 2 arguments to the BorderLayout Constructor. These arguments are :-BorderLayout(int horizontalgap, int verticalgap)This will create a BorderLayout with specified horizontal and vertical gap between the components.There is no third argument.So this is the correct answer.

How many constructors are there of CardLayout?

  1. 5

  2. 4

  3. 3

  4. 2

  5. 1


Correct Option: D
Explanation:

This is the correct answer, there are two constructors of CardLayout. These are :-CardLayout() :-Creates a new card layout with gaps of size zero.CardLayout(int hgap, int vgap) :- Creates a new card layout with the specified horizontal and vertical gaps.So this is the correct choice.

- Hide questions