This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, Which of the following AWT components can have a menu, either as a menu bar or pop-up menu, attached to it? (Exam Cram page.no 229, q.no 2) a. java.awt.Frame b. java.awt.Window c. java.awt.Applet d. java.awt.Panel Answer shown as a,b,c and d. But in RHE (page no. 341, q.no 8) Which of the following may contain a menu bar? a. A panel b. A frame c. An applet d. A menu bar e. A menu Answer shown as only a Frame may contain menu bar. So, which one is correct? regards yojana
Hello yojana, The key difference between the two questions is "which can contain a menu, either as a menubar or popup menu" and "which can contain a menubar." add( PopupMenu ) is defined in Component so Applet, Panel, Window and Frame (which have Component as a superclass) can all have PopupMenus. setMenuBar( MenuBar ) is defined in Frame hence only Frame (and subclasses) can have a MenuBar. Hence they're both right because they aren't asking the same thing. Best regards, Steve Butcher email@example.com