Chapter 1 Abstract Windowing Toolkit PDF
Document Details

Uploaded by LustrousAmethyst7528
Tags
Summary
This document is a past paper containing questions and answers related to fundamental concepts in Java Abstract Window Toolkit (AWT). The quiz covers topics such as inner classes, events, containers, and layout managers.
Full Transcript
Chapter 1 Abstract Windowing Toolkit Each Question carries 1 Marks Q1. ________ is a subclass of ComponentEvent. A) InputEvent B) ContainerEvent C) TextEvent D) WindowEvent Q2. Which of these is a superclass of all Adapter classes? A) Applet B) Component...
Chapter 1 Abstract Windowing Toolkit Each Question carries 1 Marks Q1. ________ is a subclass of ComponentEvent. A) InputEvent B) ContainerEvent C) TextEvent D) WindowEvent Q2. Which of these is a superclass of all Adapter classes? A) Applet B) ComponentEvent C) Event D) InputEvent Q3. Adapter class can be also used for incorporating property of JAVA. A) Inheritance B) Polymorphism C) Encapsulation D) All of the above Q4. In Adapter class it is sufficient to include only the methods required to override. A) True B) False C) Sometimes D) Never Q5. ______ is a superclass of ContainerEvent. A) ComponentEvent B) WindowEvent C) InputEvent D) MouseMotionEvent Q6. Commonly used methods of CardLayout class are A) public void next(Container parent) B) public void previous(Container parent) C) public voidfirst(Container parent) D) all the above Q7. Java allows a programmer to write a class within another class,is called as. A) Abstract Class B) Inner Class C) Derived Class D) Simple Class Q8. What are the different types of inner classes ? A) Local B) Anonymous C) Both A & B D) None Q9. What is the return type of isTemporary( ) method? A) int B) Long C) String D) Boolean Q10. The abstract class is a subclass of ComponentEvent and is the superclass for component input events. A) FocusEvent B) InputEvent C) WindowEvent D) TextEvent Q11. Inner class can access all the members of outer class including data members and methods. A) Private B) Public C) Protected D) Static Q12. _______ can be achieved by using Inner Class. A) Code Extension B) Code Inheritance C) Code Optimization D) Code Development Q13. is a class which is declared inside the class or interface. A) Inner Class B) Inherited Class C) Nested Interfaces D) Static Class Q14. The method returns a reference to the component that was added to or removed fromthe container. A) getParent( ) B) get( ) C) getTime( ) D) getChild( ) Q15. Which event is generates when checkable menu item is selected or deselected? A) ActionEvent B) InputEvent C) ItemEvent D) TextEvent Q16. If you compile a file containing inner class how many.class files are created ? A) 1 B) 4 C) 3 D) 2 Q17. When a component is added to and removed from a container, event generates. A) ComponentEvent B) WindowEvent C) FrameEvent D) ContainerEvent Q18. Since Nested class is a member of its enclosing class Outer, you can use notationto access Nested class and its members. A) ->(arrow) B).(dot) C) * (asterisk) D) &(ampersand) Q19. Inner classes provides ________ mechanism in Java. A) Safety B) Protection C) Security D) Risk Handling Q20. The non-static nested classes are also known as. A) event class B) class C) adapter classes D) inner classes Q21. Inner class mainly used for. A) for Code Optimization B) to access all the members C) to develop more readable and maintainablecode D) all of these Q22. Can outer Java classes access inner class private members? A) No B) Sometimes C) Yes D) Never Q23. In the following code, what is the name of the inner class? public class Periodical { long ISBN; public class Book { public long getISBN() { retrun ISBN; } } } A) getISBN B) Periodical C) ISBN D) Book Q24. Which is the container that does not contain title bar and MenuBars but it can have othercomponents like button, textfield etc? A) Window B) Menu bar C) Panel D) Output Screen Q25. What is used to store partial data results, as well as to perform dynamic linking, return values formethods, and dispatch exceptions? A) Window B) Button C) Container D) Frame Q26. Which class is used for processActionEvent( ) Processing Method ? A) JButton,JList,JMenuItem B) JButton Only C) JScrollbar D) None of the above Q27. a) It is lightweight. b) It supports pluggable look and feel. c) It follows MVC (Model ViewController) architecture Above advantages are of A) Swing B) AWT C) Networking D) Databases Q28. JFrame myFrame = new JFrame (); Any command (such as the one listed above) which createsa new object of a specific class (in this case a new JFrame object called myFrame) is generally called a... A) Constructor B) Layout manager C) Parameter D) GUI Q29. The size of a frame on the screen is measured in: A) Inches B) Centimetres C) Dots D) Pixels Q30. The layout of a container can be altered by using which of the following methods A) setLayout(LayoutManager) B) layoutmanager(LayoutManager) C) addLayout(LayoutManager) D)setLayoutManager(LayoutManager) Q31. How do you indicate where a component will be positioned using Flowlayout? A) North, South, East, West B) Assign a row/column grid reference C) Do nothing, the FlowLayout will position the component D) Pass a X/Y percentage parameter to the add method Q32. PreparedStatements are used for calling. Statements A) Interpreted Statements B) Exceuted statements C) Resultset statements D) precompile Statement Q33. Which TextComponent method is used to set a TextComponent to the read-only state ? A) setReadOnly() B) setRead() C) setUpdate() D) setTextReadOnly() Q34. In model-view-controller (MVC) architecture of swings, model defines the A) Data layer B) Presentation layer C) Business-logic layer D) Both A and C Q35. Disadvantages of MVC architecture can be : A) Navigation control is decentralized B) Time consuming C) both a& b D) UI components are not userfriendly Q35. _______ helps you to maintain data when you move from controller to view. A) View Bag B) View Data C). Temp Data D) Both A and B Q36. Which of the following view file types are supported in MVC? A).cshtml B).vbhtml C).aspx D) All of the above Q37. Can we use view state in MVC? A) Yes B) No C) Both A & B D) None of the above Q38. The code below draws a line. What is the color of the line created? g.setColor(Color.red.green.yellow.red.cyan); g.drawLine(0, 0, 100,100); A) Red B) Green C) Yellow D) Cyan Q39. What does the following code draw? g.setColor(Color.black); g.drawLine(10, 10, 10,50); g.setColor(Color.RED); g.drawRect(100, 100, 150, 150); A) A red vertical line that is 40 pixels long and a red square with sides of 150 pixels. B) A black vertical linethat is 40 pixels long and a red square with sides of 150 pixels. C) A black vertical square that is 50 pixels long and a red square with sides of 150 pixels. D) A red vertical line that is 50 pixels long and a red square with sides of 150 pixels. Q40. boolean equals(Object other) will return A) Returns true if object has same internet address as other. B) Returns False if object has same internetaddress as other. C) Returns true if object has not same internet address as other. D) Returns null if object has same internet address as other. Q41. Which method is used to construct a 24-point bold serif font? A) new Font(Font.SERIF, 24,Font.BOLD); B) new Font("SERIF", 24, BOLD"); C) new Font("BOLD",24,Font.SERIF); D) new Font("SERIF", Font.BOLD,24); Q42. What will be the following code draw on the screen. Where "g" is a graphics instance in thefollowing code of line g.fillArc(45,90,50,50,90,180); A) An arc bounded by a box of height 45, width 90 with a centre point of 50,50, starting at an angle of 90 degrees traversing through 180 degrees counter clockwise. B) An arc bounded by a box of height 50, width 50, with a centre point of 45,90 starting at an angle of 90 degrees traversing through 180 degrees clockwise. C) An arc bounded by a box of width 50, height 50, with a top left at coordinates of 45, 90, starting at 90 degrees and traversing through 180 degrees counter clockwise. D) An arc starting at 45 degrees, traversing through 90 degrees clockwise bounded by a box of height 50, width 50 with a centre point of 90, 180. Q43. Suppose a JPanel is added to a JFrame and a JButton is added to the JPanel. If the JFrames font is set to 12-point TimesRoman, the JPanels font is set to 10-point TimesRoman, and the JButtons fontis not set,what font will be taken to display the JButtons label? A) 12- point TimesRoman. B) 11- point TimesRoman. C) 10 -point TimesRoman D) 09 -pointTimesRoman. Q44. Model is the in the MVC architecture. A) top most level B) middle most level C) bottom most level D) None of the above Q45. The default layout manager for the content pane of a swing is : A) CardLayout B) GridLayout C) BorderLayout D) None of the above Q46. A label is a simple control which is used to display on the window A) button B) Editable Text C) Non-Editable Text D) All of above Q47. Label is entity. A) Active B) Passive C) Both A& B D) None of these Q48. method is used to set or change the text in a Label. A) setText(String strLabel) B) getText() C) getAlignment() D) None of these Q49. getAlignment() is the method of class. A) Button B) List C) Choice D) Label Q50. Label(String str) creates a label that contains the string specified by str which is A) Right-Justified B) Left-Justified C) Center-Justifed D) All of above Q51. Which of the following method is used to set Label for Button B A) B.setLabel(String S) B) B.getLabel() C) Both A& B D) B.setText(String S) Q52. The various controls supported by AWT are A) Buttons,Scrollbar B) Label,TabbedPanes C) Tress,Tables D) All of above Q53. Which of the following are ways to create a Frame? A) By creating the object of Frame class (association) B) By extending Frame class (inheritance) C) aand b D) none of these Q54. Give the abbreviation of AWT? A) Applet Windowing Toolkit B) Abstract Windowing Toolkit C) Absolute Windowing Toolkit D) None ofthe above Q55. How would you set the color of a graphics context called g to cyan? A) g.setColor(Color.cyan); B) g.setCurrentColor(cyan); C) g.setColor("Color.cyan"); D) g.setColor(newColor(cyan)); Q56. Which of the following are passed as an argument to the paint( ) method? A) A Canvas object B) A Graphics object C) An Image object D) A paint object Q57. Which of the following methods are invoked by the AWT to support paint and repaint operations? A) paint( ) B) repaint( ) C) draw( ) D) redraw( ) Q58. Which of the following classes have a paint( ) method? a.Canvas b.Image c.Frame d.Graphics A) b and d B) a and c C) a and b D) c and d Q59. Which of the following are methods of the Graphics class? a.drawRect( ) b. drawImage( ) c.drawPoint( ) d. drawString( ) A) a , b and c B) a , c and d C) b,c and d D) a, b and d Q60. Which of the following are true? a.The AWT automatically causes a window to be repainted when a portion of a window has been minimized and then maximized. b.The AWT automatically causes a windowto be repainted when a portion of a window has been covered and then uncovered. c.The AWT automatically causes a window to be repainted when application data is changed. d. The AWT does not support repainting operations. A) a and b B) a and d C) b and c D) a and c Q61. Which of the following is true about AWT and Swing Component? A) AWT Components create a process where as Swing Component create a thread B) AWT Componentscreate a thread where as Swing Component create a process C) Both AWT and Swing Component createa process D) Both AWT and Swing Component create a thread Q62. The setBackground() method is part of the following class in java.awt package: A) Graphics B) Component C) Applet D) Container Q63. Which of the following classes are derived from the Container class. Select the four correctanswers. a. Component b.Panel c.Dialog d.Frame A) b ,c and d B) a ,b and c C) a and b D) all of above Q64. Which of the following classes are derived from the Container class. Select the correct answers. a. Panel b Window c Frame d Component e Dialog A) a,b,d,c B) a, b, c, e C) b, c,d,e D) a, e,c,d Q65. Name the class used to represent a GUI application window, which is optionally resizable andcan have a title bar, an icon, and menus. Select the one correct answer. A) Window B) Panel C) Dialog D) Frame Q66. Button B1=new Button("Submit");Which method is used to obtain output as "Submit" A) setText() B) setLabel() C) getText() D) getLabel() Q67. Label lb=new Label("Advanced Java");Which method is used to obtain output as "AdvancedJava" A) setText() B) setLabel() C) getText() D) getLabel() Q68. By using control, we can create a set of mutually exclusive checkboxes in which one and only one checkbox in the group can be checked at a time. A) Button B) Checkbox C) CheckboxGroup D) List Q69. Superclass of TextField and TextArea classes that is used to create single Line or Multipletextfields are A) TextBox B) TextComponent C) Checkbox D) Choice Q70. Subclass of TextComponent is A) TextArea B) Button C) Label D) Checkbox Q71. Following are constructors of TextArea class A) TextArea(String str) B) TextArea(int numLines,int numChars) C) TextArea(String str,int numLines,intnumChars,int sBars) D) All of above Q72. Multiple selection of items in List is possible using following Constructor A) List() B) List(int numRows) C) List(int numRows,booean multipleSelect) D) None of these Q73. Which object can be constructed to show and select any number of choices in the visiblewindow? A) Button B) Choice C) List D) Label Q74. Which of these functions is called to display the output of an applet? A) display() B) paint() C) displayApplet() D) PrintApplet() Q75. AWT Component is used to select only one item from popup list of textual items A) Button B) Choice C) Checkbox D) All of above Q76. Which of these methods can be used to output a string in an applet? A) display() B) print() C) drawString() D) String() Q77. What is the length of the application box made by this program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { Graphic g; g.drawString("A Simple Applet", 20, 20); } A) 20 B) Default value C) Compilation Error D) Runtime Error Q78. Which of following is subclass of java.awt.Component? A) Container B) LayoutManger C) Color D) Font Q79. When should your program call repaint()? A) Never--that is the system's job. B) Only once when the frame is created. C) Whenever it has made achange to what should be displayed in the Frame.D) Always---whenever any method finishes Q80. Applet class is a subclass of the panel class, which is again a subclass of the class A) object B) Component AW C) awt D) Container Q81. The method is called every time the applet receives focus as a result of scrolling in the active window. A) init( ) B) start( ) C) stop( ) D) destroy( ) Q82. Which of the following applet tag is legal to embed an applet class named Test into a webpage? A) ; B) code=Test.class width=200 height=100> C) D) Q83. The class is an abstract class that represents the display area of the applet. A) display() B) graphics C) text D) area Q84. Which of the following method of applet class is used to clear the screen and calls the paint( )method A) update( ) B) paint( ) C) repaint( ) D) reupdate( ) Q85. The method is automatically called the first time the applet is displayed on the screenand every time the applet receives focus. A) update( ) B) paint( ) C) repaint( ) D) reupdate( ) Q86. The method is defined by the AWT which causes the AWT runtime system to execute a call to your applet’s update( ) method. A) update( ) B) paint( ) C) repaint( ) D) reupdate() Q87. Which of the following method is used to display numerical values in applet? A) paint( ) B) drawstring( ) C) draw( ) D) convert( ) Q88. Which of the following is/are the possible values for alignment attribute of Applet tag. i) Top ii) Left iii) Middle iv) Baseline A) i, ii and iii only B) ii, iii and iv only C) i, iii and iv only D) All i, ii, iii and iv Q89. attribute of applet tag specify the width of the space on the HTML page that will reserved for the applet. A) WIDTH=pixels B) HSPACE=pixels C) HWIDTH=pixels D) HBLANK=pixels Q90. What is the super class of container? A) java.awt.Container B) java.awt.Component C) java.awt.Panel D) java.awt.Layout Q91. View Data helps you to maintain data when you move from _______ A) Controller to View B) Temp Data C) Controller to Data D) None of above Q92. MVC is composed of three components: A) Member Vertical Controller B) Model View Control C) Model View Controller D) Model VariableCentered Q93. To hold component are used A) Container B) AWT C) Both D) None Q94. The elements of a Layout are organized in a top to bottom, left to right pattern. A) Grid B) Border C) Card D) Flow Q95. Which layout manager should you use to arrange the components of container in tabular form? A) Grid Layout B) Card Layout C) Border Layout D) Flow Layout Q96. Which of the following is the default layout for Frame? A) Grid Layout B) Card Layout C) Border Layout D) Flow Layout Q97. Which of the following statement is correct to change the layout of an applet? A) setLayoutManager(new GridLayout()); B) setLayout(new GridLayout(2,2)); C) setGridLayout(2,2); D)setBorderLayout(); Q98. ----------------- arranges the components as a deck of cards such that only one component is visible at a time. A) Grid Layout B) Card Layout C) Border Layout D) Flow Layout Q99. The default horizontal and vertical gap in FlowLayout is A) 0 Pixel B) 1 Pixel C) 5 Pixel D) 10 Pixel Q100. The default horizontal and vertical gap in BorderLayout is A) 0 Pixel B) 1 Pixel C) 5 Pixels D) 10 Pixels Q101. Which class provides many methods for graphics programming? A) javax.awt.graphics B) java.Graphics C) java.awt.Graphics D) None of the above