Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
51 views
11 pages
AJP Chapter 1
I have done this
Uploaded by
171 Om Bhoyar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save AJP Chapter 1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
51 views
11 pages
AJP Chapter 1
I have done this
Uploaded by
171 Om Bhoyar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save AJP Chapter 1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
hh of the following statements are true? To distinguish new Swing component classes from their gy, counterparts, Swing GUI component classes are named with a prefiy All Swing GUI components are lightweight. A user interface object such as (button, list) can appear in ons container. (d) A container such as JFrame is also a component. 2. Which of the following statements about GUI components is wrong ? (2) Swing exists since version 1.2 of the jdk (b) You can not place AWT components on Swing containers (©) AWT stands for Abstract Window Toolkit (d) The AWT classes are deprecated Which of the following are subclasses of java.awt.Component? (a) Container classes (b) Swing user interface classes (¢) Helper classes such as Color and Font (d) Layout managers ‘Swing components that don't rely on native GUI are referred to as —: (a) lightweight components _(b)_ heavyweight components (c) GUI components (d)_non-GUI componentsprogramming 1115 5, What is best to describe the relationship between 1Component and 38 ‘and 3Button? (a) Association (b) Aggregation (©) Composition (6) Inheritance fh Neh componentcannet be edt a conan? {a) JPanel (b) 2Button (©) JFrame (@)_3Component ‘analyze the following code. © aport java-ant amport javax.swing.*; public class Test [ public static void main(Stringf] args) ( Component ¢ = new dButton(*0K"); serame frame © new JFrame(*My Frame"); frame.add (ec) frame. setDefaultCloseoperat ion (JFrame. BX1T_ON_CLOSE) ; frame.setVisible (true); ) , (a) You cannot assign @ JButton to a variable of java.awt.Component. (b) You can only add ¢ to a container because c's type is Component. (c) You cannot add a Swing component directly to a 3Frame using add(c) prior to JDK 1.4, but itis OK in DK 15. > (a) You cannot create a JFrame using new JFrame("My Frame"), 8, Analyze the following code, import java. awt.*7 sport javax.swing.*7 public class Test Public static void main(string{) args) ( JFrame frame = new JFrame ("My Frame"); frame.add (new JButton ("0K") )7 frane.add (new JButton ("cancel") )7 frane set DefaultCloseoperation (JFr frane.setsize(200, 2007 ‘ane .EXIT_ON_CLOSE) + frame. setVisible(teue) HAdvanced Java Pre 10. u 12, Programming, 115 nro. to Abc Wadoning To (A 8g (a) Only button Ok is displayed. (b)_ Only button Cancel is displayed. (©) Both button OK and button Cancel are displayed and button OK js displayed on the left side of button OK (a) Both button OK and button Cancel are displayed and button OK is displayed on the right side of button OK. How many frames are displayed? import javax.swing.*7 public class public static void main(string{] ag3) [ Jrame £1 = new JFrame(*Hy Frame"); aerame £2 = 1; werane £3 = £2; f1.setVielble(true) f2.setVialble (true) 13. setVisible (true); 1 , (a) (b) 2 (3 i) 0 Which of the following statements is for placing the frame's upper left corer to (200, 100)? (a) frame.settocation(100, 100) (b) frame.setLocation( 100, 200) (©) frame.setLocation(200, 100) (0) frome.settocation(200, 200) What should you use to position a Button within an application Frame s0 tet the size of the Button is NOT affected by tne Frame size? (a) @ FlowLayout (b) a GridLayout (0) the center area of a BorderLayout (a) the East or West area of a BorderLayout mat layout manager should you use jes th Se ee erie mame tam chr comers Sear (a) @ Flowtayout (0) a Gridtayout (c)_ a BorderLayout (@) any layoutva ad ‘ Into.to a Hr. to Abstat Windowing Tet (AW) & Swings 13, Suppose a JFrame uses the GridLayout(2, 0). If you add six but frame, how many columns are displayed? fons to the @ (b) 2 3 (@ 4 ‘o set a FlowLayout in panel jp, you can use the method __. (a) jp.setLayout(new FlowLayout()); a {b) jp.setLayout(new FlowLayout(FlowLayout.CENTER)); {@) jp.setLayout(new FlowLayout(FlowLayout.center)); {@) jpsetLayout(FlowLayout()); ‘Suppose a JFrame uses the GridLayout(0, 2). If you add six buttons to the frame, how many columns are displayed? (a) 1 (b) 2 © 3 (a) 4 ‘Suppose @ JFrame uses the GridLayout(2, 2). If you add six buttons to the frame, how many columns are displayed? @ 1 (b) 2 © 3 (@) 4 J The default layout out ofa 3Panel is __. (2) FlowLayout (b) GridLayout (©) Bordertayout (@) None 418, The defeult layout out of @ contentPane in a JFrame is _. (@) Flowtayout (b) GridLayout (©) BorderLayout (a) None 19. To create a JPanel of the BorderLayout, use 4 45. 16. (@) 3Panel p = new 3Panel() (b) JPanel p = new JPanel(BorderLayout()); (©) JPanel p = new JPanel(new BorderLayout()); (@) Janel p = new JPanel().setLayout(new BorderLayout()); 20. _ creates a color object. (@) new Color(0, 0, 0) (b) new Color(0, 266, 0) (©) new Color(255, 255, 255) (d) new Color(t, 2, 3) 21. To add a component ¢ to a JPanel p, use (@) p.adace) (b) p.getContentPane(<) ag, ©, Paste) (2) p.append(c) . The method sets the foreground color to yellow in JFrame f. (a) setForeground(Color. yellow) (©) f.setForeground(Color. YELLOW) (©) f.setForeground(Color. yellow) (@) setForeground(Color. YELLOW)of Advanced Jv Programing 1110 hv. Abt! denn ten an 23, Which color is the darkest? (a) new Color(0, 0, 0) (c)_new Color(20, 0, 0) 24. The method ___ sets the background color to yellow in JFrame f, (a)_ setBackground(Color. yellow) (b) f.setBackground(Color. YELLOW) (c) f.setBackground(Color. yellow) (d)_setBackground(Color. YELLOW) 25, The method ___ sets the font (Helvetica, 20-point bold) In component ¢. (a) c.setFont(new Font( "Helvetica", Font.bold, 20) (b) c.setFont(new Font( "helvetica", BOLD, 20)) (c)_c.setFont(Font(*Helvetica", Font.BOLD, 20)) (a) _c.setFont(new Font("Helvetica", Font.BOLD, 20)) 26. Can you use the setBackground method to set a back ground coor fo, (bnew Color(10, 0, 0) (a) new Color(30, 0, 0) (a) Component (b) Container (©) Component (a) 3Button 27. To specify a font to be bold and italic, use the font style value _ (2). Font-PLAIN (b) Font.BOLD (©) Font.ITALIC (d) Font.BOLD + Font-ITALIC 28. Can you use the setBorder method to set a border for_? (2) Component (b) Component. (c) JButton (d) JLabel 29. Can you use the getWidth method to get a width for_ (a) Component (b) Container (©) 3Component (d)3Button 30. You can use methods ____on any instance of java.awt.Component. (2) setBackground (b)_getBackground (©) getBorder (6) getHeight 31. Analyze the following code: import javax.swing.*; Public class Test extends JFrame ( PrivatedButtonjbtoK = new Jautton(#0K") ; Public static void main(String!] args) { // Create a frane and set its propertiessostio 32, 33, 7ning tn Abstract Wendowing Tok (AWN & Swings mmo aetTite ("Logic Error"); pefaultcloseop ame. EXIT_ON_CLOSE) ; sotVisible(true); oO public 7 peOK. set TOOLTEpText (*This 5 a button"); gda(new JButton (*OK")); ' ' (a) The too! tip text is displayed when you move the mouse on the button. (b) The tool tip text will be displayed if you replace add(new JButton(*OK")) with add(jbtOK). (c)_ The tool tip text will be displayed if you swap the two lines in the Test constructor. (@) The tool tip text will be displayed if you replace add(new JButton("OK")) with add(jbtOK = new JButton("OK")).. Can you use the setTooITip method to set a tool tip for (2) JLabel (b) Container (©) Component (d) Button Show the output of the following code? import javax.swing.*; Public class Test ( Public static void main(Stringl) args) ( JButtonjbtoK = new JButton ("OK"); System.out print (jbtOK.-isvisible() +") * JFrame frame = new gFrame() ; System.out.printin(frame.isVisible(}}; , (2) true, true (©) true, false ©) ‘false, true (a) false, false You can use methods ‘on any instance of java.at. Component. (2) setForeground (b) setBackground (©) setFont (d) setLayout1 sto Asie a pa Progemming 2120 Ae Nine Toh a Jig methods on the button jbt? a) ich of the folowing are val fo) pbesettnemoni("®) (b) jbt.setMnemonic(’A'y; (2) jpesettconTextGap(s0): (2) pt setTextGap(50); (ere mage eon fro file n \booK\mage\con, use {0 new imagelcon(:\book\image\con)i to) ew Imagetcon‘:\book\mageVcon’ {e)_ new Imagetcon(":\\pook\\nage\ eon") {5} new Imagetcon(c:\book\\image\\icon eo retnad. gets the text (or caption) ofthe button bt, (a) jpttext() (p) jot.getText() (0). btfindText() (¢) jbtretrieveText(), Which of the following Is true? (2) JButton inherits from javax.sw (b) You can create a JButton by speci (c) You can create a JButton by specifying a (4) You can create a JButton by a text. 1. Analyze the following code: import javax. swing. 7 import java.awt.*; public class Test extends JFrame ( ing. AbstractButton. ying an icon and text, in icon. public Test() ( InageTconusIcon Button jbe1 = new JButton(usteon) + Button jbt2 = new JButton(ustcon) ; lew Imagecon ("image/usTcon.gif"); gPanel pl = new Jeanel(); pl.add(3bt1); JPanel p2 = new JPanel (); p2.add (Jbt2); gPanel p3 = new JPanel (); p2.add (3bEL) 5 add(pl, BorderLayout NORTE) ; add(p2, BorderLayout .SOUTE) ; add(p3, BorderLayout .CENTER) ) Public static void main(String] args) ( 1/ Greate a frame and set its properties Gerame frame = new Test (); rane, setSize(200, 100); {rane tpatinteei tds ton (rcane.nerr_o¥ £1098)! } ,40. a. 2 4a. sa 0:40 Abarat Windowing Toot (AW) & Swings {a) Two buttons displayed with the same icon, b) Three buttons displayed with the same icon. {6)_ Only Jott displays the icon and jbt2 does not display the icon. {@) Two buttons displayed with different icons. ‘the method creates alconimage for file c\image\us.cif. (a) new Imagelcon("e:\image\us.gif); {b) new Icon(*c:\image\us.gi" {o)_new Imagelcon("c:\\image\\us.gif}; {@)_ new Icon("e:\\image\\us.gif; ‘The method specifies that the text is placed on the right of the icon in the button jbt. {a) jbt.setVerticalTextPosition(JButton.LEFT) (0) jbt-setHorizontalTextPosition(JButton. LEFT) (c) jbt-setHorizontalTextPosition(Button.RIGHT) () jbt setHorizontalAlignment(JButton.RIGHT) ‘The method ‘specifies that the text and icon are horizontally aligned to the right in the button jb. (@) jpt.setVerticalTextPosition(JButton LEFT) () bt.setHorizontalTextPosition(JButton.LEFT) {¢)_jpt.setHorizontarTextPosition( Button. RIGHT) {(@) JotsetHorizontalalignment(JButton. RIGHT) ‘Analyze the following code: Inport javax.swing.*7 import java.awt-*7 public class Test extends JFrame { public Test () ( setLayout (new FlowLayout ())7 add(new Button ("Java") add (new Button (*Java")) 7 add(new gButton ("Java") 5 ada(new JButton("Java")) 7 , public static void main(stringl) args) | 11 Create a frame and set ies properties JFrane frame = new Test (0 frame. setSize(200, 100); frame. getDefaultCloseoperation (JFrame. EXIT_ON_CLOSE) ; frane.setVieible (true) : yae jazz intro. to Abatract Windowing Toot (AT a 44, 4s. (2). One button is displayed with the text "Java (b) Two buttons are displayed with the same text “Jova". (€)_ Three buttons are displayed with the same text "Java". (4) Four buttons are displayed with the same text "Java". _____ checks whether the JCheckBoxjchk is selected. (a) jchk.getSelected() (b) jchk.selected() (c) jchk.isSelected(). (d)_jehk.select() Analyze the following code: import javax. swing. *7 import javax.swing-border.* Amport java-awt.*7 public class Test extends JFrame { public Test () ( Border border = new TitledBorder("My button"); Button jbl = new JButton(*0K"); Button jbt2 ~ new JButton ("Cancel"); Jott .setBorder (border) + jbt2.setBorder (border) ; add (jbt1, BorderLayout NORTH) ; ada (jbt2, BorderLayout SOUTH) ; public static void main(string() args) ( Frame frame = new Test (); frane.setSize(200, 100); frame. setDefaultClosedperat ion (JPrane.EXIT_ON_CLOSE) ; Frame.setVieible(true) (a) Two buttons displayed with the same border, (b) Two buttons displayed, but only one button has the bord: (©) The program has a co mpile error use 7 TiledBorder("My button to variable of the wenn tine sient 1e Border type. (@) The program has a runtime error button. Tor because you cannot set a border 0” #«Progaming 3 post vii of Wai ou can create a9 istance of BuKoNGroup and ad rd Instance to group the buttons, ip) ButtonGrouP can be added to» container. (oTocheck whether a radio button jr is selected, use istered) (6) By default, when a radio button is created, the radio butter © noe selected. whieh ofthe following statements are true? (a) 2CheckBox inherits from Javax.swing.AbstractBtton, {uy Allthe methods in JCheckBox are also in 3Button {@) You can set a mnemonic for a ICheckBox, {@) You can use an icon on JCheckBox. wich ofthe fllotng statements are true? (a) RadioButton inherits from javax. swing. AbstractButton, (0) Allthe methods in JRadioBultton are also in 3Button, (©) You can set a mnemonic fr a ICheckBiox (@) You can use an icon on IRadioButon, 4, The method __ gets the text (or caption) ofthe labet jb following statements are true? 4. ”. 48 (2) jtb.text() (b) jlbl.getText() (0) jlbLrindText() (2) jlbl retrieveText() 50. Which of the following are valid methods on the label jbl? (2) jibl.setMnemonic("A"); _(b)_jlbl.setMnemonic(‘A’); (©) Sibl.seticonTextap(50); (4) jIbl.setTextGap(50); 51, Which of the following statements are true? (@) All the methods in. ‘JLabel are inherited from Javax.swing.AbstractButton. (®) You can set a mnemonic key in a JLabel (©) You can create a label with both text and icon. (©) You can create a label with an icon. The method assigns the name Result to the Text of variable jlbl. (2) jibi.setText(*Result") (b)_jibl.newText("Result") (©) jibl.text("Result") (d)_jibl.findText() The method specifies that the text and icon are horizontally aligned to the right in the label jlbl. (2) sib setverticarrgxtPosition(3Button.LEFT) (©) jIbl setHorizontalTextPosition (Button. LEFT) (©) bl setHorizentarTextPosition(JButton.RIGHT) ) Jbl setHorizontalAlignment(JButton.RIGHT) 8, 83,324 Intro. to Abstract Windowing Tootkit ( -svance Java Progaming 8 54, The method specifies that the text is placed on the right of the jan in the label jlbl. (@) sib.setVerticarTextPosition(JButton-LEFT) (p) jibl setHorizontalTextPosition(JButton.LEFT) (c) ib.setHorizontalTextPosition(JButton.RIGHT) (@) jibl setHorizontalAlignment( Button-RIGHT) 55. Which of the following statements are true? (a) You can specify a horizontal text alignment in a text field (b) You can specify the number of columns in a text field. () You can disable editing on a text field. (¢) You can create a text field with a specified text. 56. ___can be used to enter or display a string. (a) Alabel (b) A button (c) Acheck box (d) texfield 57. The method ___gets the contents of the text field jtf. (a) jtf.getText(s) (b)_jtf.getText() (c)_ jtf.getString() (d)_jtf.findString() in ac Answers F )— 3. (a,b) 4. (a) 5.(4) La@ 8..(b) 9.(2) 10.(2) rer 13.4 | 14. (a,b) | _15.(0) | [a] —18.(a) | 19.) | 20. (a,c,8) | 26. (,b,c,¢) | | 24. (bc) | 25.6) — {—_29.(¢)__|_30.(2,bd)_— 34. (a,b,c) | 35. (b) — | 40. — | 45. (2) [ so. (¢) — (ss. (a,b,6.8)-
You might also like
Ajava MCQ
PDF
No ratings yet
Ajava MCQ
386 pages
Chapter 12 - GUI
PDF
No ratings yet
Chapter 12 - GUI
90 pages
UNIT 01 - Abstract Windowing Toolkit (AWT)
PDF
No ratings yet
UNIT 01 - Abstract Windowing Toolkit (AWT)
12 pages
UNIT 01 - Abstract Windowing Toolkit (AWT)
PDF
No ratings yet
UNIT 01 - Abstract Windowing Toolkit (AWT)
55 pages
TY COMP Sem V AJP 22517 MCQs Bank
PDF
No ratings yet
TY COMP Sem V AJP 22517 MCQs Bank
70 pages
Java - 1 AWT
PDF
No ratings yet
Java - 1 AWT
31 pages
AJP MCQ Bank 1ALLCH
PDF
No ratings yet
AJP MCQ Bank 1ALLCH
58 pages
5.1 Java Swing
PDF
100% (2)
5.1 Java Swing
139 pages
Unit 2 UI
PDF
No ratings yet
Unit 2 UI
102 pages
ALL Chapters
PDF
No ratings yet
ALL Chapters
83 pages
AJP MCQ Bank PDF First Zeal College
PDF
No ratings yet
AJP MCQ Bank PDF First Zeal College
58 pages
Ajp MCQ
PDF
No ratings yet
Ajp MCQ
35 pages
Java Study Material Unit V April - May 2025
PDF
No ratings yet
Java Study Material Unit V April - May 2025
16 pages
JPR Assignments 4-5-6
PDF
No ratings yet
JPR Assignments 4-5-6
86 pages
CHAPTER 1 and 2
PDF
No ratings yet
CHAPTER 1 and 2
11 pages
Chapter-7 - Swing and GUI
PDF
No ratings yet
Chapter-7 - Swing and GUI
35 pages
Awt and Swing
PDF
No ratings yet
Awt and Swing
22 pages
UNIT I Test
PDF
No ratings yet
UNIT I Test
13 pages
Java Swing and Awt
PDF
No ratings yet
Java Swing and Awt
99 pages
TY COMP Sem V AJP 22517 MCQs Bank 2 20
PDF
No ratings yet
TY COMP Sem V AJP 22517 MCQs Bank 2 20
19 pages
Unit 1 Question Bank
PDF
No ratings yet
Unit 1 Question Bank
13 pages
OOP II Chapter Two JUI-Swing Part I
PDF
No ratings yet
OOP II Chapter Two JUI-Swing Part I
69 pages
Swings
PDF
No ratings yet
Swings
33 pages
Java Test
PDF
No ratings yet
Java Test
18 pages
AWT and Swing
PDF
No ratings yet
AWT and Swing
50 pages
Assignment Solution 9
PDF
No ratings yet
Assignment Solution 9
10 pages
Swings and Layout Managers
PDF
No ratings yet
Swings and Layout Managers
23 pages
Ty Comp Sem V Ajp 22517 Mcqs Bank
PDF
100% (1)
Ty Comp Sem V Ajp 22517 Mcqs Bank
59 pages
JAVA Unit 5
PDF
No ratings yet
JAVA Unit 5
106 pages
Question Bank AJP
PDF
No ratings yet
Question Bank AJP
7 pages
Final Java2
PDF
No ratings yet
Final Java2
6 pages
Swinging Into Swing: Leo S. Primero III
PDF
No ratings yet
Swinging Into Swing: Leo S. Primero III
40 pages
Javax - Swing: 1. The Swing User Interface
PDF
No ratings yet
Javax - Swing: 1. The Swing User Interface
85 pages
MCQ-part 2
PDF
No ratings yet
MCQ-part 2
4 pages
AJP Question Bank Class Test 1 Jan 2020
PDF
No ratings yet
AJP Question Bank Class Test 1 Jan 2020
10 pages
Swing Components New
PDF
No ratings yet
Swing Components New
81 pages
AJP Practice Question
PDF
No ratings yet
AJP Practice Question
10 pages
jhtp9 25 GUI2
PDF
No ratings yet
jhtp9 25 GUI2
4 pages
Chapter 1
PDF
No ratings yet
Chapter 1
32 pages
Unit 1 Part1
PDF
No ratings yet
Unit 1 Part1
22 pages
Chapter 12 Q
PDF
No ratings yet
Chapter 12 Q
11 pages
Swing Java
PDF
No ratings yet
Swing Java
34 pages
Chapter02 Swing
PDF
No ratings yet
Chapter02 Swing
36 pages
Swing, Layout Managers
PDF
100% (1)
Swing, Layout Managers
11 pages
Java Gui Study Guide
PDF
100% (2)
Java Gui Study Guide
18 pages
ICS 2201 GUI Lab
PDF
No ratings yet
ICS 2201 GUI Lab
35 pages
CHAPTER 6 GUI and Event Handling
PDF
No ratings yet
CHAPTER 6 GUI and Event Handling
68 pages
GUI Basics
PDF
No ratings yet
GUI Basics
43 pages
SSC GD
PDF
No ratings yet
SSC GD
20 pages
Unit Ii
PDF
No ratings yet
Unit Ii
34 pages
Chapter 13 GUI Basics: Answer: True
PDF
No ratings yet
Chapter 13 GUI Basics: Answer: True
3 pages
CHPTR 3
PDF
No ratings yet
CHPTR 3
63 pages
12review (GUIBasics)
PDF
No ratings yet
12review (GUIBasics)
4 pages
Java Swing
PDF
No ratings yet
Java Swing
18 pages
TCSS 143, Autumn 2004 Lecture Notes: Graphical User Interfaces Koffman/Wolfgang Appendix C, Pp. 747-786
PDF
No ratings yet
TCSS 143, Autumn 2004 Lecture Notes: Graphical User Interfaces Koffman/Wolfgang Appendix C, Pp. 747-786
41 pages
Oops Co3
PDF
No ratings yet
Oops Co3
14 pages
Chapter 12 GUI Basics Abstract Classes," in Chapter 10
PDF
No ratings yet
Chapter 12 GUI Basics Abstract Classes," in Chapter 10
37 pages
MCOs On 1st
PDF
No ratings yet
MCOs On 1st
16 pages
AJP Question Bank
PDF
No ratings yet
AJP Question Bank
10 pages