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)
38 views
CHAPTER 1 and 2
663
Uploaded by
poteshantanu1
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 now
Download
Save CHAPTER 1 and 2 For Later
Download
Save
Save CHAPTER 1 and 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
38 views
CHAPTER 1 and 2
663
Uploaded by
poteshantanu1
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 now
Download
Save CHAPTER 1 and 2 For Later
Carousel Previous
Carousel Next
Save
Save CHAPTER 1 and 2 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
ee: 22. With the help of diagram describe MVC architecture. tn 1. Which of the following statements are true? (a) To distinguish new Swing componé counterparts, Swing GUI component classes are named with a prefix . (b) All Swing GUI components are lightweight. (©) A user interface object such as (button, container. (d) A container such as JFrame Is also a component. 2. Which of the following statements about GUI components is wrong ? (a) 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 3. 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 4. 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 components ent classes from their AWT list) can appear in one ianced wen ing 1115 no. toAbatt Toot 5. What is best to describe the relationship between JComponent and JButton? (2) Association (b) Agaregation (©) Composition (@) Inheritance 6. Which component cannot be added to a container? (2) JPanel (b) 3Button (©) 3Frame (4) 3Component 7. Analyze the following code, import java.awt.*; import javax. swing. *; public class Test ( public static void main(String!) args) { Component ¢ = new gButton ("OK") ; JFrane frame = new JFrame ("My Frame"); Frame .add(c); frame, setDefaultCloseoperat ion (JFrame .EXIT_ON_CLOSE) ; frame. setVisible (true); 1 ) (2) You cannot assign @ JButton to a variable of java.awt.Component. (b) You can only add c to a container because c’s type is Component. (©) You cannot add a Swing component directly to a JFrame using add(c) prior to JDK 1.4, but it is OK in JDK 1.5. (2) You cannot create a JFrame using new JFrame("My Frame"). Analyze the following code. import java.awe.*; import javax.swing Public class Test { Public static void main(Steingl] args) { JFrame frame = new JPrame(*My Frame"); frame. add (new JButton(*OK")); frame. add (new JButton ("Cancel ")) ; frame. setDefaultCloseOperat ion (JFrame .EXI7_ON_CLOSE) ; 10(200, 200); Frone. setVisible (true); 'Advanced Java Programing _ (a) Only button Ok is displayed. (b) Only button Cancel is displayed. putton OK is {e)_ Both button OK and button Cancel are displayed 2°4 dispayed onthe le sie of button OF ag putin OK I (@) Both button OK and button Cancel are dls displayed on the right side of button OK: 9. How many frames are displayed? import javex-swing.*7 public class Test ( public static void main(string{] args) grrane £1 = new JFrame ("ty Frame")? Srrane £2 = 611 Jrrane £2 = £27 1 setvisiblecerue) e2.setvistble(teve) i 63. setvisiblecerve) | ' @1 2 (3 @ 0 Which ofthe following statements is for placing the frame's upper left c to (200, 100)? | (2) frame.setLocation(100, 100) | (©) frame.setLocation(100, 200) (©) frame.settocation(200, 100) | (@) frame.setLocation(200, 200) 111, What should you use to position a Button within an application Frame so that the size of the Button is NOT affected by tne Frame size? | (2) FlowLayout (&) a Gridtayout (c) the center area of a BorderLayout (a) the East or West area of a BorderLayout 12, What layout manager should you use so that every component occupies the same site in the container? (2) FlowLayout (b) a Gridtayout (©) a Bordertayout (6) any layout 10, sornerraced iva Programming snr 13, 14 15, 16. 17. 18, 19, 20. ai. 22, ro. to Abstract Wndowing Toot (AWT) & Swings Suppose 2 JFrame uses the GridLayout(2, 0). If you add six buttons to the frame, how many columns are displayed? (@) 1 () 2 © 3 4 To set a FlowLayout in panel jp, you can use the method (2) jp.setLayout(new FlowLayout()); te (©) jp.setLayout(new FlowLayout(FiowLayout.CENTER)); (€)_p.setLayout(new FlowLayout(Fiowtayout.center)); (6) spssettayout(FlowLayout()); Suppose a Frame uses the GridLayout(0, 2). If you add six buttons to the frame, how many columns are displayed? @ 1 (®) 2 © 3 a 4 Suppose a JFrame uses the GridLayout(2, 2). If you add six buttons to the frame, how many columns are displayed? (1 (b) 2 3 @ 4 ‘The default layout out of a JPanel is__. (2) FlowLayout (b) GridLayout (©) BorderLayout (d) None The default layout out of a contentPane in a JFrame is (2) FlowLayout (b) Gridtayout (©) BorderLayout (d)_ None To create a JPanel of the BorderLayout, use (a) JPanel p = new 3Panel() (6) JPanel p = new 3Panel(BorderLayout()); (©). JPanel p = new 3Panel(new BorderLayout()); (4) 3Panel p = new 3Panel().setLayout(new BorderLayout()); creates a color object. (@) new Coler(0, 0, 0) (©) new Color(0, 266, 0) (©) new Color(255, 255, 255) (d) new Color(1, 2, 3) To add a component c to a JPanel p, use ___. (2) p.add(c) (b)_p.getContentPane(c) (©) painsert(c) (d)_pappend(c) The method sets the foreground color to yellow in JFrame f. (2) setForeground(Color. yellow) (b)_f.setForeground(Color. YELLOW) (©) f-setForeground(Color.yellow) (d)_setForeground(Color. YELLOW)Ol Advance ov Propenming 1118 no. Abract windowing Togo # ne 23. Which color isthe darkest? {a)_new Color(0, 0, 0) (b)_new Color(10, 0, 0) (€)_ new Color(20, 0, 0) {d) new Color(30, 0, 0) 24. The method ses the background color to yellow in JFrame 25. 26. 27. 28. 29. 30. 31 (a)_ setBackground(Color.yellow) (b)_f.setBackground(Cotor. YELLOW) (©) f.setBackground(Color. yellow) (d)_ setBackground(Color.YELLOW) The method __sets the font (Helvetica, 20-point bold) in component (2) c.setFont(new Font("Helvetica", Font.bold, 20)) (b) c.setFont(new Font(*helvetica’, BOLD, 20)) (©) csetFont(Font( "Helvetica", Font.BOLD, 20)) (4) c.setFont(new Font(*Helvetica", Font.BOLD, 20)) Can you use the setBackground method to set a back ground color for ? (2) Component (b) Container (©) 3Component (@) Button To specify 8 font to be bold and italic, use the font style value (a) Font.PLAIN (b) Font.BOLD (©) Font. TALIC (4) Font.BOLD + Font.1TALIC Can you use the setBorder method to set a border for __? (2) Component (b) 3Component (©). 3Button (4) Label Can you use the getWidth method to get a width for __ (2) Component (b) Container (©) 3Component (4) 3Button You can use methods _ (a) setBackground (©) getBorder Analyze the following code: Anport javax.ewing.*; On any instance of java.awt.Component. (b) getBackground (d) getHeight Public class Test extends JFrame ( PrivateJButtonjbtoK = new JButton( "OK"; Public static Void main(String!) args) | // Create a frame and set ita properties32 33, 34. ‘Abstract Windowing Toot (AWT) & Swings JPrame frame = now Test (); frame Error’); frame-setSize(200, 100); frame. setDefaultCloseoperat ton (JFrame .EXIT_ON_CLOSE) ; frame.setVisible(true); public Test() JBUOK, sotToolTipText (*Thia is @ button"); add {new sBueton ("0K") ); 1 1 (2) The tool tip text is displayed when you move the mouse on the button, (b) The too! tip text will be displayed if you replace add(new JButton("OK")) with add (jbtOK). (©) The too! tip text will be displayed if you swap the two lines in the Test constructor. (2) The tool tip text will be displayed if you replace add(new JButton(*OK")) with add(sbtOK = new JButton("OK")), Can you use the setTooITip method to set a tool tip for__? (2) JLabel (b) Container (©) 3Component (@) 3Button Show the output of the following code? importjavax.swing.*; Public class Test ( Public static void main(string() args) { JButtonjbeok = new JButton ("OK") + Systom.out.print (jbtok-isVisible() +", "7 JFrame frame = new JFrame(): Systom.out .printin(frame, isVisible()); , 1 (2) true, true (b) true, false (c) false, true (4) false, false You can use methods fon any instance of java.awt.Component. (2) setForeground (b) setBackground (©) setFont (4) setLayout35, 36. 37. 38. 39. Which of the following are valid methods on the button Jbt? (a) _jbt.setMnemonic("A" (b)_sot.setMnemonic(’A’?i (c) jbtsetlconTextGap(50); (d) jbt.setTextGap(50)' To create an image icon for a file in c:\book\image\icon, US ——~ (a) new Imagelcon("c:\book\image\icon"); (b) new Imagelcon('c:\book\image\icon’); {@) new imagelcon(‘e\Book\Wmage\on: (@)__new Imagetcon(‘c:\\book\\image\\ieon'y: Smemet gts he text (or opin) afte Dtion OE (2) sbt.text() (b) jot-getText() (©)_jbtfindText() (d)_jbtretrieveText(): Which of the following is true? (a) 3Button inherits from javax.swing.AbstractButton (b) You can create a JButton by specifying an icon and text. (©) You can create a JButton by specifying an Icon. (d) You can create a JButton by 2 text. ‘Analyze the following code: import javax.ewing.*7 public class Test extends JFrame ( public Test() | imagelconusicon = new InageTcon(*image/ustcon.gif"); Button jbti = new JButton(usTcon) ; Button jbt2 new JButton(ustcon) ; apanel pl = new JPanel); pl.add(jbt1); gpanel p2 = new JPanel); p2.add(3bt2); JPanel p3 = new JPanel( p2.add(jbe) ; add(pl, BorderLayout .NORTH) ; add(p2, BorderLayout .SOUTH) ; add(p3, BorderLayout .CENTER) ; ) public static void main(stringl] args) ( Create @ frame and set its properties rane = new Test(); frane.setsize(200, 100); JFrare DefaultCloseoperat ion (JFrame.£XIT_ON_CLOSE) ; sible(true) ;44 42. 43, ——__ Sie eee eseery teen NT at (2) Two buttons displayed with the same icon (6) Three buttons displayed with the same icon (c) Only jbti displays the icon and jbt2 does not display the icon. (a) Two buttons displayed with diferent icons. The method ___ creates alconmage for file c:\image\us.ait- (2) new Imagetcon("e:\image\us.gi"); (b) new Icon("e:\image\us.cit"); {)_ new Imagetcon("e:\\image\\us.gi); (d)_ new Icon("e:\\image\\us.sif); The method specifies that the text is placed on the right ofthe icon in the button jbt. (a) jbt.setVerticalTextPosition(JButton.LEFT) (b) jbt.setHorizontalTextPosition(JButton.LEFT) (c)_ jbt.setHorizontalTextPosition(JButton. RIGHT) (d)_ jbt.setHorizontalAlignment(JButton.RIGHT) ‘The method specifies that the text and icon are horizontally aligned to the right in the button jot (2) jb. setVerticalTextPositon(JButton.LEFT) (b) jbt.setHorizontalTextPosition(JButton.LEFT) (c) jbt.setHorizontalTextPosition(JButton.RIGHT) (d)_jbt.setHorizontalAlignment(JButton.RIGHT) Analyze the following code: import javax.swing.*7 public close Test extends JFrame ¢ public Test () 1 Setlayout (new FlowLayout (01 aad (new sBucton (*Java") 1; dad (new easton ("ava") 9; add (new Botton ("Sava"); add (new Button ("ava"); ) public static void main(stringl] args) { 1/ Create a frane and set its properties new Test (7 Frame frane frame. setGize(200, 100); frame, setDefaultCloseoperat ion (JErame.EXTT_ON CLOSE); frame. setvisible(true)ee an ave) 8 Sg ‘Aavanced Java Programming 1.122 Intro to Abstract Windowing TOW 44 4s. (a) One button Is displayed with the text "Java", (b) Two buttons are displayed with the same text "Java" (©) 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) jehk.selected() (©) jchk.isSelected{). (d)_jehk.select() Analyze the following code: import javax.awing. import javax.ewing-border.*3 import java.awt.*7 public class Test extends JFrame ( public Test) Border border = new Titledsorder( uy burton"); ‘Button feel = new JButton ("OK") 7 Button jBe2 = new JButton ("cancel"); bt) -setBorder (border) bt 2.setBorder (border) + add(jbt, BorderLayout .NORTH) ; add(jbt2, BorderLayout .SOUTH) ; public static vold main(Stringl] args) { oPrame frame = new Test (); frame.setsize(200, 100); frame. setDefaul tCloseoperat ion (JFrame. EXIT_ON_CLOSE) ; frame. setVisible(true) ; 1 (a) Two buttons displayed with the same border. {b) Two buttons displayed, but only one button has the border. (©) The program has a compile error because you assign new TitledBorder("My button") to a variable of the Border type. (@) The program has 9 runtime eror because you canna st a border on 2 ton.[Advanced Java Programming 1128 __tro. to Abataet Windowing Took (AW) & Swi 46, Which of the following statements are true? (2) You can create an instance of ButtonGroup and add radio button to the instance to group the buttons, (b) ButtonGroup can be added to a container, (c)_ To check whether a radio button jrb is selected, use jrb.isSelected(). (2) By default, when a radio button is created, the radio button is not selected, 47. Which of the following statements are true? (2) 3CheckBox inherits from javax.swing.AbstractButton. (b) All the methods in JCheckBox are also in JButton. (©) You can set a mnemonic for a JCheckBox. (A) You can use an icon on 3CheckBox. 48, Which of the following statements are true? (2) JRadioButton inherits from javax.swing.AbstractButton (b) All the methods in JRadioButton are also in Button, (©) You can set a mnemonic for a JCheckBox. (0) You can use an icon on JRadioButton. 49. The method gets the text (or caption) of the label jib (2) jibi.text() (©) tbl getText) (©) J.finaText() (A) jlbl-retrieverext(). 50. Which of the following are valid methods on the label jb? (2) jbl. setMnemonic("A\ (b) jibl.setMinemonie(’A’); (©) ibi.seticonTextap(s0); (A) lbl.setTextGap(50); 51. Which of the following statements are true? (2) All the — methods in SLabel_- are inherited from Javax.swing.AbstractButton, (b) You can set a mnemonic key in a JLabel. (©) You can create a label with both text and icon. (A) You can create a label with an icon 52, The method ____ assigns the name Result to the Text of variable jib. (2) jbl setText(*Result”) (b) lbl.newText(*Result") (6) bl.text(*Result”) (a) jbl.findText() 53, The method specifies that the text and icon are horizontally aligned to the right in the label jib (2) jlbl.setverticalTgxtPosition( Button. LEFT) (0) jlbl.setHorizontalTextPosition(JButton. LEFT) (©) jbl setHorizontatTextPosition(JButton.RIGHT) (4) Ibi setHorizontalAlignment(JButton RIGHT)‘Advance Java Programming 128 tata tn Won Toot 54, The method _specfles thatthe text is placed on the roht of he ko the label i. (2) sib.setverticatTextPosition( Button. LEFT) (©) sibl.setHorizontalTextPesition(JButton. LEFT) (©) bl setHorizontalTextPosition(JButton.RIGHT) (4) jb setHorizontalalignment( Button. RIGHT) 55. Which ofthe following statements are true? (2) You can specity a horizontal text alignment in a text fled. (©) You can specify the number of columns in a text field, (© You can disable editing on a textfield. (@) You can create a text feld with a specified text. 56, can be used to enter or display a string. @) Alabel (6) A button (6) A check box (4) texfild 57. The method __gets the contents ofthe text field jf. () itt gettexts) (0) itt-getten() (©) itfgetString() (@) st6findstring() = Answers = 4. (@.c.d) 2.(@) 3. (3,0) 4. (2) 5.10 6.0) 7.10) 8.(b) 9.2) 10.(¢ 11. (2) 12. (6) 13. (¢) 14. (2,0) 15. (b) 16. (c) 17.0) 18. (a) 19. (c) |" 20. (ae) 21. (a) 22. (b.) 23. (a) 24. (bic) 25. () 26.(a,be8) | 27.(4) | 28. (b,c,4) 29. (e)__| 30. (aod) 31.6) 32.(ac,d) | 33. (b) 34.(2,b.) | 35. (b,c) 36. (c) 37.(b) 38. (b) 39, (a) 40.(€) 41. (0 42.(4) 43. (4) 44.(¢) 45.(0) | |46.a.c4) | 47.(ab<.0 | 48. (a,0,e.4) | 49. (by 50.(¢_| 51. (cd) 52. (2) 53. (4) 54.(c) | 55. (a,b.c) | s6.@ 57.(0) | ol
You might also like
Java Gui Study Guide
PDF
100% (2)
Java Gui Study Guide
18 pages
AJP Chapter 1
PDF
No ratings yet
AJP Chapter 1
11 pages
MCQ-part 2
PDF
No ratings yet
MCQ-part 2
4 pages
12review (GUIBasics)
PDF
No ratings yet
12review (GUIBasics)
4 pages
AJP Practice Question
PDF
No ratings yet
AJP Practice Question
10 pages
Chapter 13 GUI Basics: Answer: True
PDF
No ratings yet
Chapter 13 GUI Basics: Answer: True
3 pages
Swings and Layout Managers
PDF
No ratings yet
Swings and Layout Managers
23 pages
AJP Question Bank Class Test 1 Jan 2020
PDF
No ratings yet
AJP Question Bank Class Test 1 Jan 2020
10 pages
AJP Question Bank
PDF
No ratings yet
AJP Question Bank
10 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 01 – Abstract Windowing Toolkit (AWT)
PDF
No ratings yet
UNIT 01 – Abstract Windowing Toolkit (AWT)
12 pages
Sheet1 Stud
PDF
No ratings yet
Sheet1 Stud
5 pages
Unit-2-UI
PDF
No ratings yet
Unit-2-UI
102 pages
Final Java2
PDF
No ratings yet
Final Java2
6 pages
Oops Co3
PDF
No ratings yet
Oops Co3
14 pages
JAVA Unit 5
PDF
No ratings yet
JAVA Unit 5
106 pages
TY COMP Sem V AJP 22517 MCQs Bank
PDF
No ratings yet
TY COMP Sem V AJP 22517 MCQs Bank
70 pages
AJP MCQ Bank 1ALLCH
PDF
No ratings yet
AJP MCQ Bank 1ALLCH
58 pages
Ty Comp Sem V Ajp 22517 Mcqs Bank
PDF
100% (1)
Ty Comp Sem V Ajp 22517 Mcqs Bank
59 pages
ajp mcq
PDF
No ratings yet
ajp mcq
35 pages
UNIT 01 - Abstract Windowing Toolkit (AWT)
PDF
No ratings yet
UNIT 01 - Abstract Windowing Toolkit (AWT)
55 pages
CHAPTER 6 GUI and Event Handling
PDF
No ratings yet
CHAPTER 6 GUI and Event Handling
68 pages
TCC102 Unit3 Tutorial3
PDF
No ratings yet
TCC102 Unit3 Tutorial3
47 pages
OOP II Chapter Two JUI-Swing Part I
PDF
No ratings yet
OOP II Chapter Two JUI-Swing Part I
69 pages
AJAVA_MCQ
PDF
No ratings yet
AJAVA_MCQ
386 pages
PPT06 - Basic GUI
PDF
No ratings yet
PPT06 - Basic GUI
24 pages
AJP MCQ Bank PDF First Zeal College
PDF
No ratings yet
AJP MCQ Bank PDF First Zeal College
58 pages
Swings
PDF
No ratings yet
Swings
33 pages
Java Test
PDF
No ratings yet
Java Test
18 pages
02 Swing
PDF
No ratings yet
02 Swing
11 pages
MCOs On 1st
PDF
No ratings yet
MCOs On 1st
16 pages
Java Swing
PDF
No ratings yet
Java Swing
18 pages
Assignment Chapter 1MCQ
PDF
No ratings yet
Assignment Chapter 1MCQ
10 pages
IT-PF-01-UNIT-8-1
PDF
No ratings yet
IT-PF-01-UNIT-8-1
33 pages
Building Java Programs: Graphical User Interfaces
PDF
No ratings yet
Building Java Programs: Graphical User Interfaces
116 pages
JPR Assignments 4-5-6
PDF
No ratings yet
JPR Assignments 4-5-6
86 pages
Week 7 - GUI 1
PDF
No ratings yet
Week 7 - GUI 1
20 pages
AWT and Swing
PDF
No ratings yet
AWT and Swing
50 pages
Unit I
PDF
No ratings yet
Unit I
4 pages
AJP Unit-I ByOmiii
PDF
No ratings yet
AJP Unit-I ByOmiii
4 pages
Ajp Question Bank
PDF
No ratings yet
Ajp Question Bank
6 pages
Ajp Question MCQ
PDF
No ratings yet
Ajp Question MCQ
16 pages
UNIT 1 QUESTION BANK
PDF
No ratings yet
UNIT 1 QUESTION BANK
13 pages
Assignment Solution 9
PDF
No ratings yet
Assignment Solution 9
10 pages
Javax - Swing: 1. The Swing User Interface
PDF
No ratings yet
Javax - Swing: 1. The Swing User Interface
85 pages
OOPR212_PrelimsReviewer
PDF
No ratings yet
OOPR212_PrelimsReviewer
6 pages
jhtp9 25 GUI2
PDF
No ratings yet
jhtp9 25 GUI2
4 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
ICS 2201 GUI Lab
PDF
No ratings yet
ICS 2201 GUI Lab
35 pages
UNIT V JAVA
PDF
No ratings yet
UNIT V JAVA
5 pages
UNIT I Test
PDF
No ratings yet
UNIT I Test
13 pages
Java Exam Study Guide
PDF
100% (1)
Java Exam Study Guide
16 pages
Unit 3 GUI Concepts
PDF
No ratings yet
Unit 3 GUI Concepts
37 pages
MCQ Ajp Imp
PDF
No ratings yet
MCQ Ajp Imp
7 pages
Java - 1 AWT
PDF
No ratings yet
Java - 1 AWT
31 pages
ajp chp 1
PDF
No ratings yet
ajp chp 1
62 pages
01 Awt
PDF
No ratings yet
01 Awt
23 pages
Chapter 1
PDF
No ratings yet
Chapter 1
32 pages
GUI Event Handling
PDF
No ratings yet
GUI Event Handling
45 pages