{"id":138,"date":"2020-04-03T08:59:10","date_gmt":"2020-04-03T08:59:10","guid":{"rendered":"https:\/\/temp.ashkerala.com\/?p=138"},"modified":"2020-04-03T08:59:10","modified_gmt":"2020-04-03T08:59:10","slug":"java-packages","status":"publish","type":"post","link":"https:\/\/temp.ashkerala.com\/?p=138","title":{"rendered":"Java Packages"},"content":{"rendered":"<p><strong>Java.lang<\/strong><\/p>\n<p> \u00a0\u00a0\u00a0 1) java.lang package is automatically imported into all programs.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a<\/p>\n<p> \u00a0\u00a0\u00a0 2) What are the interfaces defined by java.lang?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Cloneable, Comparable and Runnable.<\/p>\n<p> \u00a0\u00a0\u00a0 3) What are the constants defined by both Flaot and Double classes?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : MAX_VALUE,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MIN_VALUE,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 NaN ,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 POSITIVE_INFINITY,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 NEGATIVE_INFINITY and<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TYPE.<\/p>\n<p> \u00a0\u00a0\u00a0 4) What are the constants defined by Byte, Short, Integer and Long?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : MAX_VALUE,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MIN_VALUE and<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TYPE.<\/p>\n<p> \u00a0\u00a0\u00a0 5) What are the constants defined by both Float and Double classes?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : MAX_RADIX,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MIN_RADIX,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MAX_VALUE,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MIN_VALUE and<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TYPE.<\/p>\n<p> \u00a0\u00a0\u00a0 6) What is the purpose of the Runtime class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The purpose of the Runtime class is to provide access to the Java runtime system.<\/p>\n<p> \u00a0\u00a0\u00a0 7) What is the purpose of the System class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The purpose of the System class is to provide access to system resources.<\/p>\n<p> \u00a0\u00a0\u00a0 8) Which class is extended by all other classes?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Object class is extended by all other classes.<\/p>\n<p> \u00a0\u00a0\u00a0 9) Which class can be used to obtain design information about an object?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The Class class can be used to obtain information about an object\u0393\u00c7\u00d6s design.<\/p>\n<p> \u00a0\u00a0\u00a0 10) Which method is used to calculate the absolute value of a number?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : abs( ) method.<\/p>\n<p> \u00a0\u00a0\u00a0 11) What are E and PI?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : E is the base of the natural logarithm and PI is the mathematical value pi.<\/p>\n<p> \u00a0\u00a0\u00a0 12) Which of the following classes is used to perform basic console I\/O?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SecurityManager<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Math<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Runtime<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 13) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Class class is the superclass of the Object class.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Object class is final.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Class class can be used to load other classes.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The ClassLoader class can be used to load other classes.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c and d.<\/p>\n<p> \u00a0\u00a0\u00a0 14) Which of the following methods are methods of the Math class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 absolute( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 log( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cosine( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sine( )<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 15) Which of the following are true about the Error and Exception classes?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Both classes extend Throwable.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Error class is final and the Exception class is not.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Exception class is final and the Error is not.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Both classes implement Throwable.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 16) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Void class extends the Class class.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Float class extends the Double class.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The System class extends the Runtime class.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Integer class extends the Number class.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : d.<\/p>\n<p> \u00a0\u00a0\u00a0 17) Which of the following will output -4.0<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(Math.floor(-4.7));<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(Math.round(-4.7));<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(Math.ceil(-4.7));<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(Math.Min(-4.7));<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c.<\/p>\n<p> \u00a0\u00a0\u00a0 18) Which of the following are valid statements<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a) public class MyCalc extends Math<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) Math.max(s);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) Math.round(9.99,1);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) Math.mod(4,10);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 e) None of the above.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : e.<\/p>\n<p> \u00a0\u00a0\u00a0 19) What will happen if you attempt to compile and run the following code?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Integer ten=new Integer(10);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Long nine=new Long (9);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(ten + nine);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int i=1;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(i + ten);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 19 followed by 20<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 19 followed by 11<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Error: Can&#8217;t convert java lang Integer<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) 10 followed by 1<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c.<\/p>\n<p><strong>Input\/Output<\/strong><\/p>\n<p> \u00a0\u00a0\u00a0 1) What is meant by Stream and what are the types of Streams and classes of the Streams?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : A Stream is an abstraction that either produces or consumes information.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 There are two types of Streams. They are:<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Byte Streams : Byte Streams provide a convenient means for handling input and output of bytes.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Character Streams : Character Streams provide a convenient means for handling input and output of characters.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Byte Stream classes : Byte Streams are defined by using two abstract classes. They are:InputStream and OutputStream.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Character Stream classes : Character Streams are defined by using two abstract classes. They are : Reader and Writer.<\/p>\n<p> \u00a0\u00a0\u00a0 2) Which of the following statements are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UTF characters are all 8-bits.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UTF characters are all 16-bits.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UTF characters are all 24-bits.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Unicode characters are all 16-bits.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Bytecode characters are all 16-bits.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : d.<\/p>\n<p> \u00a0\u00a0\u00a0 3) Which of the following statements are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 When you construct an instance of File, if you do not use the filenaming semantics of the local machine, the constructor will throw an IOException.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 When you construct an instance of File, if the corresponding file does not exist on the local file system, one will be created.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 When an instance of File is garbage collected, the corresponding file on the local file system is deleted.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 None of the above.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a,b and c.<\/p>\n<p> \u00a0\u00a0\u00a0 4) The File class contains a method that changes the current working directory.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 5) It is possible to use the File class to list the contents of the current working directory.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 6) Readers have methods that can read and return floats and doubles.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 7) You execute the code below in an empty directory. What is the result?<\/p>\n<p> \u00a0\u00a0\u00a0 File f1 = new File(&#8220;dirname&#8221;);<\/p>\n<p> \u00a0\u00a0\u00a0 File f2 = new File(f1, &#8220;filename&#8221;);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A new directory called dirname is created in the current working directory.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A new directory called dirname is created in the current working directory. A new file called filename is created in directory dirname.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A new directory called dirname and a new file called filename are created, both in the current working directory.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A new file called filename is created in the current working directory.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 No directory is created, and no file is created.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : e.<\/p>\n<p> \u00a0\u00a0\u00a0 8) What is the difference between the Reader\/Writer class hierarchy and the InputStream\/OutputStream class hierarchy?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The Reader\/Writer class hierarchy is character-oriented and the InputStream\/OutputStream class hierarchy is byte-oriented.<\/p>\n<p> \u00a0\u00a0\u00a0 9) What is an I\/O filter?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : An I\/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.<\/p>\n<p> \u00a0\u00a0\u00a0 10) What is the purpose of the File class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The File class is used to create objects that provide access to the files and directories of a local file system.<\/p>\n<p> \u00a0\u00a0\u00a0 11) What interface must an object implement before it can be written to a stream as an object?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.<\/p>\n<p> \u00a0\u00a0\u00a0 12) What is the difference between the File and RandomAccessFile classes?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.<\/p>\n<p> \u00a0\u00a0\u00a0 13) What class allows you to read objects directly from a stream?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The ObjectInputStream class supports the reading of objects from input streams.<\/p>\n<p> \u00a0\u00a0\u00a0 14) What value does read( ) return when it has reached the end of a file?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The read( ) method returns \u0393\u00c7\u00f4 1 when it has reached the end of a file.<\/p>\n<p> \u00a0\u00a0\u00a0 15) What value does readLine( ) return when it has reached the end of a file?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The readLine( ) method returns null when it has reached the end of a file.<\/p>\n<p> \u00a0\u00a0\u00a0 16) How many bits are used to represent Unicode, ASCII, UTF-16 and UTF-8 characters?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Unicode requires 16-bits and ASCII requires 8-bits. Although the ASCII character set uses only 1-bits, it is usually represented as 8-bits. UTF-8 represents characters using 8, 16 and 18-bit patterns. UTF-16 uses 16-bit and larger bit patterns.<\/p>\n<p> \u00a0\u00a0\u00a0 17) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The InputStream and OutputStream classes are byte-oriented.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The ObjectInputStream and ObjectOutputStream do not support serialized object input and output.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Reader and Writer classes are character-oriented.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Reader and Writer classes are the preferred solution to serialized object output.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a and c.<\/p>\n<p> \u00a0\u00a0\u00a0 18) Which of the following are true about I\/O filters?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Filters are supported on input, but not on output.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Filters are supported by the InputStream\/OutputStream class hierarchy, but not by the Reader\/Writer class hierarchy.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Filters read from one stream and write to another.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A filter may alter data that is read from one stream and written to another.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c and d.<\/p>\n<p> \u00a0\u00a0\u00a0 19) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Any Unicode character is represented using 16-bits.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7-bits are needed to represent any ASCII character.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UTF-8 characters are represented using only 8-bits.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UTF-16 characters are represented using only 16-bits.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a and b.<\/p>\n<p> \u00a0\u00a0\u00a0 20) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Serializable interface is used to identify objects that may be written to an output stream.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Externalizable interface is implemented by classes that control the way in which their objects are serialized.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Serializable interface extends the Externalizable interface.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The Externalizable interface extends the Serializable interface.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a, b and d.<\/p>\n<p> \u00a0\u00a0\u00a0 21) Which of the following are true about the File class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A File object can be used to change the current working directory.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A File object can be used to access the files in the current directory.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 When a File object is created, a corresponding directory or file is created in the local file system.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 File objects are used to access files and directories on the local file system.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 File objects can be garbage collected.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 When a File object is garbage collected, the corresponding file or directory is deleted.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b, d and e.<\/p>\n<p> \u00a0\u00a0\u00a0 22) How do you create a Reader object from an InputStream object?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Use the static createReader( ) method of InputStream class.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Use the static createReader( ) method of Reader class.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Create an InputStreamReader object, passing the InputStream object as an argument to the InputStreamReader constructor.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Create an OutputStreamReader object, passing the InputStream object as an argument to the OutputStreamReader constructor.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c.<\/p>\n<p> \u00a0\u00a0\u00a0 23) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Writer classes can be used to write characters to output streams using different character encodings.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Writer classes can be used to write Unicode characters to output streams.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Writer classes have methods that support the writing of the values of any Java primitive type to output streams.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Writer classes have methods that support the writing of objects to output streams.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a and b.<\/p>\n<p> \u00a0\u00a0\u00a0 24) The isFile( ) method returns a boolean value depending on whether the file object is a file or a directory.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 25) Reading or writing can be done even after closing the input\/output source.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 26) The ________ method helps in clearing the buffer.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : flush( ).<\/p>\n<p> \u00a0\u00a0\u00a0 27) The System.err method is used to print error message.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 28) What is meant by StreamTokenizer?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : StreamTokenizer breaks up InputStream into tokens that are delimited by sets of characters.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 It has the constructor : StreamTokenizer(Reader inStream).<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Here inStream must be some form of Reader.<\/p>\n<p> \u00a0\u00a0\u00a0 29) What is Serialization and deserialization?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Serialization is the process of writing the state of an object to a byte stream.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Deserialization is the process of restoring these objects.<\/p>\n<p> \u00a0\u00a0\u00a0 30) Which of the following can you perform using the File class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a) Change the current directory<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) Return the name of the parent directory<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) Delete a file<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) Find if a file contains text or binary information<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b and c.<\/p>\n<p> \u00a0\u00a0\u00a0 31) How can you change the current working directory using an instance of the File class called FileName?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FileName.chdir(&#8220;DirName&#8221;).<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FileName.cd(&#8220;DirName&#8221;).<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FileName.cwd(&#8220;DirName&#8221;).<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The File class does not support directly changing the current directory.<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0 Ans : d.<\/p>\n<p><strong>Applets<\/strong><\/p>\n<p> \u00a0\u00a0\u00a0 1) What is an Applet? Should applets have constructors?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Applet is a dynamic and interactive program that runs inside a Web page displayed by a Java capable browser. We don\u0393\u00c7\u00d6t have the concept of Constructors in Applets.<\/p>\n<p> \u00a0\u00a0\u00a0 2) How do we read number information from my applet\u0393\u00c7\u00d6s parameters, given that Applet\u0393\u00c7\u00d6s getParameter() method returns a string?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Use the parseInt() method in the Integer Class, the Float(String) constructor in the Class Float, or the Double(String) constructor in the class Double.<\/p>\n<p> \u00a0\u00a0\u00a0 3) How can I arrange for different applets on a web page to communicate with each other?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Name your applets inside the Applet tag and invoke AppletContext\u0393\u00c7\u00d6s getApplet() method in your applet code to obtain references to the other applets on the page.<\/p>\n<p> \u00a0\u00a0\u00a0 4) How do I select a URL from my Applet and send the browser to that page?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Ask the applet for its applet context and invoke showDocument() on that context object.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Eg. URL targetURL;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String URLString<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AppletContext context = getAppletContext();<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 try{<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 targetUR L = new URL(URLString);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } catch (Malformed URLException e){<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Code for recover from the exception<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 context. showDocument (targetURL);<\/p>\n<p> \u00a0\u00a0\u00a0 5) Can applets on different pages communicate with each other?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : No. Not Directly. The applets will exchange the information at one meeting place<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 either on the local file system or at remote system.<\/p>\n<p> \u00a0\u00a0\u00a0 6) How do Applets differ from Applications?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Appln: Stand Alone<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Applet: Needs no explicit installation on local m\/c.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Appln: Execution starts with main() method.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Applet: Execution starts with init() method.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Appln: May or may not be a GUI<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Applet: Must run within a GUI (Using AWT)<\/p>\n<p> \u00a0\u00a0\u00a0 7) How do I determine the width and height of my application?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Use the getSize() method, which the Applet class inherits from the Component<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 class in the Java.awt package. The getSize() method returns the size of the applet as<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a Dimension object, from which you extract separate width, height fields.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Eg. Dimension dim = getSize ();<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int appletwidth = dim.width ();<\/p>\n<p> \u00a0\u00a0\u00a0 8) What is AppletStub Interface?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface.<\/p>\n<p> \u00a0\u00a0\u00a0 9) It is essential to have both the .java file and the .html file of an applet in the same directory.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : 2.<\/p>\n<p> \u00a0\u00a0\u00a0 10) The &lt;PARAM&gt; tag contains two attributes namely _________ and _______.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Name , value.<\/p>\n<p> \u00a0\u00a0\u00a0 11) Passing values to parameters is done in the _________ file of an applet.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : .html.<\/p>\n<p> \u00a0\u00a0\u00a0 12) What tags are mandatory when creating HTML to display an applet<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 name, height, width<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 code, name<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 codebase, height, width<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 code, height, width<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : 4.<\/p>\n<p> \u00a0\u00a0\u00a0 13) Applet\u0393\u00c7\u00d6s getParameter( ) method can be used to get parameter values.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 14) What are the Applet\u0393\u00c7\u00d6s Life Cycle methods? Explain them?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : init( ) method &#8211; Can be called when an applet is first loaded.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 start( ) method &#8211; Can be called each time an applet is started.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 paint( ) method &#8211; Can be called when the applet is minimized or refreshed.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 stop( ) method &#8211; Can be called when the browser moves off the applet\u0393\u00c7\u00d6s page.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 destroy( ) method &#8211; Can be called when the browser is finished with the applet.<\/p>\n<p> \u00a0\u00a0\u00a0 15) What are the Applet\u0393\u00c7\u00d6s information methods?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : getAppletInfo( ) method : Returns a string describing the applet, its author ,copy<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 right information, etc.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 getParameterInfo( ) method : Returns an array of string describing the applet\u0393\u00c7\u00d6s parameters.<\/p>\n<p> \u00a0\u00a0\u00a0 16) All Applets are subclasses of Applet.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 17) All Applets must import java.applet and java.awt.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 18) What are the steps involved in Applet development?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a) Edit a Java source file,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) Compile your program and<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) Execute the appletviewer, specifying the name of your applet\u0393\u00c7\u00d6s source file.<\/p>\n<p> \u00a0\u00a0\u00a0 19) Applets are executed by the console based Java run-time interpreter.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 20) Which classes and interfaces does Applet class consist?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Applet class consists of a single class, the Applet class and three interfaces: AppletContext,<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AppletStub and AudioClip.<\/p>\n<p> \u00a0\u00a0\u00a0 21) What is the sequence for calling the methods by AWT for applets?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : When an applet begins, the AWT calls the following methods, in this sequence.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 init( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 start( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 paint( )<\/p>\n<p> \u00a0\u00a0\u00a0 22) When an applet is terminated, the following sequence of method cals takes place :<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 stop( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 destroy( )<\/p>\n<p> \u00a0\u00a0\u00a0 23) Which method is used to output a string to an applet?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : drawString ( ) method.<\/p>\n<p> \u00a0\u00a0\u00a0 24) Every color is created from an RGB value.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.\u00a0<\/p>\n<p><strong>Event Handling<\/strong><\/p>\n<p> \u00a0\u00a0\u00a0 1) The event delegation model, introduced in release 1.1 of the JDK, is fully compatible with the event model.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 2) A component subclass that has executed enableEvents( ) to enable processing of a certain kind of event cannot also use an adapter as a listener for the same kind of event.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 3) What is the highest-level event class of the event-delegation model?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The java.util.eventObject class is the highest-level class in the event-delegation hierarchy.<\/p>\n<p> \u00a0\u00a0\u00a0 4) What interface is extended by AWT event listeners?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : All AWT event listeners extend the java.util.EventListener interface.<\/p>\n<p> \u00a0\u00a0\u00a0 5) What class is the top of the AWT event hierarchy?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The java.awt.AWTEvent class is the highest-level class in the AWT event class hierarchy.<\/p>\n<p> \u00a0\u00a0\u00a0 6) What event results from the clicking of a button?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The ActionEvent event is generated as the result of the clicking of a button.<\/p>\n<p> \u00a0\u00a0\u00a0 7) What is the relationship between an event-listener interface and an event-adapter class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event. An event adapter provides a default implementation of an event-listener interface.<\/p>\n<p> \u00a0\u00a0\u00a0 8) In which package are most of the AWT events that support the event-delegation model defined?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Most of the AWT\u0393\u00c7\u00f4related events of the event-delegation model are defined in the java.awt.event package. The AWTEvent class is defined in the java.awt package.<\/p>\n<p> \u00a0\u00a0\u00a0 9) What is the advantage of the event-delegation model over the earlier event-inheritance model?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The event-delegation has two advantages over the event-inheritance model. They are :<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 It enables event handling by objects other than the ones that generate the events. This allows a clean separation between a component\u0393\u00c7\u00d6s design and its use.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 It performs much better in applications where many events are generated. This performance improvement is due to the fact that the event-delegation model does not have to repeatedly process unhandled events, as is the case of the event-inheritance model.<\/p>\n<p> \u00a0\u00a0\u00a0 10) What is the purpose of the enableEvents( ) method?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans :The enableEvents( ) method is used to enable an event for a particular object.<\/p>\n<p> \u00a0\u00a0\u00a0 11) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The event-inheritance model has replaced the event-delegation model.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The event-inheritance model is more efficient than the event-delegation model.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The event-delegation model uses event listeners to define the methods of event-handling classes.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The event-delegation model uses the handleEvent( ) method to support event handling.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c.<\/p>\n<p> \u00a0\u00a0\u00a0 12) Which of the following is the highest class in the event-delegation model?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 java.util.EventListener<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 java.util.EventObject<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 java.awt.AWTEvent<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 java.awt.event.AWTEvent<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 13) When two or more objects are added as listeners for the same event, which listener is first invoked to handle the event?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The first object that was added as listener.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The last object that was added as listener.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 There is no way to determine which listener will be invoked first.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 It is impossible to have more than one listener for a given event.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c.<\/p>\n<p> \u00a0\u00a0\u00a0 14) Which of the following components generate action events?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Buttons<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Labels<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Check boxes<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Windows<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 15) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A TextField object may generate an ActionEvent.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A TextArea object may generate an ActionEvent.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A Button object may generate an ActionEvent.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A MenuItem object may generate an ActionEvent.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a,c and d.<\/p>\n<p> \u00a0\u00a0\u00a0 16) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The MouseListener interface defines methods for handling mouse clicks.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The MouseMotionListener interface defines methods for handling mouse clicks.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The MouseClickListener interface defines methods for handling mouse clicks.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The ActionListener interface defines methods for handling the clicking of a button.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a and d.<\/p>\n<p> \u00a0\u00a0\u00a0 17) Suppose that you want to have an object eh handle the TextEvent of a TextArea object t. How should you add eh as the event handler for t?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 t.addTextListener(eh);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 eh.addTextListener(t);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 addTextListener(eh.t);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 addTextListener(t,eh);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 18) What is the preferred way to handle an object\u0393\u00c7\u00d6s events in Java 2?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Override the object\u0393\u00c7\u00d6s handleEvent( ) method.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Add one or more event listeners to handle the events.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Have the object override its processEvent( ) methods.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Have the object override its dispatchEvent( ) methods.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 19) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A component may handle its own events by adding itself as an event listener.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A component may handle its own events by overriding its event-dispatching method.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A component may not handle oits own events.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A component may handle its own events only if it implements the handleEvent( ) method.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a and b.<\/p>\n<p> \u00a0\u00a0\u00a0 20) How many types of events are provided by AWT? Explain them?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The AWT provides two types of events. They are :<\/p>\n<p> \u00a0\u00a0\u00a0 21) Low-level event : A low-level event is the one that represents a low-level input or window-system occurrence on a visual component on the screen.<\/p>\n<p> \u00a0\u00a0\u00a0 22) Semantic event : Semantic event is defined at a higher-level to encapsulate the semantics of a user interface component\u0393\u00c7\u00d6s model.<\/p>\n<p> \u00a0\u00a0\u00a0 23) A __________ is an object that originates or &#8220;fire&#8221; events.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : source.<\/p>\n<p> \u00a0\u00a0\u00a0 24) The event listener corresponding to handling keyboard events is the _________ .<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : KeyListener.<\/p>\n<p> \u00a0\u00a0\u00a0 25) What are the types of mouse event listeners?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : MouseListener and MouseMotionListener.<\/p>\n<p> \u00a0\u00a0\u00a0 26) Which of the following are correct event handling methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a) mousePressed(MouseEvent e){}<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) MousePressed(MouseClick e){}<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) functionKey(KeyPress k){}<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) componentAdded(ContainerEvent e){}<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a and d.<\/p>\n<p> \u00a0\u00a0\u00a0 27) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a) A component may have only one event listener attached at a time<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) An event listener may be removed from a component<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) The ActionListener interface has no corresponding Adapter class<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) The processing of an event listener requires a try\/catch block<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b and c.<\/p>\n<p><strong>\u00a0AWT : windows, graphics and fonts<\/strong><\/p>\n<p> \u00a0\u00a0\u00a0 1) How would you set the color of a graphics context called g to cyan?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.setColor(Color.cyan);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.setCurrentColor(cyan);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.setColor(&#8220;Color.cyan&#8221;);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.setColor(&#8220;cyan\u0393\u00c7\u00d6);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.setColor(new Color(cyan));<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 2) The code below draws a line. What color is the line?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.setColor(Color.red.green.yellow.red.cyan);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.drawLine(0, 0, 100,100);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Red<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Green<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Yellow<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Cyan<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Black<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : d.<\/p>\n<p> \u00a0\u00a0\u00a0 3) What does the following code draw?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.setColor(Color.black);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.drawLine(10, 10, 10, 50);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.setColor(Color.RED);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.drawRect(100, 100, 150, 150);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A red vertical line that is 40 pixels long and a red square with sides of 150 pixels<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A black vertical line that is 40 pixels long and a red square with sides of 150 pixels<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A black vertical line that is 50 pixels long and a red square with sides of 150 pixels<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A red vertical line that is 50 pixels long and a red square with sides of 150 pixels<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A black vertical line that is 40 pixels long and a red square with sides of 100 pixel<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 4) Which of the statements below are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a) A polyline is always filled.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) A polyline can not be filled.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) A polygon is always filled.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) A polygon is always closed<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 e) A polygon may be filled or not filled<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b, d and e.<\/p>\n<p> \u00a0\u00a0\u00a0 5) What code would you use to construct a 24-point bold serif font?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 new Font(Font.SERIF, 24,Font.BOLD);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 new Font(&#8220;SERIF&#8221;, 24, BOLD&#8221;);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 new Font(&#8220;BOLD &#8220;, 24,Font.SERIF);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 new Font(&#8220;SERIF&#8221;, Font.BOLD,24);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 new Font(Font.SERIF, &#8220;BOLD&#8221;, 24);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : 4.<\/p>\n<p> \u00a0\u00a0\u00a0 6) What does the following paint( ) method draw?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Public void paint(Graphics g) {<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.drawString(&#8220;question #6&#8221;,10,0);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The string &#8220;question #6&#8221;, with its top-left corner at 10,0<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A little squiggle coming down from the top of the component, a little way in from the left edge<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : 2.<\/p>\n<p> \u00a0\u00a0\u00a0 7) What does the following paint( ) method draw?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Public void paint(Graphics g) {<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g.drawString(&#8220;question #6&#8221;,10,0);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A circle at (100, 100) with radius of 44<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A circle at (100, 44) with radius of 100<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A circle at (100, 44) with radius of 44<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The code does not compile<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : 4.<\/p>\n<p> \u00a0\u00a0\u00a0 8) What is relationship between the Canvas class and the Graphics class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : A Canvas object provides access to a Graphics object via its paint( ) method.<\/p>\n<p> \u00a0\u00a0\u00a0 9) What are the Component subclasses that support painting.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The Canvas, Frame, Panel and Applet classes support painting.<\/p>\n<p> \u00a0\u00a0\u00a0 10) What is the difference between the paint( ) and repaint( ) method?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The paint( ) method supports painting via a Graphics object. The repaint( ) method is used to cause paint( ) to be invoked by the AWT painting method.<\/p>\n<p> \u00a0\u00a0\u00a0 11) What is the difference between the Font and FontMetrics classes?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.<\/p>\n<p> \u00a0\u00a0\u00a0 12) Which of the following are passed as an argument to the paint( ) method?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A Canvas object<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A Graphics object<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 An Image object<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A paint object<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 13) Which of the following methods are invoked by the AWT to support paint and repaint operations?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 paint( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 repaint( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 draw( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 redraw( )<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 14) Which of the following classes have a paint( ) method?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Canvas<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Image<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Frame<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Graphics<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a and c.<\/p>\n<p> \u00a0\u00a0\u00a0 15) Which of the following are methods of the Graphics class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 drawRect( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 drawImage( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 drawPoint( )<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 drawString( )<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a, b and d.<\/p>\n<p> \u00a0\u00a0\u00a0 16) Which Font attributes are available through the FontMetrics class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ascent<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 leading<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 height<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a, b and d.<\/p>\n<p> \u00a0\u00a0\u00a0 17) Which of the following are true?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The AWT automatically causes a window to be repainted when a portion of a window has been minimized and then maximized.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The AWT automatically causes a window to be repainted when a portion of a window has been covered and then uncovered.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The AWT automatically causes a window to be repainted when application data is changed.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The AWT does not support repainting operations.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a and b.<\/p>\n<p> \u00a0\u00a0\u00a0 18) Which method is used to size a graphics object to fit the current size of the window?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : getSize( ) method.<\/p>\n<p> \u00a0\u00a0\u00a0 19) What are the methods to be used to set foreground and background colors?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : setForeground( ) and setBackground( ) methods.<\/p>\n<p> \u00a0\u00a0\u00a0 20) You have created a simple Frame and overridden the paint method as follows<\/p>\n<p> \u00a0\u00a0\u00a0 public void paint(Graphics g){<\/p>\n<p> \u00a0\u00a0\u00a0 \u00a0<\/p>\n<p> \u00a0\u00a0\u00a0 g.drawString(&#8220;Dolly&#8221;,50,10);<\/p>\n<p> \u00a0\u00a0\u00a0 \u00a0<\/p>\n<p> \u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0\u00a0\u00a0 What will be the result when you attempt to compile and run the program?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a) The string &#8220;Dolly&#8221; will be displayed at the centre of the frame<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) An error at compilation complaining at the signature of the paint method<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) The lower part of the word Dolly will be seen at the top of the form, with the top hidden.<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) The string &#8220;Dolly&#8221; will be shown at the bottom of the form<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c.<\/p>\n<p> \u00a0\u00a0\u00a0 21) Where g is a graphics instance what will the following code draw on the screen.<\/p>\n<p> \u00a0\u00a0\u00a0 g.fillArc(45,90,50,50,90,180);<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a) An arc bounded by a box of height 45, width 90 with a centre point of 50,50, starting<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 at an angle of 90 degrees traversing through 180 degrees counter clockwise.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) An arc bounded by a box of height 50, width 50, with a centre point of 45,90 starting<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 at an angle of 90 degrees traversing through 180 degrees clockwise.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) An arc bounded by a box of height 50, width 50, with a top left at coordinates of 45,<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 90, starting at 90 degrees and traversing through 180 degrees counter clockwise.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) An arc starting at 45 degrees, traversing through 90 degrees clockwise bounded by a<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 box of height 50, width 50 with a centre point of 90, 180.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : c.<\/p>\n<p> \u00a0\u00a0\u00a0 22) Given the following code<br \/> \u00a0\u00a0\u00a0 import java.awt.*;<br \/> \u00a0\u00a0\u00a0 public class SetF extends Frame{<br \/> \u00a0\u00a0\u00a0 public static void main(String argv[]){<br \/> \u00a0\u00a0\u00a0 SetF s = new SetF();<br \/> \u00a0\u00a0\u00a0 s.setSize(300,200);<br \/> \u00a0\u00a0\u00a0 s.setVisible(true);<br \/> \u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0 }<br \/> \u00a0\u00a0\u00a0 How could you set the frame surface color to pink<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)s.setBackground(Color.pink);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)s.setColor(PINK);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c)s.Background(pink);<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d)s.color=Color.pink<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java.lang \u00a0\u00a0\u00a0 1) java.lang package is automatically imported into all programs. \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 False \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a \u00a0\u00a0\u00a0 2) What are the interfaces defined by java.lang? \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Cloneable, Comparable and Runnable. \u00a0\u00a0\u00a0 3) What are the constants defined by both Flaot and Double classes? \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : MAX_VALUE, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MIN_VALUE, \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-138","post","type-post","status-publish","format-standard","hentry","category-java-programming"],"_links":{"self":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts\/138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=138"}],"version-history":[{"count":0,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts\/138\/revisions"}],"wp:attachment":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}