Which statement is true about a non-static inner class? A.It must implement an interface. B.It is accessible from any other class. C.It can only be instantiated in the enclosing class. D.It must be final if it is declared in a method scope. E.It can access private instance variables in the enclosing object. Given is E fine .But Why not c. I saw these type of Q in some other mocks and is confusing. Can anybody clear? 20) A sample question provided by Sun Given a TextArea using a proportional pitch font and constructed like this: TextField t = new TextArea("12345", 5, 5); Which statement is true? A.The displayed width shows exactly five characters on each line unless otherwise constrained B.The displayed height is five lines unless otherwise constrained. C.The maximum number of characters in a line will be five. D.The user will be able to edit the character string. E.The displayed string can use multiple fonts. In this B and D are given.Is a also a right option? Thanks, Madhuri.
Hi Madhuri, C is not always true because the following code works.
The above code proves that the inner class Inner can be instanciated by an outside class Tester. 2. Regarding text components we can only make statements regarding rows and not columns. That is because column is dependent on Font which remains an unknown. For example: Text1 uses Courier, 12 Text2 uses Helvetica, 12 Courier is a fixed sized font, meaning that every character takes a constant height and width regardless of what the character is. While Helvetica is a variable size font, meaning that every character takes a variable width but a constant height. For example, take the letter i (usually narrowest letter): Courier box size = 12h, 8w Helvetica box size = 12h, 3w take the letter w (usually widest letter): Courier box size = 12h, 8w Helvetica box size = 12h, 8w Therefore, the textfield can only use an average width for some fonts. That being the case the amount of characters will not always be the same in the column case. Since we are always dealing with constant heights, we can usually make a statement about them. Regards, Manfred.
Joined: Jan 17, 2001
Hi manfred, Thanku for the explanation. I was looking for the reply till the day I took the exam. Fortunately i was thru in the exam on 14th and got my certificate today. once again thankkyou . madhuri.