<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="http://faqworldofrastogi.wetpaint.com/xsl/rss2html.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://faqworldofrastogi.wetpaint.com/scripts/wpcss/wiki/faqworldofrastogi/skin/sporty/rss" type="text/css" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>&lt;a  href=&quot;http://instantptr.com/pag - Recently Updated Pages</title><link>http://faqworldofrastogi.wetpaint.com/pageSearch/updated</link><description>Recently Updated Pages on http://faqworldofrastogi.wetpaint.com</description><language>en-us</language><webMaster>info@wetpaint.com</webMaster><pubDate>Wed, 30 Sep 2009 02:51:25 CDT</pubDate><lastBuildDate>Wed, 30 Sep 2009 02:51:25 CDT</lastBuildDate><generator>wetpaint.com</generator><ttl>60</ttl><image><title>&lt;a  href=&quot;http://instantptr.com/pag</title><url>http://image.wetpaint.com/image/2/8kPzYanhgV0O-M9HL6wsdQ85868</url><link>http://faqworldofrastogi.wetpaint.com</link><description>this site contains various FAQ's of different technologies.you can be a member of this site by registering as a writer to contribute this site.</description></image><item><title>Home</title><link>http://faqworldofrastogi.wetpaint.com/page/Home</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/Home</guid><pubDate>Wed, 30 Sep 2009 02:51:25 CDT</pubDate><description> &lt;br&gt;&lt;br&gt;Hello Friends I am&lt;b&gt; Rahul Rastogi&lt;/b&gt;.Here I am Giving The Frequently Asked Questions on various technologies such as Java,C#,C++.C,DBMS etc.&lt;br&gt;you can get on this site&lt;br&gt;&lt;ol&gt;  &lt;li&gt;  java&amp;#39;s faq   &lt;/li&gt;&lt;li&gt;  c# faq   &lt;/li&gt;&lt;li&gt;  DBMS&amp;#39;s faq   &lt;/li&gt;&lt;li&gt;  Networking&amp;#39;s faq etc&lt;/li&gt;&lt;/ol&gt;AS a registered user you can give suggestions &amp;amp; contribute to make this site efficient. please suggest me to do any thing new.   &lt;br&gt;Mail me at :&lt;b&gt;rahulrastogi6@gmail.com&lt;/b&gt;&lt;br&gt;hope to get a better response.&lt;br&gt;Thanks &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;http://instantptr.com/pages/index.php?refid=rahulrastogi&lt;br&gt;&lt;br&gt;&lt;div&gt;Rahul Rastogi&lt;/div&gt;&lt;br&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>Mock Exam 2</title><link>http://faqworldofrastogi.wetpaint.com/page/Mock+Exam+2</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/Mock+Exam+2</guid><pubDate>Mon, 12 Nov 2007 23:05:12 CST</pubDate><description>  &lt;table align=&quot;bottom&quot; cellpadding=&quot;3&quot; class=&quot;wp-border-all&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  &lt;ol&gt;  &lt;li&gt;Which of the following are Java keywords? Select the three correct answers.   &lt;ol&gt;  &lt;li&gt;external   &lt;/li&gt;&lt;li&gt;implement   &lt;/li&gt;&lt;li&gt;throw   &lt;/li&gt;&lt;li&gt;void   &lt;/li&gt;&lt;li&gt;integer   &lt;/li&gt;&lt;li&gt;private   &lt;/li&gt;&lt;li&gt;synchronize   &lt;/li&gt;&lt;li&gt;unsigned &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of the following are legal definitions of the main method that can be used to execute a class. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;public void main(String args)   &lt;/li&gt;&lt;li&gt;public static int main(String args[])   &lt;/li&gt;&lt;li&gt;public static void main(String args[])   &lt;/li&gt;&lt;li&gt;static public void MAIN(String args[])   &lt;/li&gt;&lt;li&gt;public static void main(string args[])   &lt;/li&gt;&lt;li&gt;public static void main(String *args) &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of these are legal array declarations or definitions? Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;int[] []x[];   &lt;/li&gt;&lt;li&gt;int *x;   &lt;/li&gt;&lt;li&gt;int x[5];   &lt;/li&gt;&lt;li&gt;int[] x = {1,2,3}; &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Name the collection interface used to represent a sequence of numbers in a fixed order. &lt;br&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;The class Hashtable is used to implement which collection interface. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;Table   &lt;/li&gt;&lt;li&gt;List   &lt;/li&gt;&lt;li&gt;Set   &lt;/li&gt;&lt;li&gt;SortedSet   &lt;/li&gt;&lt;li&gt;Map &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What gets printed when the following program is compiled and run? Select the one correct answer. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;    class test {        public static void main(String args[]) {            int i;            do {                i++;            }            while(i &amp;lt; 0);            System.out.println(i);        }    }    &lt;/font&gt;      &lt;ol&gt;  &lt;li&gt;The program does not compile as i is not initialized.   &lt;/li&gt;&lt;li&gt;The program compiles but does not run.   &lt;/li&gt;&lt;li&gt;The program compiles and runs but does not print anything.   &lt;/li&gt;&lt;li&gt;The program prints 0.   &lt;/li&gt;&lt;li&gt;The program prints 1. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What gets printed when the following program is compiled and run? Select the one correct answer. &lt;font color=&quot;red&quot;&gt;    class xyz {        static int i;        public static void main(String args[]) {                while (i &amp;lt; 0) {                i--;            }            System.out.println(i);        }    }        &lt;/font&gt;  &lt;ol&gt;  &lt;li&gt;The program does not compile as i is not initialized.   &lt;/li&gt;&lt;li&gt;The program compiles but does not run.   &lt;/li&gt;&lt;li&gt;The program compiles and runs but does not print anything.   &lt;/li&gt;&lt;li&gt;The program prints 0.   &lt;/li&gt;&lt;li&gt;The program prints 1. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What gets printed when the following program is compiled and run? Select the one correct answer. &lt;font color=&quot;red&quot;&gt;    class xyz {             public static void main(String args[]) {            int i,j,k;            for (i = 0; i &amp;lt; 3; i++) {                for(j=1; j &amp;lt; 4; j++) {                    for(k=2; k&amp;lt;5; k++) {                        if((i == j)   &amp;amp;&amp;amp; (j==k))                            System.out.println(i);                    }                                }            }        }    }        &lt;/font&gt;  &lt;ol&gt;  &lt;li&gt;0   &lt;/li&gt;&lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;3   &lt;/li&gt;&lt;li&gt;4 &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Using up to four characters what is the Java representation of the number 23 in hex? &lt;br&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What gets printed when the following program is compiled and run? Select the one correct answer. &lt;font color=&quot;red&quot;&gt;    class test {        static boolean check;        public static void main(String args[]) {            int i;            if(check == true)                i=1;            else                i=2;                if(i=2) i=i+2;            else i = i + 4;            System.out.println(i);         }    }        &lt;/font&gt;  &lt;ol&gt;  &lt;li&gt;3   &lt;/li&gt;&lt;li&gt;4   &lt;/li&gt;&lt;li&gt;5   &lt;/li&gt;&lt;li&gt;6   &lt;/li&gt;&lt;li&gt;The program does not compile because of the statement if(i=2) &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Select the one correct answer. The smallest number that can be represented using short primitive type in Java is -   &lt;ol&gt;  &lt;li&gt;0   &lt;/li&gt;&lt;li&gt;-127   &lt;/li&gt;&lt;li&gt;-128   &lt;/li&gt;&lt;li&gt;-16384   &lt;/li&gt;&lt;li&gt;-32768   &lt;/li&gt;&lt;li&gt;The smallest number is compiler dependent. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Given the following declarations, which of the assignments given in the options below would compile. Select the two correct answers. &lt;font color=&quot;red&quot;&gt;    int i = 5;    boolean t = true;    float f = 2.3F;    double d = 2.3;        &lt;/font&gt;  &lt;ol&gt;  &lt;li&gt;t = (boolean) i;   &lt;/li&gt;&lt;li&gt;f = d;   &lt;/li&gt;&lt;li&gt;d = i;   &lt;/li&gt;&lt;li&gt;i = 5;   &lt;/li&gt;&lt;li&gt;f = 2.8; &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What gets printed when the following program is compiled and run. Select the one correct answer. &lt;font color=&quot;red&quot;&gt;    public class incr {        public static void main(String args[]) {            int i , j;            i = j = 3;            int n = 2 * ++i;            int m = 2 * j++;            System.out.println(i + &amp;quot; &amp;quot; + j + &amp;quot; &amp;quot; + n + &amp;quot; &amp;quot; + m);        }    }        &lt;/font&gt;  &lt;ol&gt;  &lt;li&gt;4 4 8 6   &lt;/li&gt;&lt;li&gt;4 4 8 8   &lt;/li&gt;&lt;li&gt;4 4 6 6   &lt;/li&gt;&lt;li&gt;4 3 8 6   &lt;/li&gt;&lt;li&gt;4 3 8 8   &lt;/li&gt;&lt;li&gt;4 4 6 8 &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Given two non-negative integers a and b and a String str, what is the number of characters in the expression str.substring(a,b) . Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;a + b   &lt;/li&gt;&lt;li&gt;a - b   &lt;/li&gt;&lt;li&gt;b - a - 1   &lt;/li&gt;&lt;li&gt;b - a + 1   &lt;/li&gt;&lt;li&gt;b - a   &lt;/li&gt;&lt;li&gt;b &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What is the result of compiling and running the following program. Select the one correct answer. &lt;font color=&quot;red&quot;&gt;    class test {        public static void main(String args[]) {            char ch;            String test2 = &amp;quot;abcd&amp;quot;;            String test = new String(&amp;quot;abcd&amp;quot;);            if(test.equals(test2)) {                if(test == test2)                    ch = test.charAt(0);                else                    ch = test.charAt(1);	                       }            else {                if(test == test2)                    ch = test.charAt(2);                else                                    ch = test.charAt(3);            }            System.out.println(ch);        }    }    &lt;/font&gt;      &lt;ol&gt;  &lt;li&gt;&amp;#39;a&amp;#39;   &lt;/li&gt;&lt;li&gt;&amp;#39;b&amp;#39;   &lt;/li&gt;&lt;li&gt;&amp;#39;c&amp;#39;   &lt;/li&gt;&lt;li&gt;&amp;#39;d&amp;#39; &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What is the result of compiling and running the following program. Select the one correct answer. &lt;font color=&quot;red&quot;&gt;    class test {        public static void main(String args[]) {         int i,j=0;         for(i=10;i&amp;lt;0;i--) { j++; }         switch(j) {         case (0) :             j=j+1;         case(1):             j=j+2;             break;         case (2) :             j=j+3;             break;                  case (10) :             j=j+10;             break;         default :             break;         }       System.out.println(j);       }    }    &lt;/font&gt;      &lt;ol&gt;  &lt;li&gt;0   &lt;/li&gt;&lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;3   &lt;/li&gt;&lt;li&gt;10   &lt;/li&gt;&lt;li&gt;20 &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What is the number displayed when the following program is compiled and run. &lt;font color=&quot;red&quot;&gt;    class test {        public static void main(String args[]) {            test test1 = new test();                System.out.println(test1.xyz(100));            }        public int xyz(int num) {            if(num == 1) return 1;            else return(xyz(num-1) + num);        }    }    &lt;/font&gt;    &lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of the following statements are true. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;Arrays in Java are essentially objects.   &lt;/li&gt;&lt;li&gt;It is not possible to assign one array to another. Individual elements of array can however be assigned.   &lt;/li&gt;&lt;li&gt;Array elements are indexed from 1 to size of array.   &lt;/li&gt;&lt;li&gt;If a method tries to access an array element beyond its range, a compile warning is generated. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which expression can be used to access the last element of an array. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;array[array.length()]   &lt;/li&gt;&lt;li&gt;array[array.length() - 1]   &lt;/li&gt;&lt;li&gt;array[array.length]   &lt;/li&gt;&lt;li&gt;array[array.length - 1] &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What is the result of compiling and running the following program. Select the one correct answer. &lt;font color=&quot;red&quot;&gt;    class test {        public static void main(String args[]) {            int[] arr = {1,2,3,4};            call_array(arr[0], arr);            System.out.println(arr[0] + &amp;quot;,&amp;quot; + arr[1]);                }        static void call_array(int i, int arr[]) {            arr[i] = 6;            i = 5;        }        }    &lt;/font&gt;      &lt;ol&gt;  &lt;li&gt;1,2   &lt;/li&gt;&lt;li&gt;5,2   &lt;/li&gt;&lt;li&gt;1,6   &lt;/li&gt;&lt;li&gt;5,6 &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of the following statements are correct. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;Each Java file must have exactly one package statement to specify where the class is stored.   &lt;/li&gt;&lt;li&gt;If a Java file has both import and package statement, the import statement must come before package statement.   &lt;/li&gt;&lt;li&gt;A Java file has at least one class defined.   &lt;/li&gt;&lt;li&gt;If a Java file has a package statement, it must be the first statement (except comments). &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What happens when the following program is compiled and then the command &amp;quot;java check it out&amp;quot; is executed. Select the one correct answer. &lt;font color=&quot;red&quot;&gt;    class check {        public static void main(String args[]) {            System.out.println(args[args.length-2]);        }    }    &lt;/font&gt;      &lt;ol&gt;  &lt;li&gt;The program does not compile.   &lt;/li&gt;&lt;li&gt;The program compiles but generates ArrayIndexOutOfBoundsException exception.   &lt;/li&gt;&lt;li&gt;The program prints java   &lt;/li&gt;&lt;li&gt;The program prints check   &lt;/li&gt;&lt;li&gt;The program prints it   &lt;/li&gt;&lt;li&gt;The program prints out &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What all gets printed when the following code is compiled and run. Select the three correct answers. &lt;font color=&quot;red&quot;&gt;    class test {        public static void main(String args[]) {            int i[] = {0,1};            try {                i[2] = i[0] + i[1];            }            catch(ArrayIndexOutOfBoundsException e1) {                System.out.println(&amp;quot;1&amp;quot;);            }            catch(Exception e2) {                System.out.println(&amp;quot;2&amp;quot;);            }            finally {                System.out.println(3);            }            System.out.println(&amp;quot;4&amp;quot;);           }    }    &lt;/font&gt;      &lt;ol&gt;  &lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;3   &lt;/li&gt;&lt;li&gt;4 &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;A program needs to store the name, salary, and age of employees in years. Which of the following data types should be used to create the Employee class. Select the three correct answers.   &lt;ol&gt;  &lt;li&gt;char   &lt;/li&gt;&lt;li&gt;boolean   &lt;/li&gt;&lt;li&gt;Boolean   &lt;/li&gt;&lt;li&gt;String   &lt;/li&gt;&lt;li&gt;int   &lt;/li&gt;&lt;li&gt;double &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;To make a variable defined in a class accessible only to methods defined in the classes in same package, which of the following keyword should be used. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;By using the keyword package before the variable.   &lt;/li&gt;&lt;li&gt;By using the keyword private before the variable.   &lt;/li&gt;&lt;li&gt;By using the keyword protected before the variable.   &lt;/li&gt;&lt;li&gt;By using the keyword public before the variable.   &lt;/li&gt;&lt;li&gt;The variable should not be preceded by any of the above mentioned keywords. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;In implementing two classes Employee and Manager, such that each Manager is an Employee, what should be the relationship between these classes. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;Employee should be the base class of Manager class.   &lt;/li&gt;&lt;li&gt;Manager should be the base class of Employee class.   &lt;/li&gt;&lt;li&gt;Manager class should include the Employee class as a data member.   &lt;/li&gt;&lt;li&gt;Employee class should include Manager class as a data member.   &lt;/li&gt;&lt;li&gt;The Manager and Employee should not have any relationship. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Select the one most appropriate answer. What is the purpose of method parseInt defined in Integer class.   &lt;ol&gt;  &lt;li&gt;The method converts an integer to a String.   &lt;/li&gt;&lt;li&gt;The method is used to convert String to an integer, assuming that the String represents an integer.   &lt;/li&gt;&lt;li&gt;The method is used to convert String to Integer class, assuming that the String represents an integer.   &lt;/li&gt;&lt;li&gt;The method converts the Integer object to a String. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What should be done to invoke the run() method on a thread for an object derived from the Thread class. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;The run() method should be directly invoked on the Object.   &lt;/li&gt;&lt;li&gt;The start() method should be directly invoked on the Object.   &lt;/li&gt;&lt;li&gt;The init() method should be directly invoked on the Object.   &lt;/li&gt;&lt;li&gt;The creation of the object using the new operator would create a new thread and invoke its run() method. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;What is the default priority of a newly created thread.   &lt;ol&gt;  &lt;li&gt;MIN_PRIORITY (which is defined as 1 in the Thread class.)   &lt;/li&gt;&lt;li&gt;NORM_PRIORITY (which is defined as 5 in the Thread class.)   &lt;/li&gt;&lt;li&gt;MAX_PRIORITY (which is defined as 10 in the Thread class.)   &lt;/li&gt;&lt;li&gt;A thread inherits the priority of its parent thread. &lt;/li&gt;&lt;/ol&gt;  The remaining questions are from AWT and related topics, and are not relevant for SCJP 1.4 .     &lt;/li&gt;&lt;li&gt;Which of following correctly describes the functionality of the method drawRect(int a, int b, int c, int d) defined in jawa.awt.Graphics class. Select the one correct option.   &lt;ol&gt;  &lt;li&gt;Draws the outline of a rectangle with a, b being the x,y co-ordinates of top left corner, and c,d being the x,y co-ordinates of the bottom right corner.   &lt;/li&gt;&lt;li&gt;Draws the outline of a rectangle with a, b being the x,y co-ordinates of top left corner, and c,d being the width and height of the rectangle.   &lt;/li&gt;&lt;li&gt;Draws a filled rectangle with a, b being the x,y co-ordinates of top left corner, and c,d being the x,y co-ordinates of the bottom right corner.   &lt;/li&gt;&lt;li&gt;Draws a filled rectangle with a, b being the x,y co-ordinates of top left corner, and c,d being the width and height of the rectangle. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which Listener interface must be implemented by a class responsible for handling mouse clicks on buttons? &lt;br&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;The getSource method defined in the EventObject class returns the source of an event. What is the return type of this getSource method?   &lt;ol&gt;  &lt;li&gt;EventObject   &lt;/li&gt;&lt;li&gt;Event   &lt;/li&gt;&lt;li&gt;Object   &lt;/li&gt;&lt;li&gt;Component   &lt;/li&gt;&lt;li&gt;Button &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;The focusLost method is defined in FocusListener interface and is executed when a control loses focus. What is the argument of focusLost method? &lt;br&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of the following is the super class of these classes - ContainterEvent, FocusEvent, InputEvent, PaintEvent, WindowEvent. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;ActionEvent   &lt;/li&gt;&lt;li&gt;AdjustmentEvent   &lt;/li&gt;&lt;li&gt;ComponentEvent   &lt;/li&gt;&lt;li&gt;ItemEvent   &lt;/li&gt;&lt;li&gt;TextEvent   &lt;/li&gt;&lt;li&gt;Event &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of these are adapter classes. Select the three correct answers.   &lt;ol&gt;  &lt;li&gt;ComponentAdapter   &lt;/li&gt;&lt;li&gt;ItemAdapter   &lt;/li&gt;&lt;li&gt;ActionAdapter   &lt;/li&gt;&lt;li&gt;KeyAdapter   &lt;/li&gt;&lt;li&gt;ContainerAdapter &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of the following statements about layout managers is true. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;FlowLayout places components left-aligned in a row (by default) and when there is no space in a row, another row is started.   &lt;/li&gt;&lt;li&gt;FlowLayout provides a constructor Flowlayout(int align, int x, int y), where x and y are the coordinates of the first component being added.   &lt;/li&gt;&lt;li&gt;The FlowLayout is the default layout manager for Window class   &lt;/li&gt;&lt;li&gt;Default horizontal and vertical gaps of components placed using FlowLayout is 5 pixels. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of the following is true about BorderLayout. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;The default layout manager for Applet class is BorderLayout.   &lt;/li&gt;&lt;li&gt;BorderLayout places components in North, South, East and West first and then the remaining space is occupied by the Center component.   &lt;/li&gt;&lt;li&gt;When a component is added in BorderLayout using the add method, it is placed in the center by default.   &lt;/li&gt;&lt;li&gt;The BorderLayout always honors the size of components provided by the program. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;  &lt;/li&gt;&lt;li&gt;Which of these is true about the GridBagLayout. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;The weightx and weighty fields of GridBagConstraints specify how many column and rows each component occupies.   &lt;/li&gt;&lt;li&gt;The gridwidth and gridheight constraints of GridBagConstraints specify the width and height in pixels of each cell.   &lt;/li&gt;&lt;li&gt;GridBagLayout is the default layout manager of the Frame class.   &lt;/li&gt;&lt;li&gt;The gridx and gridy parameters of GridBagConstraints define the column and row position of the upper left corner of the component. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;br&gt; &lt;br&gt;&lt;b&gt;Answers to Sample Test 2 &lt;/b&gt;&lt;br&gt;  &lt;ol&gt;  &lt;li&gt;c, d, f   &lt;/li&gt;&lt;li&gt;c. The main method must be static and return void. Hence a and b are incorrect. It must take an array of String as argument. Hence e and f are incorrect. As Java is case sensitive, d is incorrect.   &lt;/li&gt;&lt;li&gt;a, d   &lt;/li&gt;&lt;li&gt;List   &lt;/li&gt;&lt;li&gt;e. The collection interface Map has two implementation HashMap and Hashtable.   &lt;/li&gt;&lt;li&gt;a. Local variables are not initialized by default. They must be initialized before they are used.   &lt;/li&gt;&lt;li&gt;d. The variable i gets initialized to zero. The while loop does not get executed.   &lt;/li&gt;&lt;li&gt;c. During various iterations of three loops, the only time i, j and k have same values are when all of them are set to 2.   &lt;/li&gt;&lt;li&gt;0x17 or 0X17.   &lt;/li&gt;&lt;li&gt;e. The statement &amp;quot;i=2&amp;quot; evaluates to 2. The expression within the if block must evaluate to a boolean.   &lt;/li&gt;&lt;li&gt;e. The range of short primitive type is -32768 to 32767.   &lt;/li&gt;&lt;li&gt;c,d. Java does not allow casts between boolean values and any numeric types. Hence a is incorrect. Assigning double to a float requires an explicit cast. Hence b and e are incorrect.   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;e   &lt;/li&gt;&lt;li&gt;b. Both Strings test and test2 contain &amp;quot;abcd&amp;quot; . They are however located at different memory addresses. Hence test == test2 returns false, and test.equals(test2) returns true.   &lt;/li&gt;&lt;li&gt;d. The for loop does not get executed even once as the condition (i &amp;lt; 0) fails in the first iteration. In the switch statement, the statement j = j +1; gets executed, setting j to 1. As there is no break after this case, the next statement also gets executed setting j to 3.   &lt;/li&gt;&lt;li&gt;5050. The recursive function xyz essentially sums up numbers 1 to num. This evaluates to (num * (num + 1))/2.   &lt;/li&gt;&lt;li&gt;a. Java supports assignment of one array to another. Hence b is incorrect. Array elements are indexed from 0. Hence c is incorrect. A method that accesses array elements out of its range does not generate a compilation error. Hence d is incorrect.   &lt;/li&gt;&lt;li&gt;d. array.length gives the number of elements in the array. As indexes in Java start from 0, d is the correct answer.   &lt;/li&gt;&lt;li&gt;c. In the invocation of call_array, the first element is invoked using call-by-value, and the second using call-by-reference.   &lt;/li&gt;&lt;li&gt;d. import statement, package statement and class definitions are all optional in a file. Hence a and c are incorrect. If both import and package statements are present in a file, then package statement must appear before the import statement. Hence b is incorrect.   &lt;/li&gt;&lt;li&gt;e. The args array consists of two elements &amp;quot;it&amp;quot; and &amp;quot;out&amp;quot;. args.length is set to two.   &lt;/li&gt;&lt;li&gt;a,c,d. The exception ArrayIndexOutOfBoundsException is generated as the main method tries to access i[2]. Hence 1 gets printed. After this finally block gets excuted, before the program exits.   &lt;/li&gt;&lt;li&gt;d,e,f   &lt;/li&gt;&lt;li&gt;e. A data member that does not have public/protected/private is accessible to all methods in the same package.   &lt;/li&gt;&lt;li&gt;a. The Manager and Employee share as &amp;quot;is a&amp;quot; relationship - A Manager is an Employee. This is captured by making Employee the base class of Manager.   &lt;/li&gt;&lt;li&gt;b. The method int parseInt(Sting s) returns the integer value corresponding to input String, assuming that the input string represents an integer in base 10.   &lt;/li&gt;&lt;li&gt;b. The start() method invokes the run() method when the thread is ready to execute.   &lt;/li&gt;&lt;li&gt;d   &lt;/li&gt;&lt;li&gt;b. drawRect method draws the outline of a rectangle. The last two arguments are width and height of the rectangle.   &lt;/li&gt;&lt;li&gt;ActionListener   &lt;/li&gt;&lt;li&gt;c. The getSource method returns a reference to the object where the event initially occurred.   &lt;/li&gt;&lt;li&gt;FocusEvent. A class implementing FocusListener interface must implement the following method - &lt;br&gt;   public void focusLost(FocusEvent)&lt;br&gt;   public void focusGained(FocusEvent)&lt;br&gt;  &lt;/li&gt;&lt;li&gt;c   &lt;/li&gt;&lt;li&gt;a,d,e. There are no adapter classes corresponding to the following interfaces - ActionListener, ItemListener, AdjustmentListener, and TextListener.   &lt;/li&gt;&lt;li&gt;d. The default alignment for FlowLayout is CENTER. Hence a is incorrect. The default Layout Manager for Window class is BorderLayout. Hence c is incorrect. X and y in option b indicate horizontal and vertical gaps between components.   &lt;/li&gt;&lt;li&gt;b,c. The default Layout Manager for Applet class is FlowLayout. Hence a is incorrect. BorderLayout grows all components to fill the space available. Hence d is incorrect.   &lt;/li&gt;&lt;li&gt;d. The weightx and weighty specify how the size of a cell should change when the container exceeds the preferred size of component. Hence a is not correct. gridwidth and gridheight specify how many columns and rows the component specifies. So b is incorrect. BorderLayout is the default layout manager for Frame class. &lt;/li&gt;&lt;/ol&gt;         &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>mock Exam 1</title><link>http://faqworldofrastogi.wetpaint.com/page/mock+Exam+1</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/mock+Exam+1</guid><pubDate>Mon, 12 Nov 2007 22:57:02 CST</pubDate><description>&lt;ol&gt;  &lt;li&gt;  &lt;table align=&quot;bottom&quot; cellpadding=&quot;3&quot; class=&quot;wp-border-all&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  &lt;ol&gt;  &lt;li&gt;Which declaration of the main method below would allow a class to be started as a standalone program. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;public static int main(char args[])   &lt;/li&gt;&lt;li&gt;public static void main(String args[])   &lt;/li&gt;&lt;li&gt;public static void MAIN(String args[])   &lt;/li&gt;&lt;li&gt;public static void main(String args)   &lt;/li&gt;&lt;li&gt;public static void main(char args[]) &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What all gets printed when the following code is compiled and run? Select the three correct answers. &lt;font color=&quot;red&quot;&gt;  public class xyz {     public static void main(String args[]) {        for(int i = 0; i &amp;lt; 2; i++) {           for(int j = 2; j&amp;gt;= 0; j--) {              if(i == j) break;              System.out.println(&amp;quot;i=&amp;quot; + i + &amp;quot; j=&amp;quot;+j);           }        }     }  }  &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;i=0 j=0   &lt;/li&gt;&lt;li&gt;i=0 j=1   &lt;/li&gt;&lt;li&gt;i=0 j=2   &lt;/li&gt;&lt;li&gt;i=1 j=0   &lt;/li&gt;&lt;li&gt;i=1 j=1   &lt;/li&gt;&lt;li&gt;i=1 j=2   &lt;/li&gt;&lt;li&gt;i=2 j=0   &lt;/li&gt;&lt;li&gt;i=2 j=1   &lt;/li&gt;&lt;li&gt;i=2 j=2 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What gets printed when the following code is compiled and run with the following command - &lt;br&gt;java test 2 &lt;br&gt;Select the one correct answer.&lt;br&gt;&lt;font color=&quot;red&quot;&gt;  public class test {     public static void main(String args[]) {         Integer intObj=Integer.valueOf(args[args.length-1]);        int i = intObj.intValue();          if(args.length &amp;gt; 1)            System.out.println(i);        if(args.length &amp;gt; 0)           System.out.println(i - 1);        else            System.out.println(i - 2);     }  }            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;test   &lt;/li&gt;&lt;li&gt;test -1   &lt;/li&gt;&lt;li&gt;0   &lt;/li&gt;&lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;In Java technology what expression can be used to represent number of elements in an array named arr ?   &lt;/li&gt;&lt;li&gt;How would the number 5 be represented in hex using up-to four characters.   &lt;/li&gt;&lt;li&gt;Which of the following is a Java keyword. Select the four correct answers.   &lt;ol&gt;  &lt;li&gt;extern   &lt;/li&gt;&lt;li&gt;synchronized   &lt;/li&gt;&lt;li&gt;volatile   &lt;/li&gt;&lt;li&gt;friend   &lt;/li&gt;&lt;li&gt;friendly   &lt;/li&gt;&lt;li&gt;transient   &lt;/li&gt;&lt;li&gt;this   &lt;/li&gt;&lt;li&gt;then &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Is the following statement true or false. The constructor of a class must not have a return type.   &lt;ol&gt;  &lt;li&gt;true   &lt;/li&gt;&lt;li&gt;false &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What is the number of bytes used by Java primitive long. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;The number of bytes is compiler dependent.   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;4   &lt;/li&gt;&lt;li&gt;8   &lt;/li&gt;&lt;li&gt;64 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What is returned when the method substring(2, 4) is invoked on the string &amp;quot;example&amp;quot;? Include the answer in quotes as the result is of type String.   &lt;/li&gt;&lt;li&gt;Which of the following is correct? Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;The native keyword indicates that the method is implemented in another language like C/C++.   &lt;/li&gt;&lt;li&gt;The only statements that can appear before an import statement in a Java file are comments.   &lt;/li&gt;&lt;li&gt;The method definitions inside interfaces are public and abstract. They cannot be private or protected.   &lt;/li&gt;&lt;li&gt;A class constructor may have public or protected keyword before them, nothing else. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What is the result of evaluating the expression 14 ^ 23. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;25   &lt;/li&gt;&lt;li&gt;37   &lt;/li&gt;&lt;li&gt;6   &lt;/li&gt;&lt;li&gt;31   &lt;/li&gt;&lt;li&gt;17   &lt;/li&gt;&lt;li&gt;9   &lt;/li&gt;&lt;li&gt;24 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of the following are true. Select the one correct answers.   &lt;ol&gt;  &lt;li&gt;&amp;amp;&amp;amp; operator is used for short-circuited logical AND.   &lt;/li&gt;&lt;li&gt;~ operator is the bit-wise XOR operator.   &lt;/li&gt;&lt;li&gt;| operator is used to perform bitwise OR and also short-circuited logical OR.   &lt;/li&gt;&lt;li&gt;The unsigned right shift operator in Java is &amp;gt;&amp;gt;. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Name the access modifier which when used with a method, makes it available to all the classes in the same package and to all the subclasses of the class.   &lt;/li&gt;&lt;li&gt;Which of the following is true. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;A class that is abstract may not be instantiated.   &lt;/li&gt;&lt;li&gt;The final keyword indicates that the body of a method is to be found elsewhere. The code is written in non-Java language, typically in C/C++.   &lt;/li&gt;&lt;li&gt;A static variable indicates there is only one copy of that variable.   &lt;/li&gt;&lt;li&gt;A method defined as private indicates that it is accessible to all other classes in the same package. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What all gets printed when the following program is compiled and run. Select the two correct answers. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;  public class test {     public static void main(String args[]) {         int i, j=1;        i = (j&amp;gt;1)?2:1;        switch(i) {          case 0: System.out.println(0); break;          case 1: System.out.println(1);          case 2: System.out.println(2); break;          case 3: System.out.println(3); break;        }     }  }            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;0   &lt;/li&gt;&lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;3 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What all gets printed when the following program is compiled and run. Select the one correct answer. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;  public class test {     public static void main(String args[]) {         int i=0, j=2;        do {           i=++i;           j--;        } while(j&amp;gt;0);        System.out.println(i);     }  }            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;0   &lt;/li&gt;&lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;The program does not compile because of statement &amp;quot;i=++i;&amp;quot; &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What all gets printed when the following gets compiled and run. Select the three correct answers. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;  public class test {      public static void main(String args[]) {           int i=1, j=1;          try {              i++;               j--;              if(i/j &amp;gt; 1)                  i++;          }          catch(ArithmeticException e) {              System.out.println(0);          }          catch(ArrayIndexOutOfBoundsException e) {              System.out.println(1);          }          catch(Exception e) {              System.out.println(2);          }          finally {              System.out.println(3);          }          System.out.println(4);       }  }            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;0   &lt;/li&gt;&lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;3   &lt;/li&gt;&lt;li&gt;4 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What all gets printed when the following gets compiled and run. Select the two correct answers. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;  public class test {      public static void main(String args[]) {           int i=1, j=1;          try {              i++;               j--;              if(i == j)                  i++;          }          catch(ArithmeticException e) {              System.out.println(0);          }          catch(ArrayIndexOutOfBoundsException e) {              System.out.println(1);          }          catch(Exception e) {              System.out.println(2);          }          finally {              System.out.println(3);          }          System.out.println(4);       }  }            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;0   &lt;/li&gt;&lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;3   &lt;/li&gt;&lt;li&gt;4 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What all gets printed when the following gets compiled and run. Select the two correct answers. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;  public class test {      public static void main(String args[]) {       String s1 = &amp;quot;abc&amp;quot;;      String s2 = &amp;quot;abc&amp;quot;;      if(s1 == s2)          System.out.println(1);      else          System.out.println(2);      if(s1.equals(s2))          System.out.println(3);      else          System.out.println(4);      }  }            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;3   &lt;/li&gt;&lt;li&gt;4 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What all gets printed when the following gets compiled and run. Select the two correct answers. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;  public class test {      public static void main(String args[]) {       String s1 = &amp;quot;abc&amp;quot;;      String s2 = new String(&amp;quot;abc&amp;quot;);        if(s1 == s2)          System.out.println(1);      else          System.out.println(2);      if(s1.equals(s2))          System.out.println(3);      else          System.out.println(4);      }  }            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;3   &lt;/li&gt;&lt;li&gt;4 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of the following are legal array declarations. Select the three correct answers.   &lt;ol&gt;  &lt;li&gt;int i[5][];   &lt;/li&gt;&lt;li&gt;int i[][];   &lt;/li&gt;&lt;li&gt;int []i[];   &lt;/li&gt;&lt;li&gt;int i[5][5];   &lt;/li&gt;&lt;li&gt;int[][] a; &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What is the range of values that can be specified for an int. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;The range of values is compiler dependent.   &lt;/li&gt;&lt;li&gt;-231 to 231 - 1   &lt;/li&gt;&lt;li&gt;-231-1 to 231   &lt;/li&gt;&lt;li&gt;-215 to 215 - 1   &lt;/li&gt;&lt;li&gt;-215-1 to 215 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;How can you ensure that the memory allocated by an object is freed. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;By invoking the free method on the object.   &lt;/li&gt;&lt;li&gt;By calling system.gc() method.   &lt;/li&gt;&lt;li&gt;By setting all references to the object to new values (say null).   &lt;/li&gt;&lt;li&gt;Garbage collection cannot be forced. The programmer cannot force the JVM to free the memory used by an object. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What gets printed when the following code is compiled and run. Select the one correct answer. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;  public class test {      public static void main(String args[]) {       int i = 1;      do {          i--;      } while (i &amp;gt; 2);      System.out.println(i);      }  }            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;0   &lt;/li&gt;&lt;li&gt;1   &lt;/li&gt;&lt;li&gt;2   &lt;/li&gt;&lt;li&gt;-1 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of these is a legal definition of a method named m assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;void m() throws IOException{}   &lt;/li&gt;&lt;li&gt;void m() throw IOException{}   &lt;/li&gt;&lt;li&gt;void m(void) throws IOException{}   &lt;/li&gt;&lt;li&gt;m() throws IOException{}   &lt;/li&gt;&lt;li&gt;void m() {} throws IOException &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of the following are legal identifier names in Java. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;%abcd   &lt;/li&gt;&lt;li&gt;$abcd   &lt;/li&gt;&lt;li&gt;1abcd   &lt;/li&gt;&lt;li&gt;package   &lt;/li&gt;&lt;li&gt;_a_long_name &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;At what stage in the following method does the object initially referenced by s becomes available for garbage collection. Select the one correct answer. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;  void method X()  {       String r = new String(&amp;quot;abc&amp;quot;);      String s = new String(&amp;quot;abc&amp;quot;);      r = r+1; //1      r = null; //2      s = s + r; //3  } //4            &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;Before statement labeled 1   &lt;/li&gt;&lt;li&gt;Before statement labeled 2   &lt;/li&gt;&lt;li&gt;Before statement labeled 3   &lt;/li&gt;&lt;li&gt;Before statement labeled 4   &lt;/li&gt;&lt;li&gt;Never. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;&lt;font color=&quot;red&quot;&gt;String s = new String(&amp;quot;xyz&amp;quot;); &lt;/font&gt;&lt;br&gt;Assuming the above declaration, which of the following statements would compile. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;s = 2 * s;   &lt;/li&gt;&lt;li&gt;int i = s[0];   &lt;/li&gt;&lt;li&gt;s = s + s;   &lt;/li&gt;&lt;li&gt;s = s &amp;gt;&amp;gt; 2;   &lt;/li&gt;&lt;li&gt;None of the above. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of the following statements related to Garbage Collection are correct. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;It is possible for a program to free memory at a given time.   &lt;/li&gt;&lt;li&gt;Garbage Collection feature of Java ensures that the program never runs out of memory.   &lt;/li&gt;&lt;li&gt;It is possible for a program to make an object available for Garbage Collection.   &lt;/li&gt;&lt;li&gt;The finalize method of an object is invoked before garbage collection is performed on the object. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;If a base class has a method defined as &lt;br&gt;void method() { } &lt;br&gt;Which of the following are legal prototypes in a derived class of this class. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;void method() { }   &lt;/li&gt;&lt;li&gt;int method() { return 0;}   &lt;/li&gt;&lt;li&gt;void method(int i) { }   &lt;/li&gt;&lt;li&gt;private void method() { } &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;In which all cases does an exception gets generated. Select the two correct answers. &lt;br&gt;&lt;font color=&quot;red&quot;&gt;int i = 0, j = 1; &lt;/font&gt;&lt;br&gt;  &lt;ol&gt;  &lt;li&gt;if((i == 0) || (j/i == 1))   &lt;/li&gt;&lt;li&gt;if((i == 0) | (j/i == 1))   &lt;/li&gt;&lt;li&gt;if((i != 0) &amp;amp;&amp;amp; (j/i == 1))   &lt;/li&gt;&lt;li&gt;if((i != 0) &amp;amp; (j/i == 1)) &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of the following statements are true. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;The wait method defined in the Thread class, can be used to convert a thread from Running state to Waiting state.   &lt;/li&gt;&lt;li&gt;The wait(), notify(), and notifyAll() methods must be executed in synchronized code.   &lt;/li&gt;&lt;li&gt;The notify() and notifyAll() methods can be used to signal and move waiting threads to ready-to-run state.   &lt;/li&gt;&lt;li&gt;The Thread class is an abstract class. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which keyword when applied on a method indicates that only one thread should execute the method at a time. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;transient   &lt;/li&gt;&lt;li&gt;volatile   &lt;/li&gt;&lt;li&gt;synchronized   &lt;/li&gt;&lt;li&gt;native   &lt;/li&gt;&lt;li&gt;static   &lt;/li&gt;&lt;li&gt;final &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What is the name of the Collection interface used to represent elements in a sequence (in a particular order). Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;Collection   &lt;/li&gt;&lt;li&gt;Set   &lt;/li&gt;&lt;li&gt;List   &lt;/li&gt;&lt;li&gt;Map &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of these classes implement the Collection interface SortedMap. Select the one correct answers.   &lt;ol&gt;  &lt;li&gt;HashMap   &lt;/li&gt;&lt;li&gt;Hashtable   &lt;/li&gt;&lt;li&gt;TreeMap   &lt;/li&gt;&lt;li&gt;HashSet   &lt;/li&gt;&lt;li&gt;TreeSet   &lt;/li&gt;&lt;li&gt;Vector &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of the following are true about interfaces. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;Methods declared in interfaces are implicitly private.   &lt;/li&gt;&lt;li&gt;Variables declared in interfaces are implicitly public, static, and final.   &lt;/li&gt;&lt;li&gt;An interface can extend any number of interfaces.   &lt;/li&gt;&lt;li&gt;The keyword implements indicate that an interface inherits from another. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Assume that class A extends class B, which extends class C. Also all the three classes implement the method test(). How can a method in a class A invoke the test() method defined in class C (without creating a new instance of class C). Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;test();   &lt;/li&gt;&lt;li&gt;super.test();   &lt;/li&gt;&lt;li&gt;super.super.test();   &lt;/li&gt;&lt;li&gt;::test();   &lt;/li&gt;&lt;li&gt;C.test();   &lt;/li&gt;&lt;li&gt;It is not possible to invoke test() method defined in C from a method in A. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;What is the return type of method round(double d) defined in Math class.   &lt;/li&gt;&lt;li&gt;What gets written on the screen when the following program is compiled and run. Select the one right answer. &lt;font color=&quot;red&quot;&gt;  public class test {     public static void main(String args[]) {      int i;     float  f = 2.3f;     double d = 2.7;     i = ((int)Math.ceil(f)) * ((int)Math.round(d));        System.out.println(i);     }  }  &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;4   &lt;/li&gt;&lt;li&gt;5   &lt;/li&gt;&lt;li&gt;6   &lt;/li&gt;&lt;li&gt;6.1   &lt;/li&gt;&lt;li&gt;9 &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Is the following statement true or false. As the toString method is defined in the Object class, System.out.println can be used to print any object.   &lt;ol&gt;  &lt;li&gt;true   &lt;/li&gt;&lt;li&gt;false &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of these classes defined in java.io and used for file-handling are abstract. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;InputStream   &lt;/li&gt;&lt;li&gt;PrintStream   &lt;/li&gt;&lt;li&gt;Reader   &lt;/li&gt;&lt;li&gt;FileInputStream   &lt;/li&gt;&lt;li&gt;FileWriter &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Name the collection interface used to represent collections that maintain unique elements.   &lt;/li&gt;&lt;li&gt;What is the result of compiling and running the following program. &lt;font color=&quot;red&quot;&gt;  public class test {     public static void main(String args[]) {         String str1=&amp;quot;abc&amp;quot;;        String str2=&amp;quot;def&amp;quot;;        String str3=str1.concat(str2);          str1.concat(str2);        System.out.println(str1);     }  }  &lt;/font&gt;    &lt;ol&gt;  &lt;li&gt;abc   &lt;/li&gt;&lt;li&gt;def   &lt;/li&gt;&lt;li&gt;abcabc   &lt;/li&gt;&lt;li&gt;abcdef   &lt;/li&gt;&lt;li&gt;defabc   &lt;/li&gt;&lt;li&gt;abcdefdef &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Select the one correct answer. The number of characters in an object of a class String is given by   &lt;ol&gt;  &lt;li&gt;The member variable called size   &lt;/li&gt;&lt;li&gt;The member variable called length   &lt;/li&gt;&lt;li&gt;The method size() returns the number of characters.   &lt;/li&gt;&lt;li&gt;The method length() returns the number of characters. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Select the one correct answer. Which method defined in Integer class can be used to convert an Integer object to primitive int type.   &lt;ol&gt;  &lt;li&gt;valueOf   &lt;/li&gt;&lt;li&gt;intValue   &lt;/li&gt;&lt;li&gt;getInt   &lt;/li&gt;&lt;li&gt;getInteger &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Name the return type of method hashCode() defined in Object class, which is used to get the unique hash value of an Object.   &lt;/li&gt;&lt;li&gt;Which of the following are correct. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;An import statement, if defined, must always be the first non-comment statement of the file.   &lt;/li&gt;&lt;li&gt;private members are accessible to all classes in the same package.   &lt;/li&gt;&lt;li&gt;An abstract class can be declared as final.   &lt;/li&gt;&lt;li&gt;Local variables cannot be declared as static. &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;static   &lt;/li&gt;&lt;li&gt;final   &lt;/li&gt;&lt;li&gt;abstract   &lt;/li&gt;&lt;li&gt;native   &lt;/li&gt;&lt;li&gt;volatile   &lt;/li&gt;&lt;li&gt;transient &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of these are core interfaces in the collection framework. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;Tree   &lt;/li&gt;&lt;li&gt;Stack   &lt;/li&gt;&lt;li&gt;Queue   &lt;/li&gt;&lt;li&gt;Array   &lt;/li&gt;&lt;li&gt;LinkedList   &lt;/li&gt;&lt;li&gt;Map &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of these statements are true. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;For each try block there must be at least one catch block defined.   &lt;/li&gt;&lt;li&gt;A try block may be followed by any number of finally blocks.   &lt;/li&gt;&lt;li&gt;A try block must be followed by at least one finally or catch block.   &lt;/li&gt;&lt;li&gt;If both catch and finally blocks are defined, catch block must precede the finally block. &lt;/li&gt;&lt;/ol&gt;  The remaining questions are related to AWT, event classes, and layout managers. These topics are not included in 1.4 version of the exam.     &lt;/li&gt;&lt;li&gt;The default layout manager for a Frame is ...   &lt;ol&gt;  &lt;li&gt;FlowLayout   &lt;/li&gt;&lt;li&gt;BorderLayout   &lt;/li&gt;&lt;li&gt;GridLayout   &lt;/li&gt;&lt;li&gt;GridBagLayout   &lt;/li&gt;&lt;li&gt;CardLayout &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of the following are valid adapter classes in Java. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;ComponentAdapter   &lt;/li&gt;&lt;li&gt;ActionAdapter   &lt;/li&gt;&lt;li&gt;AdjustmentAdapter   &lt;/li&gt;&lt;li&gt;ItemAdapter   &lt;/li&gt;&lt;li&gt;FocusAdapter &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which method defined in the EventObject class returns the Object that generated an event. The method should be given in the format - return_type method_name();   &lt;/li&gt;&lt;li&gt;Which of the following object receives ActionEvent. Select the four correct answers.   &lt;ol&gt;  &lt;li&gt;List   &lt;/li&gt;&lt;li&gt;Button   &lt;/li&gt;&lt;li&gt;Choice   &lt;/li&gt;&lt;li&gt;CheckBox   &lt;/li&gt;&lt;li&gt;TextField   &lt;/li&gt;&lt;li&gt;MenuItem &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Name the class that may be used to create submenus in pull-down menus.   &lt;/li&gt;&lt;li&gt;In which class is the wait() method defined. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;Applet   &lt;/li&gt;&lt;li&gt;Runnable   &lt;/li&gt;&lt;li&gt;Thread   &lt;/li&gt;&lt;li&gt;Object &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which is the only layout manager that always honors the size of a component. Select the one correct answer.   &lt;ol&gt;  &lt;li&gt;FlowLayout   &lt;/li&gt;&lt;li&gt;GridLayout   &lt;/li&gt;&lt;li&gt;BorderLayout   &lt;/li&gt;&lt;li&gt;CardLayout   &lt;/li&gt;&lt;li&gt;GridBagLayout &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which of these are valid Event Listener interfaces. Select the two correct answers.   &lt;ol&gt;  &lt;li&gt;MouseMotionListener   &lt;/li&gt;&lt;li&gt;WindowListener   &lt;/li&gt;&lt;li&gt;DialogListener   &lt;/li&gt;&lt;li&gt;PaintListener &lt;/li&gt;&lt;/ol&gt;  &lt;/li&gt;&lt;li&gt;Which abstract class is the super class of all menu-related classes. &lt;/li&gt;&lt;/ol&gt;&lt;br&gt;&lt;b&gt;Answers to Sample Test 1 &lt;/b&gt;&lt;br&gt;  &lt;ol&gt;  &lt;li&gt;b   &lt;/li&gt;&lt;li&gt;b, c, f   &lt;/li&gt;&lt;li&gt;d. Note that the program gets one command line argument - 2. args.length will get set to 1. So the condition if(args.length &amp;gt; 1) will fail, and the second check if(args.length &amp;gt; 0) will return true.   &lt;/li&gt;&lt;li&gt;arr.length   &lt;/li&gt;&lt;li&gt;Any of these is correct - 0x5, 0x05, 0X05, 0X5   &lt;/li&gt;&lt;li&gt;b, c, f, g   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;d   &lt;/li&gt;&lt;li&gt;&amp;quot;am&amp;quot;   &lt;/li&gt;&lt;li&gt;a, c. Please note that b is not correct. A package statement may appear before an import statement. A class constructor may be declared private also. Hence d is incorrect.   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;protected   &lt;/li&gt;&lt;li&gt;a, c   &lt;/li&gt;&lt;li&gt;b, c   &lt;/li&gt;&lt;li&gt;c   &lt;/li&gt;&lt;li&gt;a, d, e   &lt;/li&gt;&lt;li&gt;d, e   &lt;/li&gt;&lt;li&gt;a, c   &lt;/li&gt;&lt;li&gt;b, c   &lt;/li&gt;&lt;li&gt;b, c, e   &lt;/li&gt;&lt;li&gt;b   &lt;/li&gt;&lt;li&gt;d   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;b, e . The option c is incorrect because a Java identifier name cannot begin with a digit.   &lt;/li&gt;&lt;li&gt;d   &lt;/li&gt;&lt;li&gt;c   &lt;/li&gt;&lt;li&gt;c, d   &lt;/li&gt;&lt;li&gt;a, c   &lt;/li&gt;&lt;li&gt;b, d   &lt;/li&gt;&lt;li&gt;b, c   &lt;/li&gt;&lt;li&gt;c   &lt;/li&gt;&lt;li&gt;c   &lt;/li&gt;&lt;li&gt;c   &lt;/li&gt;&lt;li&gt;b, c   &lt;/li&gt;&lt;li&gt;f   &lt;/li&gt;&lt;li&gt;long   &lt;/li&gt;&lt;li&gt;e   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;a, c   &lt;/li&gt;&lt;li&gt;Set   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;d   &lt;/li&gt;&lt;li&gt;b   &lt;/li&gt;&lt;li&gt;int   &lt;/li&gt;&lt;li&gt;d   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;f   &lt;/li&gt;&lt;li&gt;c, d   &lt;/li&gt;&lt;li&gt;b   &lt;/li&gt;&lt;li&gt;a, e   &lt;/li&gt;&lt;li&gt;Object getSource();   &lt;/li&gt;&lt;li&gt;a, b, e, f   &lt;/li&gt;&lt;li&gt;Menu   &lt;/li&gt;&lt;li&gt;d   &lt;/li&gt;&lt;li&gt;a   &lt;/li&gt;&lt;li&gt;a, b   &lt;/li&gt;&lt;li&gt;MenuComponent &lt;/li&gt;&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;/ol&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>java faq</title><link>http://faqworldofrastogi.wetpaint.com/page/java+faq</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/java+faq</guid><pubDate>Tue, 23 Oct 2007 06:05:45 CDT</pubDate><description>There is no abstract available for this page revision.&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>Answers Of Review Of Java Language</title><link>http://faqworldofrastogi.wetpaint.com/page/Answers+Of+Review+Of+Java+Language</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/Answers+Of+Review+Of+Java+Language</guid><pubDate>Fri, 14 Sep 2007 00:39:58 CDT</pubDate><description>  &lt;h3&gt;Answers Of Review Of Java Language&lt;/h3&gt;  &lt;h3&gt;1 Basics of Java Programming&lt;/h3&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec9.html#ch01qa1q1&quot; target=&quot;_top&quot;&gt;1.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;A method is an operation defining the behavior for a   particular abstraction. Java implements abstractions, using classes that have   properties and behavior. Behavior is dictated by the operations of the   abstraction.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec9.html#ch01qa1q2&quot; target=&quot;_top&quot;&gt;1.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;An object is an instance of a class. Objects are created   from class definitions that implement abstractions. The objects that are   created are concrete realizations of those abstractions.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec9.html#ch01qa1q3&quot; target=&quot;_top&quot;&gt;1.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The code marked with (2) is a constructor. A constructor in   Java is declared like a method, except that the name is identical to the class   name and it does not specify a return value.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec9.html#ch01qa1q4&quot; target=&quot;_top&quot;&gt;1.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (f)&lt;br&gt;Two objects and three reference variables are created by the   code. Objects are typically created by using the new operator. Declaration of a   reference variable creates a variable regardless of whether a reference value   is assigned to it or not.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec9.html#ch01qa1q5&quot; target=&quot;_top&quot;&gt;1.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;An instance member is a field or an instance method. These   members belong to an instance of the class rather than the class as a whole.   Members which are not explicitly declared static in a class definition are   instance members.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec9.html#ch01qa1q6&quot; target=&quot;_top&quot;&gt;1.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;An object can pass a message to another object by calling an   instance method of the other object.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec9.html#ch01qa1q7&quot; target=&quot;_top&quot;&gt;1.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d) and (f)&lt;br&gt;Given the declaration class B extends A {...} we can   conclude that class B   extends class A,   class A   is the superclass of class B, class B is a subclass of class A, and class B inherits   from class A,   which means that objects of class B will inherit the field value1 from   class A.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec12.html#ch01qa2q1&quot; target=&quot;_top&quot;&gt;1.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The compiler supplied with the Java 2 SDK is named javac. It   requires the names of the source files that should be compiled.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch01lev1sec12.html#ch01qa2q2&quot; target=&quot;_top&quot;&gt;1.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;Java programs are executed by the Java Virtual Machine   (JVM). In the Java 2 SDK, the command java is used to start the execution by   the JVM. The java   command requires the name of a class that has a valid main() method.   The JVM starts the program execution by calling the main() method   of the given class. The exact name of the class should be specified, and not   the name of the class file, that is, the &amp;quot;.class&amp;quot; extension in the   class file name should not be specified.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Language Fundamental&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec2.html#ch02qa1q1&quot; target=&quot;_top&quot;&gt;2.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;(c)&lt;/b&gt;52pickup is   not a legal identifier. The first character of an identifier cannot be a   digit.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec2.html#ch02qa1q2&quot; target=&quot;_top&quot;&gt;2.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;(e)&lt;/b&gt;In   Java, the identifiers delete,   thrown,   exit,   unsigned,   and next   are not keywords. Java has a goto keyword, but it is reserved and not currently   used.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec2.html#ch02qa1q3&quot; target=&quot;_top&quot;&gt;2.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   (b)It is a completely valid comment.   Comments do not nest. Everything from the start marker of a comment block (/*) until the   first occurrence of the end marker of the comment block (*/) is ignored   by the compiler.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec4.html#ch02qa2q1&quot; target=&quot;_top&quot;&gt;2.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (d)&lt;br&gt;String   is a class, and &amp;quot;hello&amp;quot;   and &amp;quot;t&amp;quot;   denote String   objects. Java only has the following primitive data types: boolean, byte, short, char, int, long, float, and double.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec4.html#ch02qa2q2&quot; target=&quot;_top&quot;&gt;2.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), and (e)&lt;br&gt;Type (a) is a boolean data type, while types (c) and (e) are   floating-point data types.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec4.html#ch02qa2q3&quot; target=&quot;_top&quot;&gt;2.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The bit representation of int is 32-bits wide and can hold   values in the range &amp;ndash;231 through 231&amp;ndash;1.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec7.html#ch02qa3q1&quot; target=&quot;_top&quot;&gt;2.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), and (d)&lt;br&gt;The \uxxxx notation can be   used anywhere in the source to represent unicode characters.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec7.html#ch02qa3q2&quot; target=&quot;_top&quot;&gt;2.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Local variable a is declared but not initialized. The first line   of code declares the local variables a and b. The second line of code initializes   the local variable b.   Local variable a   remains uninitialized.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec7.html#ch02qa3q3&quot; target=&quot;_top&quot;&gt;2.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The local variable of type float will remain uninitialized.   Fields receive a default value unless explicitly initialized. Local variables   remain uninitialized unless explicitly initialized. The type of the variable   does not affect whether a variable is initialized or not.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec9.html#ch02qa4q1&quot; target=&quot;_top&quot;&gt;2.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The class will fail to compile since the package declaration   can never occur after an import   statement. The package   and import   statements, if present, must always precede any class definitions. If a file   contains both import   statements and a package   statement, then the package   statement must occur before the import statements.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec9.html#ch02qa4q2&quot; target=&quot;_top&quot;&gt;2.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   true&lt;br&gt;Although nonsensical, an empty file is a valid source file.   A source file can contain an optional package declaration, any number of import   statements, and any number of class and interface definitions.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec11.html#ch02qa5q1&quot; target=&quot;_top&quot;&gt;2.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d) and (f)&lt;br&gt;The main()   method must be declared public,   static,   and void   and takes a single array of String objects as argument. The order of the static and public   keywords is irrelevant. Also, declaring the method final is   irrelevant in this respect.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch02lev1sec11.html#ch02qa5q2&quot; target=&quot;_top&quot;&gt;2.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), and (c)&lt;br&gt;Neither main,   string,   nor args   are reserved keywords, but they are legal identifiers. In the declaration public static void   main(String[] args), the identifier main denotes the method that is   the main entry point of a program. In all other contexts, the identifier main has no   predefined meaning.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Operator &amp;amp; Assinment&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec5.html#ch03qa1q1&quot; target=&quot;_top&quot;&gt;3.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;A value of type char can be assigned to a variable of   type int.   An implicit widening conversion will convert the value to an int.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec5.html#ch03qa1q2&quot; target=&quot;_top&quot;&gt;3.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;An assignment statement is an expression statement. The   value of the expression statement is the value of the expression on the right   hand side. Since the assignment operator is right associative, the statement a = b = c = 20   is evaluated as follows: (a   = (b = (c = 20))). This results in the value 20 being assigned to   variable c,   then the same value being assigned to variable b and finally to variable a. The program   will compile correctly and display 20 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec5.html#ch03qa1q3&quot; target=&quot;_top&quot;&gt;3.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Strings are objects. The variables a, b, and c are   references that can denote such objects. Assigning to a reference only   changes the reference value. It does not create a copy of the source object   or change the object denoted by the old reference value in the destination   reference. In other words, assignment to references only affects which object   the destination reference denotes. The reference value of the &amp;quot;cat&amp;quot;   object is first assigned to variable a, then to variable b, and later   to variable c.   The program prints the string denoted by the variable c, which is &amp;quot;cat&amp;quot;.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec7.html#ch03qa2q1&quot; target=&quot;_top&quot;&gt;3.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (d), and (e)&lt;br&gt;A binary expression with any floating-point operand will be   evaluated using floating-point arithmetic. Expressions such as 2/3, where   both operands are integers, will use integer arithmetic and evaluate to an   integer value.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec7.html#ch03qa2q2&quot; target=&quot;_top&quot;&gt;3.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The /   operator has higher precedence than the + operator. This means that the expression   is evaluated as ((1/2)   + (3/2) + 0.1). The associativity of the binary operators is from   left to right, giving (((1/2)   + (3/2)) + 0.1). Integer division results in ((0 + 1) + 0.1)   which evaluates to 1.1.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec7.html#ch03qa2q3&quot; target=&quot;_top&quot;&gt;3.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;0x10   is a hexadecimal literal equivalent to the decimal value 16. 10 is a decimal   literal. 010   is an octal literal equivalent to the decimal value 8. The println()   method will print the sum of these values, which is 34, in decimal form.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec7.html#ch03qa2q4&quot; target=&quot;_top&quot;&gt;3.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b), (c), and (f)&lt;br&gt;The unary + and - operators with right-to-left   associativity are used in the valid expressions (b), (c), and (f). Expression   (a) tries to use a nonexistent unary - operator with left-to-right   associativity, expression (d) tries to use a decrement operator (--) on an   expression that does not resolve to a variable, and expression (e) tries to   use a nonexistent unary *   operator.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec7.html#ch03qa2q5&quot; target=&quot;_top&quot;&gt;3.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The expression evaluates to &amp;ndash;6. The whole expression is   evaluated as (((-(-1))   - ((3 * 10) / 5)) - 1) according to the precedence and   associativity rules.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec7.html#ch03qa2q6&quot; target=&quot;_top&quot;&gt;3.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), (d), and (e)&lt;br&gt;In (a) the conditions for implicit narrowing conversion are   fulfilled: the source is a constant expression of type int, the destination   type is of type short,   the value of the source (12) is in the range of the destination type. The   assignments in (b), (d), and (e) are valid, since the source type is narrower   than the target type and an implicit widening conversion will be applied. The   expression (c) is not valid. Values of type boolean cannot be converted to other   types.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec10.html#ch03qa3q1&quot; target=&quot;_top&quot;&gt;3.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), and (d)&lt;br&gt;The left associativity of the + operator makes the evaluation   of (1 + 2 +   &amp;quot;3&amp;quot;) proceed as follows: (1 + 2) + &amp;quot;3&amp;quot; 3 + &amp;quot;3&amp;quot;   &amp;quot;33&amp;quot;. Evaluation of the   expression (&amp;quot;1&amp;quot;   + 2 + 3), however, will proceed as follows: (&amp;quot;1&amp;quot; + 2) + 3   &amp;quot;12&amp;quot; + 3 &amp;quot;123&amp;quot;. (4 + 1.0f)   evaluates as 4.0f   + 1.0f 5.0f and (10/9) performs integer   division, resulting in the value 1. The operand &amp;#39;a&amp;#39; in the expression (&amp;#39;a&amp;#39; + 1) will   be promoted to int,   and the resulting value will be of type int.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec10.html#ch03qa3q2&quot; target=&quot;_top&quot;&gt;3.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The expression ++k + k++ + + k is evaluated as ((++k) + (k++)) + (+k)   ((2) + (2) + (3)), resulting in the   value 7.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec10.html#ch03qa3q3&quot; target=&quot;_top&quot;&gt;3.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The types char and int are both integral. A char value can   be assigned to an int   variable since the int   type is wider than the char   type and an implicit widening conversion will be done. An int type   cannot be assigned to a char   variable because the char   type is narrower than the int   type. The compiler will report an error about a possible loss of precision in   the line labeled (4).   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec10.html#ch03qa3q4&quot; target=&quot;_top&quot;&gt;3.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Variables of type byte can store values in the range   &amp;ndash;128 to 127. The expression on the right-hand side of the first assignment is   the int   literal 128. Had this literal been in the range of the byte type, an   implicit narrowing conversion would have to be applied during assignment to   convert it to a byte   value. Since 128 is outside the valid range of type byte, the   compiler will not compile the code.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec10.html#ch03qa3q5&quot; target=&quot;_top&quot;&gt;3.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;First, the expression ++i is evaluated, resulting in the   value 2, Now the variable i   also has the value 2. The target of the assignment is now determined to be   the element array[2].   Evaluation of the right-hand expression, --i, results in the value 1. The   variable i   now has the value 1. The value of the right-hand expression 1 is then   assigned to the array element array[2], resulting in the array contents to   become {4, 8, 1}.   The program sums these values and prints 13.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec16.html#ch03qa4q1&quot; target=&quot;_top&quot;&gt;3.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (c)&lt;br&gt;The expression (4 &amp;lt;= 4) is true. The null literal can be compared,   so (null !=   null) yields false.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec16.html#ch03qa4q2&quot; target=&quot;_top&quot;&gt;3.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (e)&lt;br&gt;The remainder operator is not limited to integral values,   but can also be applied to floating-point operands. Identifiers in Java are   case sensitive. Operators *,   /,   and %   have the same level of precedence. Type short has the range -32768 to +32767   inclusive. (+15)   is a legal expression using the unary + operator.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec16.html#ch03qa4q3&quot; target=&quot;_top&quot;&gt;3.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), and (e)&lt;br&gt;The !=   and ^   operators, when used on boolean operands, will return true if and   only if one operand is true,   and false   otherwise. This means that d and e in the program will always be   assigned the same value, given any combination of truth values in a and b. The program   will, therefore, print true   four times.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec16.html#ch03qa4q4&quot; target=&quot;_top&quot;&gt;3.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The element referenced by a[i] is determined based on the   current value of i,   which is zero, that is, the element a[0]. The expression i = 9 will   evaluate to the value 9, which will be assigned to the variable i. The value 9   is also assigned to the array element a[0]. After the execution of the   statement, the variable i   will contain the value 9, and the array a will contain the values 9 and 6. The   program will print 9   9 6 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec16.html#ch03qa4q5&quot; target=&quot;_top&quot;&gt;3.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;Unlike the &amp;amp; and | operators, the &amp;amp;&amp;amp; and   ||   operators short-circuit the evaluation of their operands if the result of the   operation can be determined from the value of the first operand. The second   operand of the ||   operator in the program is never evaluated because of short-circuiting. All   the operands of the other operators are evaluated. Variable i ends up with   a value of 3, which is the first digit printed, and j ends up with   a value of 1, which is the second digit printed.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec21.html#ch03qa5q1&quot; target=&quot;_top&quot;&gt;3.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (f)&lt;br&gt;The method test() will print out its second argument if the   results of performing a signed and an unsigned 1-bit right shift on its first   argument differ. The only difference between these operations is that when   performing a signed shift, the leftmost bit will retain its state, rather   than being assigned the bit value 0. The operational difference will,   therefore, only be apparent when applied on values where the value of the   leftmost bit is 1. Of the values being passed to the method test(), only   the result of the expression 1&amp;lt;&amp;lt;31 (i.e., 1000 ... 0000) and the value -1 (1111 ...   1111) have the left-most bit set.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec21.html#ch03qa5q2&quot; target=&quot;_top&quot;&gt;3.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (g)&lt;br&gt;Java has the operators &amp;gt;&amp;gt; and &amp;gt;&amp;gt;&amp;gt;   to perform signed and unsigned right shifts. For left shifts there is no   difference between shifting signed and unsigned values. Java, therefore, only   has one left-shift operator, which is &amp;lt;&amp;lt;. &amp;lt;&amp;lt;&amp;lt; is not an operator   in Java. Java has the boolean AND compound assignment operator &amp;amp;=, but &amp;amp;&amp;amp;= is   not an operator in Java.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec21.html#ch03qa5q3&quot; target=&quot;_top&quot;&gt;3.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b), (c), (d), and (e)&lt;br&gt;All the expressions will return the same result. All   expressions will accommodate negative values, and x can be any value of type int. However,   expression (a) will not assign the result back to the variable x.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec21.html#ch03qa5q4&quot; target=&quot;_top&quot;&gt;3.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), and (d)&lt;br&gt;The logical complement operator (!) cannot be used as an integer   bitwise operator, and the bitwise complement operator (~) cannot be   used as a boolean logical operator.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec21.html#ch03qa5q5&quot; target=&quot;_top&quot;&gt;3.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b), (c), and (e)&lt;br&gt;All the values of the expressions on the right-hand side of   the assignments are implicitly promoted to type int. For expression (b) this   works, since the target type is also int. The compound assignment operators   in expressions (c) and (e) ensure that an implicit narrowing conversion makes   the result fit back in the target variable. Expressions (a) and (d) are   simply invalid, since the type of expression on the right-hand side of the   assignment operator is not compatible with the type of the target variable on   the left-hand side.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec29.html#ch03qa6q1&quot; target=&quot;_top&quot;&gt;3.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;Evaluation of the actual parameter i++ yields 0,   and increments i   to 1 in the process. The value 0 is copied into the formal parameter i of the   method addTwo()   during method invocation. However, the formal parameter is local to the method,   and changing its value does not affect the value in the actual parameter. The   value of variable i   in the main()   method remains 1.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec29.html#ch03qa6q2&quot; target=&quot;_top&quot;&gt;3.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The variables a and b are local variables that contain   primitive values. When these variables are passed as parameters to another   method, the method receives copies of the primitive values in the variables.   The original variables are unaffected by operations performed on the copies   of the primitive values within the called method. The variable bArr contains   a reference value that denotes an array object containing primitive values.   When the variable is passed as a parameter to another method, the method   receives a copy of the reference value. Using this reference value, the   method can manipulate the object that the reference value denotes. This   allows the elements in the array object referenced by bArr to be   accessed and modified in the method inc2().   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec29.html#ch03qa6q3&quot; target=&quot;_top&quot;&gt;3.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The length of the array passed to the main() method   corresponds exactly to the number of command-line arguments given to the   program. Unlike some other programming languages, the element at index 0 does   not contain the name of the program. The first argument given is retrieved   using args[0],   and the last argument given is retrieved using args[args.length-1].   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch03lev1sec29.html#ch03qa6q4&quot; target=&quot;_top&quot;&gt;3.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (f)&lt;br&gt;Values can only be assigned once to final variables. A final formal   parameter is assigned the value of the actual parameter at method invocation.   Within the method body, it is illegal to reassign or modify the value of a final   parameter. This causes a++   and c = d   to fail. Whether the actual parameter is final does not constrain the client   that invoked the method, since the actual parameter values are copied to the   formal parameters.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_3061533.html&quot; target=&quot;_top&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Declarations and Access Control&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec2.html#ch04qa1q1&quot; target=&quot;_top&quot;&gt;4.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;In Java, arrays are objects. Each array object has a final field   named length   that stores the size of the array.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec2.html#ch04qa1q2&quot; target=&quot;_top&quot;&gt;4.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;Java allows arrays of length zero. Such an array is passed   as an argument to the main()   method when a Java program is run without any program arguments.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec2.html#ch04qa1q3&quot; target=&quot;_top&quot;&gt;4.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The []   notation can be placed both before and after the variable name in an array   declaration. Multidimensional arrays are created by constructing arrays that   can contain references to other arrays. The expression new int[4][]   will create an array of length 4, which can contain references to arrays of int values.   The expression new   int[4][4] will create the same array, but will in addition create   four more arrays, each containing four int values. References to each of   these arrays are stored in the first array. The expression int[][4] will   not work, because the arrays for the dimensions must be created from left to   right.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec2.html#ch04qa1q4&quot; target=&quot;_top&quot;&gt;4.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;The size of the array cannot be specified as in (b) and (e).   The size of the array is given implicitly by the initialization code. The   size of the array is never specified in the declaration of an array   reference. The size of an array is always associated with the array instance,   not the array reference.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec2.html#ch04qa1q5&quot; target=&quot;_top&quot;&gt;4.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The array declaration is valid and will declare and   initialize an array of length 20 containing int values. All the values of the   array are initialized to their default value of 0. The for loop will   print all the values in the array, that is, it will print 0 twenty   times.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec2.html#ch04qa1q6&quot; target=&quot;_top&quot;&gt;4.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The program will type &amp;quot;no arguments&amp;quot; and &amp;quot;four arguments&amp;quot;   when called with 0 and 3 arguments, respectively. When the program is called   with no arguments, the args   array will be of length zero. The program will in this case type &amp;quot;no arguments&amp;quot;.   When the program is called with three arguments, the args array   will have length 3. Using the index 3 on the numbers array will retrieve the string   &amp;quot;four&amp;quot;,   because the start index is 0.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec2.html#ch04qa1q7&quot; target=&quot;_top&quot;&gt;4.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will print &amp;quot;0 false 0 null&amp;quot; when run.   All the instance variables, including the array element, will be initialized   to their default values. When concatenated with a string, the values are   converted to their string representation. Notice that the null pointer   is converted to the string &amp;quot;null&amp;quot; rather than throwing a NullPointerException.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec7.html#ch04qa2q1&quot; target=&quot;_top&quot;&gt;4.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;Only (b) is a valid method declaration. Methods must specify   a return type or are declared void. This makes (d) and (e) invalid. Methods must   specify a list of zero or more comma-separated parameters delimited by ( ). The   keyword void   is not a valid type for a parameter. This makes (a) and (c) invalid.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec7.html#ch04qa2q2&quot; target=&quot;_top&quot;&gt;4.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), and (e)&lt;br&gt;Non-static methods have an implicit this object   reference. The this   reference cannot be changed, as shown in (c). The this reference can be used in a   non-static context to refer to both instance and static members. However, it   cannot be used to refer to local variables, as shown in (d).   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec7.html#ch04qa2q3&quot; target=&quot;_top&quot;&gt;4.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (d)&lt;br&gt;The first and the third pairs of methods will compile   correctly. The second pair of methods will not compile correctly, since their   method signatures do not differ. The compiler has no way of differentiating   between the two methods. Note that return type and the names of the   parameters are not a part of the method signatures. Both methods in the first   pair are named fly   and, therefore, overload this method name. The methods in pair three do not   overload the method name glide,   since only one method has that name. The method named Glide is   distinct from the method named glide, as identifiers in Java are case sensitive.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec7.html#ch04qa2q4&quot; target=&quot;_top&quot;&gt;4.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;A constructor cannot specify any return type, not even void. A   constructor cannot be final,   static   or abstract.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec7.html#ch04qa2q5&quot; target=&quot;_top&quot;&gt;4.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;A constructor can be declared private, but this means that   this constructor can only be used within the class. Constructors need not   initialize all the fields of the class. A field will be assigned a default   value if not explicitly initialized. A constructor is non-static, and as such   it can directly access both the static and non-static members of the class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec7.html#ch04qa2q6&quot; target=&quot;_top&quot;&gt;4.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;A compilation error will occur at (3), since the class does   not have a constructor accepting a single argument of type int. The   declaration at (1) declares a method, not a constructor, since it is declared   as void.   The method happens to have the same name as the class, but that is   irrelevant. The class has an implicit default constructor since the class   contains no constructor declarations. This constructor is invoked to create a   MyClass   object at (2).   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec11.html#ch04qa3q1&quot; target=&quot;_top&quot;&gt;4.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;A class or interface name can be referred to by using either   its fully qualified name or its simple name. Using the fully qualified name   will always work, but in order to use the simple name it has to be imported.   By importing net.basemaster.*   all the type names from the package net.basemaster will be imported and   can now be referred to using simple names. Importing net.* will not   import the subpackage basemaster.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec11.html#ch04qa3q2&quot; target=&quot;_top&quot;&gt;4.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;A class is uninstantiable if the class is declared abstract. The   declaration of an abstract   method cannot provide an implementation. The declaration of a non-abstract   method must provide an implementation. If any method in a class is declared abstract, then   the class must be declared abstract. Definition (d) is not valid since it   omits the class   keyword.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec11.html#ch04qa3q3&quot; target=&quot;_top&quot;&gt;4.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;A class can be extended unless it is declared final. For   classes, final   means it cannot be extended, while for methods, final means it cannot be   overridden in a subclass. A nested static class, (d), can be extended. A private member   class, (f), can also be extended. The keyword native can only be used for   methods, not for classes and fields.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec13.html#ch04qa4q1&quot; target=&quot;_top&quot;&gt;4.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (d)&lt;br&gt;Outside the package, member j is accessible to any class, whereas   member k   is only accessible to subclasses of MyClass.&lt;br&gt;Field i   has package accessibility and is only accessible by classes inside the   package. Field j   has public accessibility and is accessible from anywhere. Field k has   protected accessibility and is accessible from any class inside the package   and from subclasses anywhere. Field l has private accessibility and is   only accessible within its own class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec13.html#ch04qa4q2&quot; target=&quot;_top&quot;&gt;4.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The default accessibility for members is more restrictive   than protected accessibility, but less restrictive than private. Members with   default accessibility are only accessible within the class itself and from   classes in the same package. Protected members are in addition accessible   from subclasses anywhere. Members with private accessibility are only   accessible within the class itself.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec13.html#ch04qa4q3&quot; target=&quot;_top&quot;&gt;4.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;A private member is only accessible by code from within the   class of the member. If no accessibility modifier has been specified, a   member has default accessibility, also known as package accessibility. The   keyword default   is not an accessibility modifier, and its only use is as a label in a switch   statement. Members with package accessibility are only accessible from   classes in the same package. Subclasses outside the package cannot access   members with default accessibility.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q1&quot; target=&quot;_top&quot;&gt;4.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;You cannot specify accessibility of local variables. They   are accessible only within the block in which they are declared.&lt;br&gt;Objects themselves do not have any accessibility, only   references to objects do. If no accessibility modifier (public, protected, or private) is   given in the member declaration of a class, the member is only accessible to   classes in the same package. A class does not have access to members with   default accessibility declared in a superclass, unless both classes are in   the same package. Inheritance has no consequence with respect to accessing   members with default accessibility in the same package. Local variables   cannot be declared static   or given an accessibility modifier.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q2&quot; target=&quot;_top&quot;&gt;4.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The line void   k() { i++; } can be re-inserted without introducing errors.   Re-inserting line (1) will cause the compilation to fail, since MyOtherClass   will try to override a final   method. Re-inserting line (2) will fail, since MyOtherClass will no longer   have a default constructor. The main() method needs to call the default   constructor. Re-inserting line (3) will work without any problems, but   re-inserting line (4) will fail, since the method will try to access a private member   of the superclass.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q3&quot; target=&quot;_top&quot;&gt;4.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (f)&lt;br&gt;An object reference is needed to access non-static members.   Static methods do not have the implicit object reference this, and must   always supply an explicit object reference when referring to non-static   members. The static method main() refers legally to the non-static method func() using   the reference variable ref.   Static members are accessible both from static and non-static methods, using   their simple names.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q4&quot; target=&quot;_top&quot;&gt;4.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Local variables can have the same name as member variables.   The local variables will simply shadow the member variables with the same   names. Declaration (4) defines a static method that tries to access a   variable named a,   which is not locally declared. Since the method is static, this   access will only be valid if variable a is declared static within   the class. Therefore, declarations (1) and (4) cannot occur in the same class   definition, while declarations (2) and (4) can.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q5&quot; target=&quot;_top&quot;&gt;4.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The keyword this can only be used in non-static code, like in   non-static methods. Only one occurrence of each static variable of a class is   created. This occurrence is shared among all the objects of the class (or for   that matter, by other clients). Local variables are only accessible within   the local scope, regardless of whether the local scope is defined within a   static context.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q6&quot; target=&quot;_top&quot;&gt;4.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The variable k cannot be declared synchronized. Only methods   and code blocks can be synchronized.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q7&quot; target=&quot;_top&quot;&gt;4.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The declaration abstract int t; is not legal. Keywords   static   and final   are valid modifiers for both field and method declarations. The modifiers abstract and native are   only valid for methods.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q8&quot; target=&quot;_top&quot;&gt;4.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (c)&lt;br&gt;Abstract classes can contain both final methods   and non-abstract   methods. Non-abstract   classes cannot, however, contain abstract methods. Nor can abstract   classes be final.   Only methods can be declared native.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch04lev1sec15.html#ch04qa5q9&quot; target=&quot;_top&quot;&gt;4.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The transient   keyword signifies that the fields should not be stored when objects are   serialized. Constructors cannot be declared abstract. When an array object is   created, as in (c), the elements in the array object are assigned the default   value corresponding to the type of the elements. Whether the reference   variable denoting the array object is a local or a member variable is   irrelevant. Abstract methods from a superclass need not be implemented by a   subclass. The subclass must then be declared abstract.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Control Flow, Exception Handling, and Assertions&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec3.html#ch05qa1q1&quot; target=&quot;_top&quot;&gt;5.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will display the letter b when run.   The second if   statement is evaluated since the boolean expression of the first if statement   is true.   The else   clause belongs to the second if statement. Since the boolean expression of the   second if   statement is false,   the if   block is skipped and the else   clause is executed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec3.html#ch05qa1q2&quot; target=&quot;_top&quot;&gt;5.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), and (e)&lt;br&gt;The conditional expression of an if statement can have any   subexpressions, including method calls, as long as the whole expression   evaluates to a value of type boolean. The expression (a = b) does   not compare the variables a   and b,   but assigns the value of b   to the variable a.   The result of the expression is the value being assigned. Since a and b are boolean   variables, the value returned by the expression is also boolean. This   allows the expression to be used as the condition for an if statement.   An if   statement must always have an if block, but the else clause is optional. The   expression if   (false) ; else ; is legal. In this case, both the if block and   the else   block are simply the empty statement.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec3.html#ch05qa1q3&quot; target=&quot;_top&quot;&gt;5.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (f)&lt;br&gt;There is nothing wrong with the code. The case and default labels   do not have to be specified in any specific order. The use of the break   statement is not mandatory, and without it the control flow will simply fall   through the labels of the switch   statement.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec3.html#ch05qa1q4&quot; target=&quot;_top&quot;&gt;5.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The type of the switch expression must be either byte, char, short, or int. This   excludes (b) and (e). The type of the case labels must be assignable to the   type of the switch   expression. This excludes (c) and (d).   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q1&quot; target=&quot;_top&quot;&gt;5.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The loop body is executed twice and the program will print 3. The first   time the loop is executed, the variable i changes from 1 to 2 and the variable   b   changes from false   to true.   Then the loop condition is evaluated. Since b is true, the loop body is executed again.   This time the variable i   changes from 2 to 3 and the variable b changes from true to false. The   loop condition is now evaluated again. Since b is now false, the loop terminates   and the current value of i   is printed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q2&quot; target=&quot;_top&quot;&gt;5.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;Both the first and the second number printed will be 10. Both the   loop body and the increment expression will be executed exactly 10 times.   Each execution of the loop body will be directly followed by an execution of   the increment expression. Afterwards, the condition j&amp;lt;10 is   evaluated to see whether the loop body should be executed again.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q3&quot; target=&quot;_top&quot;&gt;5.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Only (c) contains a valid for loop. The initializer in a for statement   can contain either declarations or a list of expression statements, but not   both as attempted in (a). The loop condition must be of type boolean. (b)   tries to use an assignment of an int value (notice the use of = rather than ==) as a loop   condition and is, therefore, not valid. The loop condition in the for loop (d)   tries to use the uninitialized variable i, and the for loop in (e) is simply   syntactically invalid.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q4&quot; target=&quot;_top&quot;&gt;5.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (f)&lt;br&gt;The code will compile without error, but will never   terminate when run. All the sections in the for header are optional and can be   omitted (but not the semicolons).&lt;br&gt;An omitted loop condition is interpreted as being true. Thus, a for loop with   an omitted loop condition will never terminate, unless a break   statement is encountered in the loop body. The program will enter an infinite   loop at (4).   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q5&quot; target=&quot;_top&quot;&gt;5.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b), (d), and (e)&lt;br&gt;The loop condition in a while statement is not optional. It is   not possible to break out of the if statement in (c). Notice that if   the if   statement had been placed within a labeled block, a switch   statement, or a loop, the usage of break would be valid.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q6&quot; target=&quot;_top&quot;&gt;5.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (d)&lt;br&gt;&amp;quot;i=1,   j=0&amp;quot; and &amp;quot;i=2, j=1&amp;quot; are part of the output. The   variable i   iterates through the values 0, 1, and 2 in the outer loop, while j toggles   between the values 0 and 1 in the inner loop. If the values of i and j are equal,   the printing of the values is skipped and the execution continues with the   next iteration of the outer loop. The following can be deduced when the   program is run: variables i   and j   are both 0 and the execution continues with the next iteration of the outer   loop. &amp;quot;i=1,   j=0&amp;quot; is printed and the next iteration of the inner loop   starts. Variables i   and j   are both 1 and the execution continues with the next iteration of the outer   loop. &amp;quot;i=2,   j=0&amp;quot; is printed and the next iteration of the inner loop   starts. &amp;quot;i=2,   j=1&amp;quot; is printed, j is incremented, j &amp;lt; 2   fails, and the inner loop ends. Variable i is incremented, i &amp;lt; 3   fails, and the outer loop ends.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q7&quot; target=&quot;_top&quot;&gt;5.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The code will fail to compile, since the conditional   expression of the if   statement is not of type boolean.   The conditional expression of an if statement must be of type boolean. The   variable i   is of type int.   There is no conversion between boolean and other primitive types.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q8&quot; target=&quot;_top&quot;&gt;5.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;Implementation (4) will correctly return the largest value.   The if   statement does not return any value and, therefore, cannot be used as in   implementations (1) and (2). Implementation (3) is invalid since neither the switch   expression nor the case   label values can be of type boolean.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q9&quot; target=&quot;_top&quot;&gt;5.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;As it stands, the program will compile correctly and will   print &amp;quot;3, 2&amp;quot;   when run. If the break   statement is replaced with a continue statement, the loop will perform all four   iterations and will print &amp;quot;4, 3&amp;quot;. If the break statement is replaced   with a return   statement, the whole method will end when i equals 2, before anything is   printed. If the break   statement is simply removed, leaving the empty statement (;), the loop   will complete all four iterations and will print &amp;quot;4, 4&amp;quot;.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec6.html#ch05qa2q10&quot; target=&quot;_top&quot;&gt;5.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (c)&lt;br&gt;The block construct {} is a compound statement. The   compound statement can contain zero or more arbitrary statements. Thus, {{}} is a   legal compound statement, containing one statement that is also a compound   statement, containing no statement. The block { continue; } by itself is not   valid, since the continue   statement cannot be used outside the context of a loop. (c) is a valid   example of breaking out of a labeled block. (d) is not valid for the same   reasons (b) was not valid. The statement at (e) is not true, since the break   statement can also be used to break out of labeled blocks, as illustrated by   (c).   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q1&quot; target=&quot;_top&quot;&gt;5.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will only print 1, 4, and 5, in that order. The   expression 5/k   will throw an ArithmeticExecption,   since k   equals 0. Control is transferred to the first catch block, since it is the   first block that can handle arithmetic exceptions. This exception handler   simply prints 1.   The exception has now been caught and normal execution can resume. Before   leaving the try   statement, the finally   block is executed. This block prints 4. The last statement of the main() method   prints 5.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q2&quot; target=&quot;_top&quot;&gt;5.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;If run with one argument, the program will print the given   argument followed by &amp;quot;The   end&amp;quot;. The finally block will always be executed, no matter   how control leaves the try   block.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q3&quot; target=&quot;_top&quot;&gt;5.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will compile without error, but will throw a NullPointerException   when run. The throw   statement can only throw Throwable   objects. A NullPointerException   will be thrown if the expression of the throw statement results in a null   reference.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q4&quot; target=&quot;_top&quot;&gt;5.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;Normal execution will only resume if the exception is caught   by the method. The uncaught exception will propagate up the runtime stack   until some method handles it. An overriding method need only declare that it   can throw a subset of the checked exceptions the overridden method can throw.   The main()   method can declare that it throws checked exceptions just like any other   method. The finally   block will always be executed, no matter how control leaves the try block.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q5&quot; target=&quot;_top&quot;&gt;5.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The program will print 1 and 4, in that order. An InterruptedException   is handled in the first catch   block. Inside this block a new RuntimeException is thrown. This exception was not   thrown inside the try   block and will not be handled by the catch blocks, but will be sent to the   caller of the main()   method. Before this happens, the finally block is executed. The code   printing 5   is never reached, since the runtimeException remains uncaught after the   execution of the finally   block.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q6&quot; target=&quot;_top&quot;&gt;5.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The program will print 2 and throw an InterruptedException.   An InterruptedException   is thrown in the try   block. There is no catch   block to handle the exception, so it will be sent to the caller of the main() method,   that is, to the default exception handler. Before this happens, the finally block   is executed. The code printing 3 is never reached.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q7&quot; target=&quot;_top&quot;&gt;5.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The only thing that is wrong with the code is the ordering   of the catch   and finally   blocks. If present, the finally   block must always appear last in a try-catch-finally construct.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q8&quot; target=&quot;_top&quot;&gt;5.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;Overriding methods can specify all, none, or a subset of the   checked exceptions the overridden method declares in its throws clause.   The InterruptedException   is the only checked exception specified in the throws clause of the overridden   method. The overriding method f() need not specify any checked exception from   the throws   clause of the overridden method.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec12.html#ch05qa3q9&quot; target=&quot;_top&quot;&gt;5.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The overriding f() method in MyClass is not permitted to throw the   checked InterruptedException,   since the f()   method in class A   does not throw this exception. To avoid compilation errors, either the   overriding f()   method must not throw an InterruptedException   or the overridden f()   method must declare that it can throw an InterruptedException.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q1&quot; target=&quot;_top&quot;&gt;5.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;Statements (c) and (d) will throw an AssertionError   because the first expression is false. Statement (c) will report true as the   error message, while (d) will report false as the error message.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q2&quot; target=&quot;_top&quot;&gt;5.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (d)&lt;br&gt;-ea   (enable assertions) is a valid runtime option, not -ae. -source 1.4 is   a compile time option. -dsa   (disable system assertions) is a valid runtime option, not -dea.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q3&quot; target=&quot;_top&quot;&gt;5.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The class of exceptions thrown by assertion statements is   always AssertionError.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q4&quot; target=&quot;_top&quot;&gt;5.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Assertions can be enabled or disabled at runtime, but the assert   statements are always compiled into bytecode.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q5&quot; target=&quot;_top&quot;&gt;5.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (b)&lt;br&gt;Statement (a) will cause the assert statement to throw an AssertionError   since (-50 &amp;gt;   -50) evaluates to false. Statement (b) will cause the expression 100/value to   throw an ArithmeticException   since an integer division by zero is attempted.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q6&quot; target=&quot;_top&quot;&gt;5.29&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (d)&lt;br&gt;Option (a) enables assertions for all non-system classes,   while (d) enables assertions for all classes in the package org and its   subpackages. Options (b), (c), and (f) try to enable assertions in   specifically named classes: Bottle, org.example, and org.example.ttp.   Option (e) is not a valid runtime option.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q7&quot; target=&quot;_top&quot;&gt;5.30&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The assert   statement correctly asserts that 150 is greater than 100 and less than 200.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q8&quot; target=&quot;_top&quot;&gt;5.31&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (d)&lt;br&gt;The AssertionError   class, like all other error classes, is not a checked exception, and need not   be declared in a throws   clause. After an AssertionError   is thrown, it is propagated exactly the same way as other exceptions, and can   be caught by a try-catch   construct.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q9&quot; target=&quot;_top&quot;&gt;5.32&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The class Error is the direct superclass of AssertionError.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch05lev1sec14.html#ch05qa4q10&quot; target=&quot;_top&quot;&gt;5.33&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;The command line enables assertions for all non-system   classes, except for those in the com package or one of its subpackages.   Assertions are not enabled for the system classes in (b) and (e).   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Object-oriented Programming&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec2.html#ch06qa1q1&quot; target=&quot;_top&quot;&gt;6.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (b)&lt;br&gt;The extends   clause is used to specify that a class extends another class. A subclass can   be declared abstract   regardless of whether the superclass was declared abstract. Private, overridden,   and hidden members from the superclass are not inherited by the subclass. A   class cannot be declared both abstract and final, since an abstract class   needs to be extended to be useful and a final class cannot be extended. The   accessibility of the class is not limited by the accessibility of its   members. A class with all the members declared private can still be declared public.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec2.html#ch06qa1q2&quot; target=&quot;_top&quot;&gt;6.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;Inheritance defines an is-a   relation. Aggregation defines a has-a   relation. The Object   class has a public   method named equals,   but it does not have any method named length. Since all classes are   subclasses of the Object   class, they all inherit the equals() method. Thus, all Java objects have a public method   named equals.   In Java, a class can only extend a single superclass, but there is no limit   on how many classes can extend a superclass.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec4.html#ch06qa2q1&quot; target=&quot;_top&quot;&gt;6.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (c)&lt;br&gt;A subclass need not redefine all the methods defined in the   superclass. It is possible for a subclass to define a method with the same   name and parameters as a method defined by the superclass, but then the   return type should also be the same. This is called method overriding. A   subclass can define a field that can hide a field defined in a superclass.   Two classes cannot be the superclass of each other.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec4.html#ch06qa2q2&quot; target=&quot;_top&quot;&gt;6.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), and (d)&lt;br&gt;Bar   is a legal subclass of Foo   that overrides the method g().   The statement a.j   = 5 is not legal, since the member j in class Bar cannot be   accessed through a Foo   reference. The statement b.i   = 3 is not legal either, since the private member i cannot be   accessed from outside of the class Foo.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec4.html#ch06qa2q3&quot; target=&quot;_top&quot;&gt;6.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;A method can be overridden by defining a method with the   same signature (i.e., name and parameter list) and return type as the method   in a superclass. Only instance methods that are accessible by their simple   name can be overridden. A private   method, therefore, cannot be overridden in subclasses, but the subclasses are   allowed to define a new method with exactly the same signature. A final method   cannot be overridden. An overriding method cannot exhibit behavior that   contradicts the declaration of the original method. An overriding method,   therefore, cannot return a different type of value or declare that it throws   more exceptions than the original method in the superclass.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec4.html#ch06qa2q4&quot; target=&quot;_top&quot;&gt;6.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (g)&lt;br&gt;It is not possible to invoke the doIt() method in A from an   instance method in class C.   The method in C   needs to call a method in a superclass two levels up in the inheritance   hierarchy. The super.super.doIt()   strategy will not work, since super is a keyword and cannot be used as an   ordinary reference, nor accessed like a field. If the member to be accessed   had been a field, the solution would be to cast the this reference   to the class of the field and use the resulting reference to access the   field. Field access is determined by the declared type of the reference,   whereas the instance method to execute is determined by the actual type of   the object denoted by the reference.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec4.html#ch06qa2q5&quot; target=&quot;_top&quot;&gt;6.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The code will compile without errors. None of the calls to a   max()   method are ambiguous. When the program is run, the main() method   will call the max()   method in C   with the parameters 13   and 29.   This method will call the max()   method in B   with the parameters 23   and 39.   The max()   method in B   will in turn call the max()   method in A   with the parameters 39   and 23.   The max()   method in A   will return 39   to the max()   method in B.   The max()   method in B   will return 29   to the max()   method in C.   The max()   method in C   will return 29   to the main()   method.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec4.html#ch06qa2q6&quot; target=&quot;_top&quot;&gt;6.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The simplest way to print the message in the class Message would   be to use System.   out.println(msg.text). The main() method creates an instance of MyClass, which   results in the creation of a Message instance. The field msg denotes   this Message   object in MySuperclass   and is inherited by the MyClass   object. Thus, the message in the Message object can be accessed   directly by msg.text   in the print()   method of MyClass.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec6.html#ch06qa3q1&quot; target=&quot;_top&quot;&gt;6.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The class MySuper does not have a default constructor. This   means that constructors in subclasses must explicitly call the superclass   constructor to provide the required parameters. The supplied constructor   accomplishes this by calling super(num) in its first statement. Additional   constructors can accomplish this either by calling the superclass constructor   directly using the super()   call, or by calling another constructor in the same class using the this() call,   which in turn calls the superclass constructor. (a) and (b) are not valid   since they do not call the superclass constructor explicitly. (d) fails since   the super()   call must always be the first statement in the constructor body. (f) fails   since the super()   and this()   calls cannot be combined.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec6.html#ch06qa3q2&quot; target=&quot;_top&quot;&gt;6.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;In a subclass without any declared constructors, the   implicit default constructor will call super(). The use of the super() and this()   statements are not mandatory as long as the superclass has a default   constructor. If neither super()   nor this()   is declared as the first statement in the body of a constructor, then super() will   implicitly be the first statement. A constructor body cannot have both a super() and a this()   statement. Calling super()   will not always work, since a superclass might not have a default   constructor.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec6.html#ch06qa3q3&quot; target=&quot;_top&quot;&gt;6.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will print 12 followed by Test. When the   main()   method is executed, it will create a new instance of B by giving &amp;quot;Test&amp;quot;   as argument. This results in a call to the constructor of class B that has one   String   parameter. The constructor does not explicitly call any superclass   constructor, but instead the default constructor of the superclass A is called   implicitly. The default constructor of class A calls the constructor in A that has two   String   parameters, giving it the arguments &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;.   This constructor calls the constructor with one String parameter, passing the   argument &amp;quot;12&amp;quot;.   This constructor prints the argument. Now the execution of all the   constructors in A   is completed, and execution continues in the constructor of B. This constructor   now prints the original argument &amp;quot;Test&amp;quot; and returns to the main() method.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec8.html#ch06qa4q1&quot; target=&quot;_top&quot;&gt;6.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (c)&lt;br&gt;Interfaces do not have any implementations and only permit   multiple interface inheritance. An interface can extend any number of other   interfaces and can be extended by any number of interfaces. Fields in   interfaces are always static   and method prototypes in interfaces are never static.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec8.html#ch06qa4q2&quot; target=&quot;_top&quot;&gt;6.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), and (d)&lt;br&gt;Fields in interfaces declare named constants, and are always   public,   static,   and final.   None of these modifiers are mandatory in a constant declaration. All named   constants must be explicitly initialized in the declaration.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec8.html#ch06qa4q3&quot; target=&quot;_top&quot;&gt;6.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (d)&lt;br&gt;The keyword implements is used when a class inherits from an   interface. The keyword extends   is used when an interface inherits from another interface or a class inherits   from another class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec8.html#ch06qa4q4&quot; target=&quot;_top&quot;&gt;6.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The code will compile without errors. The class MyClass   declares that it implements the interfaces Interface1 and Interface2.   Since the class is declared abstract, it does not need to supply   implementations for all the method prototypes defined in these interfaces.   Any non-abstract   subclasses of MyClass   must provide the missing method implementations. The two interfaces share a   common method prototype void   g(). MyClass   provides an implementation for this prototype that satisfies both Interface1 and   Interface2.   Both interfaces provide declarations of constants named VAL_B. This   can lead to an ambiguity when referring to VAL_B by its simple name from MyClass. The   ambiguity can be resloved by using fully qualified names: Interface1.VAL_B   and Interface2.VAL_B.   However, there are no problems with the code as it stands.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec8.html#ch06qa4q5&quot; target=&quot;_top&quot;&gt;6.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (c)&lt;br&gt;Declaration (b) fails since it contains an illegal forward   reference to its own named constant. The field type is missing in declaration   (d). Declaration (e) tries illegally to use the protected modifier, even though   named constants always have public accessibility.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec11.html#ch06qa5q1&quot; target=&quot;_top&quot;&gt;6.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The program will throw a java.lang.ClassCastException in the   assignment at (3) when run. The statement at (1) will compile since the   assignment is done from a subclass reference to a superclass reference. The   cast at (2) assures the compiler that arrA will refer to an object that can   be referenced by arrB.   This will work when run since arrA will refer to an object of type B[]. The cast   at (3) will also assure the compiler that arrA will refer to an object that can   be referenced by arrB.   This will not work when run since arrA will refer to an object of type A[].   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec11.html#ch06qa5q2&quot; target=&quot;_top&quot;&gt;6.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;Line (4) will cause a compile-time error since it attempts   to assign a reference value of a supertype object to a reference of a   subtype. The type of the source reference value is MyClass and   the type of the destination reference is MySubclass. Lines (1) and (2) will compile   since the reference is assigned a reference value of the same type. Line (3)   will also compile since the reference is assigned a reference value of a   subtype.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec11.html#ch06qa5q3&quot; target=&quot;_top&quot;&gt;6.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;Only the assignment I1 b = obj3 is valid. The assignment   is allowed since C3   extends C1,   which implements I1.   Assignment obj2   = obj1 is not legal since C1 is not a subclass of C2.   Assignments obj3   = obj1 and obj3   = obj2 are not legal since neither C1 nor C2 is a   subclass of C3.   Assignment I1 a   = obj2 is not legal since C2 does not implement I1. Assignment   I2 c = obj1   is not legal since C1   does not implement I2.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec11.html#ch06qa5q4&quot; target=&quot;_top&quot;&gt;6.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The statement would be legal at compile time, since the   reference x   might actually refer to an object of the type Sub. The cast tells the   compiler to go ahead and allow the assignment. At runtime, the reference x may turn out   to denote an object of the type Super instead. If this happens, the assignment   will be aborted and a ClassCastException   will be thrown.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec11.html#ch06qa5q5&quot; target=&quot;_top&quot;&gt;6.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Only A   a = d is legal. The reference value in d can be   assigned to a   since D   implements A.   The statements c   = d and d   = c are illegal since there is no subtype-supertype relationship   between classes C   and D.   Even though a cast is provided, the statement d = (D) c is illegal. The   object referred to by c   cannot possibly be of type D, since D is not a subclass of C. The   statement c = b   is illegal since assigning a reference value of a reference of type B to a   reference of type C   requires a cast.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec11.html#ch06qa5q6&quot; target=&quot;_top&quot;&gt;6.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), and (c)&lt;br&gt;The program will print A, B, and C when run. The object denoted   by reference a   is of type C.   The object is also an instance of A and B, since C is a subclass of B and B is a   subclass of A.   The object is not an instance of D.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec11.html#ch06qa5q7&quot; target=&quot;_top&quot;&gt;6.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The expression (o instanceof B) will return true if the   object referred to by o   is of type B   or a subtype of B.   The expression (!(o   instanceof C)) will return true unless the object referred to by o is of type C or a subtype   of C.   Thus, the expression (o   instanceof B) &amp;amp;&amp;amp; (!(o instanceof C)) will only return true if the   object is of type B   or a subtype of B   that is not C   or a subtype of C.   Given objects of classes A,   B,   and C,   this expression will only return true for objects of class B.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec11.html#ch06qa5q8&quot; target=&quot;_top&quot;&gt;6.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The program will print all of I, J, C, and D when run.   The object referred to by reference x is of class D. Class D extends   class C   and class C   implements interface I.   This makes I,   J,   and C   supertypes of class D.   A reference of type D   can be cast to any of its supertypes and is, therefore, an instanceof   these types.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec13.html#ch06qa6q1&quot; target=&quot;_top&quot;&gt;6.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The program will print 2 when System.out.println(ref2.f()) is   executed. The object referenced by ref2 is of class C, but the   reference is of type B.   Since B   contains a method f(),   the method call will be allowed at compile time. During execution it is determined   that the object is of class C, and dynamic method lookup will cause the   overridden method in C   to be executed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec13.html#ch06qa6q2&quot; target=&quot;_top&quot;&gt;6.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The program will print 1 when run. The f() methods in   A   and B   are private   and are not accessible by the subclasses. Because of this, the subclasses   cannot overload or override these methods, but simply define new methods with   the same signature. The object being called is of class C. The   reference used to access the object is of type B. Since B contains a   method g(),   the method call will be allowed at compile time. During execution it is   determined that the object is of class C, and dynamic method lookup will   cause the overridden method g() in B to be called. This method calls a   method named f().   It can be determined during compilation that this can only refer to the f() method in B, since the   method is private   and cannot be overridden. This method returns the value 1, which is   printed.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec15.html#ch06qa7q1&quot; target=&quot;_top&quot;&gt;6.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;The code as it stands will compile without error. The use of   inheritance in this code is not justifiable since, conceptually, a planet is-not-a star. The code will fail if the name of the   field starName   is changed in the Star   class since the subclass Planet   tries to access it using the name starName. An instance of Planet is not   an instance of HeavenlyBody.   Neither Planet   nor Star   implements HeavenlyBody.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch06lev1sec15.html#ch06qa7q2&quot; target=&quot;_top&quot;&gt;6.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The code will compile without error. The use of aggregation   in this code is justifiable. The code will not fail to compile if the name of   the field starName   is changed in the Star   class, since the Planet   class does not try to access the field by name, but instead uses the public method describe() in   the Star   class to do that. An instance of Planet is not an instance of HeavenlyBody   since it neither implements HeavenlyBody nor extends a class that implements HeavenlyBody.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Nested Classes And Interfaces&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec4.html#ch07qa1q1&quot; target=&quot;_top&quot;&gt;7.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The code will compile without error and will print 123 when run.   An instance of the Outer   outer will be created and the field secret will be initialized to 123. A call to   the createInner()   method will return a reference to a newly created Inner instance. This object is   an instance of a non-static member class and is associated with the outer   instance. This means that an object of a non-static member class has access   to the members within the outer instance. Since the Inner class is   nested in the class containing the field secret, this field is accessible to   the Inner   instance, even though the field secret is declared private.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec4.html#ch07qa1q2&quot; target=&quot;_top&quot;&gt;7.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;A static member class is in many respects like a top-level   class, and can contain non-static fields. Instances of non-static member   classes are created in the context of an outer instance. The outer instance   is inherently associated with the inner instance. Several inner class   instances can be created and associated with the same outer instance. Static   classes do not have any inherent outer instance. A static member interface,   just like top-level interfaces, cannot contain non-static fields. Nested   interfaces are always static.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec4.html#ch07qa1q3&quot; target=&quot;_top&quot;&gt;7.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The code will fail to compile, since the expression ((State) this).val   in the method restore()   of the class Memento   is invalid. The correct way to access the field val in the class State, which   is hidden by the field val   in the class Memento,   is to use the expression State.this.val.   Other than that, there are no problems with the code.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec4.html#ch07qa1q4&quot; target=&quot;_top&quot;&gt;7.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will compile without error, and will print 1, 3, 4, in that   order, when run. The expression B.this.val will access the value 1 stored in   the field val   of the (outer) B   instance associated with the (inner) C object denoted by the reference obj. The   expression C.this.val   will access the value 3   stored in the field val   of the C   object denoted by the reference obj. The expression super.val will access the field   val   from A,   the superclass of C.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec4.html#ch07qa1q5&quot; target=&quot;_top&quot;&gt;7.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;The class Inner is a non-static member class of the Outer class,   and its full name is Outer.Inner.   The Inner   class does not inherit from the Outer class. The method named doIt is,   therefore, neither overridden nor overloaded. Within the scope of the Inner class,   the doIt()   method of the Outer   class is hidden by the doIt()   method of the Inner   class.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec7.html#ch07qa2q1&quot; target=&quot;_top&quot;&gt;7.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;Non-static member classes, unlike top-level classes, can   have any accessibility modifier. Static member classes can only be declared   in top-level or nested static member classes and interfaces. Only static   member classes can be declared static. Declaring a class static only   means that instances of the class are created without having an outer   instance. This has no bearing on whether the members of the class can be   static or not.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec7.html#ch07qa2q2&quot; target=&quot;_top&quot;&gt;7.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d) and (e)&lt;br&gt;The methods labeled (1) and (3) will not compile, since the   non-final   parameter i   is not accessible from within the inner class. The syntax of the anonymous   class in the method labeled (2) is not correct, as the parameter list is   missing.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec7.html#ch07qa2q3&quot; target=&quot;_top&quot;&gt;7.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (d)&lt;br&gt;No other static members, except final static fields, can be declared   within a non-static member class. Members in outer instances are directly   accessible using simple names (provided they are not hidden). Fields in   nested static member classes need not be final. Anonymous classes cannot have   constructors, since they have no names. Nested classes define distinct types   from the enclosing class, and the instanceof operator does not take the   type of the outer instance into consideration.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch07lev1sec7.html#ch07qa2q4&quot; target=&quot;_top&quot;&gt;7.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;Classes can be declared as members of top-level classes.   Such a class is a static member class if it is declared static,   otherwise, it is a non-static member class. Top-level classes, local classes,   and anonymous classes cannot be declared static.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Object Lifetime&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec2.html#ch08qa1q1&quot; target=&quot;_top&quot;&gt;8.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;An object is only eligible for garbage collection if all   remaining references to the object are from other objects that are also eligible   for garbage collection. Therefore, if an object obj2 is eligible for garbage   collection and object obj1   contains a reference to it, then object obj1 must also be eligible for   garbage collection. Java does not have a keyword delete. An object will not necessarily   be garbage collected immediately after it becomes unreachable. However, the   object will be eligible for garbage collection. Circular references do not   prevent objects from being garbage collected, only reachable references do.   An object is not eligible for garbage collection as long as the object can be   accessed by any live thread. An object that has been eligible for garbage   collection can be made non-eligible. This occurs if the finalize()   method of the object creates a reachable reference to the object.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec2.html#ch08qa1q2&quot; target=&quot;_top&quot;&gt;8.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;Before (1), the String object initially referenced by arg1 is   denoted by both msg   and arg1.   After (1), the String   object is only denoted by msg.   At (2), reference msg   is assigned a new reference value. This reference value denotes a new String object   created by concatenating several other String objects. After (2), there are   no references to the String   object initially referenced by arg1. The String object is now eligible for   garbage collection.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec2.html#ch08qa1q3&quot; target=&quot;_top&quot;&gt;8.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The Object   class defines a protected   finalize() method. All classes inherit from Object, thus,   all objects have a finalize()   method. Classes can override the finalize() method and, as with all   overriding, the new method must not reduce the accessibility. The finalize()   method of an eligible object is called by the garbage collector to allow the   object to do any cleaning up, before the object is destroyed. When the   garbage collector calls the finalize() method, it will ignore any exceptions   thrown by the finalize()   method. In all other cases, normal exception handling occurs when an   exception is thrown during the execution of the finalize() method, that is,   exceptions are not simply ignored. Calling the finalize() method does not in   itself destroy the object. Chaining of the finalize() methods is not enforced by   the compiler, and it is not mandatory to call the overridden finalize()   method.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec2.html#ch08qa1q4&quot; target=&quot;_top&quot;&gt;8.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The finalize()   method is like any other method, it can be called explicitly if it is   accessible. However, the intended purpose of the method is to be called by   the garbage collector in order to clean up before an object is destroyed.   Overloading the finalize()   method name is allowed, but only the method with the original signature will   be called by the garbage collector. The finalize() method in Object is protected.   This means that overriding methods must be declared either protected or public. The finalize() method   in Object   can throw any Throwable   object. Overriding methods can limit the range of throwables to unchecked   exceptions. Further overridden definitions of this method in subclasses will   not be able to throw checked exceptions.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec2.html#ch08qa1q5&quot; target=&quot;_top&quot;&gt;8.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The finalize()   method will never be called more than once on an object, even if the finalize()   method resurrects the object. An object can be eligible for garbage   collection even if there are references denoting the object, as long as the   objects owning these references are also eligible for garbage collection.   There is no guarantee that the garbage collector will destroy an eligible   object before the program terminates. The order in which the objects are   destroyed is not guaranteed. The finalize() method can make an object   that has been eligible for garbage collection, accessible again by a live   thread.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec4.html#ch08qa2q1&quot; target=&quot;_top&quot;&gt;8.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c), (e), and (f)&lt;br&gt;Static initializer blocks (a) and (b) are not legal since   the fields alive   and STEP   are non-static and final,   respectively. (d) is syntactically not a legal static initializer block.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec4.html#ch08qa2q2&quot; target=&quot;_top&quot;&gt;8.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The program will compile without error and will print 50, 70, 0, 20, 0   when run. All fields are given default values unless they are explicitly   initialized. Field i   is assigned the value 50 in the static initializer block that is executed   when the class is initialized. This assignment will override the explicit   initialization of field i   in its declaration statement. When the main() method is executed, the static   field i   is 50 and the static field l is 0. When an instance of the class is created   using the new   operator, the value of static field l (i.e., 0) is passed to the constructor.   Before the body of the constructor is executed, the instance initializer   block is executed, which assigns values 70 and 20 to fields j and l,   respectively. When the body of the constructor is executed, the fields i, j, k, and l, and the   parameter m,   have the values 50, 70, 0, 20, and 0, respectively.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec4.html#ch08qa2q3&quot; target=&quot;_top&quot;&gt;8.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (f)&lt;br&gt;This class has a blank final boolean variable active. This   variable must be initialized when an instance is constructed or else the code   will not compile. The keyword static is used to signify that a block is a static   initializer block. No keyword is used to signify that a block is an instance   initializer block. (a) and (b) are not instance initializers blocks, and (c),   (d), and (e) fail to initialize the blank final variable active.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec4.html#ch08qa2q4&quot; target=&quot;_top&quot;&gt;8.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The program will compile without error and will print 2, 3, and 1 when run.   When the object is created and initialized, the instance initializer block is   executed first, printing 2.   Then the instance initializer expression is executed, printing 3. Finally,   the constructor body is executed, printing 1. The forward reference in the   instance initializer block is legal, as the use of the field m is on the   left-hand side of the assignment.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec4.html#ch08qa2q5&quot; target=&quot;_top&quot;&gt;8.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The program will compile without error and will print 1, 3, and 2 when run.   First, the static initializers are executed when the class is initialized,   printing 1   and 3.   When the object is created and initialized, the instance initializer block is   executed, printing 2.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch08lev1sec4.html#ch08qa2q6&quot; target=&quot;_top&quot;&gt;8.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (e)&lt;br&gt;Line A will cause illegal redefinition of the field width. Line B   uses an illegal forward reference to the fields width and height. The   assignment in line C is legal. Line D is not a legal initializer since it is   neither a declaration nor a block. Line E declares a local variable inside an   initializer block.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Threads&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec4.html#ch09qa1q1&quot; target=&quot;_top&quot;&gt;9.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Create a new Thread object and call the method start(). The   call to the start()   method will return immediately, and the thread will start executing the run() method   asynchronously.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec4.html#ch09qa1q2&quot; target=&quot;_top&quot;&gt;9.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;When extending the Thread class, the run() method   should be overridden to provide the code executed by the thread. This is   analogous to implementing the run() method of the Runnable interface.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec4.html#ch09qa1q3&quot; target=&quot;_top&quot;&gt;9.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;The Thread   class implements the Runnable   interface and is not abstract.   A program terminates when the last non-daemon thread ends. The Runnable   interface has a method named run, but the interface does not dictate that   implementations must define a method named start. Calling the run() method   on a Runnable   object does not necessarily create a new thread. Method run() is the   method executed by a thread. Instances of the Thread class must be created to   spawn new threads.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec4.html#ch09qa1q4&quot; target=&quot;_top&quot;&gt;9.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The program will compile without errors, and will simply   terminate without any output when run. Two thread objects will be created,   but they will never be started. The start() method must be called on the   thread objects to make the threads execute the run() method asynchronously.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec6.html#ch09qa2q1&quot; target=&quot;_top&quot;&gt;9.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (e)&lt;br&gt;Because the exact behavior of the scheduler is undefined,   the text A,   B,   and End   can be printed in any order. The thread printing B is a daemon thread, which   means that the program may terminate before the thread manages to print the   letter.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec6.html#ch09qa2q2&quot; target=&quot;_top&quot;&gt;9.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;No two threads can concurrently execute synchronized methods   on the same object. This does not prevent one thread from executing a   non-synchronized method while another thread executes a synchronized method   on the same object. The synchronization mechanism in Java acts like recursive   semaphores, which means that during the time a thread owns the lock, it may   enter and re-enter any region of code associated with the lock.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec6.html#ch09qa2q3&quot; target=&quot;_top&quot;&gt;9.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;One cannot be certain whether any of the letters i, j, and k will be   printed during execution. For each invocation of the doit() method,   each variable pair is incremented and their values are always equal when the   method returns. The only way a letter could be printed would be if the method   check()   was executed between the time the first and the second variable were   incremented. Since the check()   method does not depend on owning any lock, it can be executed at any time,   and the method doit()   cannot protect the atomic nature of its operations by acquiring locks.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec8.html#ch09qa3q1&quot; target=&quot;_top&quot;&gt;9.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;A thread dies when the execution of the run() method   ends. The call to the start()   method is asynchronous, that is, it returns immediately, and it enables the   thread for running. Calling the sleep() or wait() methods will only block the   thread temporarily.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec8.html#ch09qa3q2&quot; target=&quot;_top&quot;&gt;9.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (d)&lt;br&gt;The inner createThread() call is evaluated first, and will   print 23   as the first number. The last number the main thread prints is 14. After the   main thread ends, the thread created by the inner createdThread() completes its join() call   and prints 22.   After this thread ends, the thread created by the outer createThread()   call completes its join()   call and prints the number 12 before the program terminates.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec8.html#ch09qa3q3&quot; target=&quot;_top&quot;&gt;9.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The exact behavior of the scheduler is not defined. There is   no guarantee that a call to the yield() method will grant other threads use of the   CPU.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec8.html#ch09qa3q4&quot; target=&quot;_top&quot;&gt;9.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The notify()   method is defined in the Object   class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec8.html#ch09qa3q5&quot; target=&quot;_top&quot;&gt;9.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The priority of a thread is set by calling the setPriority()   method in the Thread   class. No Thread   constructor accepts a priority level as an argument.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec8.html#ch09qa3q6&quot; target=&quot;_top&quot;&gt;9.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (c)&lt;br&gt;A thread can hold multiple locks; for example, by nesting synchronized   blocks. Invoking the wait()   method on an object whose lock is held by the current thread will relinquish   the lock for the duration of the call. The notify() method does not relinquish   any locks.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec8.html#ch09qa3q7&quot; target=&quot;_top&quot;&gt;9.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;An IllegalMonitorStateException   will be thrown if the wait()   method is called when the current thread does not hold the lock of the   object.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch09lev1sec8.html#ch09qa3q8&quot; target=&quot;_top&quot;&gt;9.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), (d), and (e)&lt;br&gt;The thread terminates once the run() method completes   execution.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Fundamental Classes&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec3.html#ch10qa1q1&quot; target=&quot;_top&quot;&gt;10.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The method hashCode() in the Object class returns a hash code value   of type int.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec3.html#ch10qa1q2&quot; target=&quot;_top&quot;&gt;10.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;All arrays are genuine objects and inherit all the methods   defined in the Object   class, including the clone()   method. Neither the hashCode()   method nor the equals()   method is declared final   in the Object()   class, and it cannot be guaranteed that implementations of these methods will   differentiate between all objects.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec3.html#ch10qa1q3&quot; target=&quot;_top&quot;&gt;10.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The clone()   method of the Object   class will throw a CloneNotSupportedException   if the class of the object does not implement the Cloneable interface.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec5.html#ch10qa2q1&quot; target=&quot;_top&quot;&gt;10.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), and (d)&lt;br&gt;The class java.lang.Void is considered a wrapper class,   although it does not wrap any value. There is no class named java.lang.Int,   but there is a wrapper class named java.lang.Integer. A class named java.lang.String   also exists, but it is not a wrapper class since all strings in Java are   objects.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec5.html#ch10qa2q2&quot; target=&quot;_top&quot;&gt;10.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;The classes Character and Boolean are non-numeric wrapper   classes and they do not extend the Number class. The classes Byte, Short, Integer, Long, Float, and Double are   numeric wrapper classes that extend the Number class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec5.html#ch10qa2q3&quot; target=&quot;_top&quot;&gt;10.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), and (d)&lt;br&gt;All instances of wrapper classes are immutable.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec5.html#ch10qa2q4&quot; target=&quot;_top&quot;&gt;10.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (c)&lt;br&gt;All instances of wrapper classes except Void and Character have   a constructor that accepts a string parameter. The class Object has   only a default constructor.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec5.html#ch10qa2q5&quot; target=&quot;_top&quot;&gt;10.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;While all numeric wrapper classes have the methods byteValue(), doubleValue(),   floatValue(),   intValue(),   longValue(),   and shortValue(),   only the Boolean   class has the booleanValue()   method. Likewise, only the Character class has the charValue()   method.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec5.html#ch10qa2q6&quot; target=&quot;_top&quot;&gt;10.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (d)&lt;br&gt;String   is not a wrapper class. All wrapper classes except Boolean and Void have a compareTo()   method. Only the numeric wrapper classes have an intValue() method. The Byte class,   like all other numeric wrapper classes, extends the Number class.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec7.html#ch10qa3q1&quot; target=&quot;_top&quot;&gt;10.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (d)&lt;br&gt;The lines labeled (2) and (4) will print 11 exactly,   since their expressions will return the int value 11. The expression Math.ceil(v)   will return the double   value 11.0,   which will be printed as 11.0.   The expression Math.floor(v)   will return 10.0d.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec7.html#ch10qa3q2&quot; target=&quot;_top&quot;&gt;10.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The Math   class does not have a method named tan2. However, it does have a method   named atan2,   which converts rectangular coordinates to polar coordinates.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec7.html#ch10qa3q3&quot; target=&quot;_top&quot;&gt;10.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The method round(float) will return a value of type int. A round(double)   method also exists, which returns a value of type long.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec7.html#ch10qa3q4&quot; target=&quot;_top&quot;&gt;10.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The rounding function ceil() will return a value of type double. This   is in contrast to the round()   methods that will return values of integer types.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec7.html#ch10qa3q5&quot; target=&quot;_top&quot;&gt;10.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The value -0.5 is rounded up to 0 and the value 0.5 is   rounded up to 1.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec7.html#ch10qa3q6&quot; target=&quot;_top&quot;&gt;10.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b), (c), and (d)&lt;br&gt;The expression will evaluate to one of the numbers 0, 1, 2,   or 3. Each number has an equal probability of being returned by the   expression.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q1&quot; target=&quot;_top&quot;&gt;10.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;The operators - and &amp;amp; cannot be used in conjunction   with a String   object. The operators +   and +=   perform concatenation on strings, and the dot operator accesses members of   the String   object.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q2&quot; target=&quot;_top&quot;&gt;10.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The expression str.substring(2, 5) will extract the substring &amp;quot;kap&amp;quot;.   The method extracts the characters from index 2 to index 4, inclusive.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q3&quot; target=&quot;_top&quot;&gt;10.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will print str3str1 when run. The concat()   method will create and return a new String object, which is the   concatenation of the current String object and the String object given as an   argument. The expression statement str1.concat(str2) creates a new String object,   but its reference value is not stored.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q4&quot; target=&quot;_top&quot;&gt;10.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The trim()   method of the String   class returns a string where both the leading and the trailing white space of   the original string have been removed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q5&quot; target=&quot;_top&quot;&gt;10.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (c)&lt;br&gt;The String   class and all wrapper classes are declared final and, therefore, cannot be   extended. The clone()   method is declared protected   in the Object   class. String   objects are immutable and, therefore, cannot be modified. The classes String and StringBuffer   are unrelated.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q6&quot; target=&quot;_top&quot;&gt;10.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), (c), and (e)&lt;br&gt;The expressions (&amp;#39;c&amp;#39; + &amp;#39;o&amp;#39; + &amp;#39;o&amp;#39; + &amp;#39;l&amp;#39;) and (&amp;#39;o&amp;#39; + &amp;#39;l&amp;#39;)   are of type int   due to numeric promotion. Expression (d) is illegal since the String class   has no constructor taking a single int parameter. Expression (a) is legal   since string literals denote String objects and can be used just like any other   object.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q7&quot; target=&quot;_top&quot;&gt;10.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The constant expressions &amp;quot;ab&amp;quot; + &amp;quot;12&amp;quot; and &amp;quot;ab&amp;quot; + 12   will, at compile time, be evalutated to the string-valued constant &amp;quot;ab12&amp;quot;.   Both variables s   and t   are assigned a reference to the same interned String object containing &amp;quot;ab12&amp;quot;.   The variable u   is assigned a new String   object, created using the new   operator.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q8&quot; target=&quot;_top&quot;&gt;10.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (c), and (d)&lt;br&gt;The String   class does not have a constructor that takes a single int as a   parameter.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q9&quot; target=&quot;_top&quot;&gt;10.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The String   class has no reverse()   method.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q10&quot; target=&quot;_top&quot;&gt;10.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The expression &amp;quot;abcdef&amp;quot;.charAt(3) evaluates to the   character &amp;#39;d&amp;#39;.   The charAt()   method takes an int   value as an argument and returns a char value. The expression (&amp;quot;abcdef&amp;quot;).charAt(3)   is legal. It also evaluates to the character &amp;#39;d&amp;#39;. The index of the first character   in a string is 0.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q11&quot; target=&quot;_top&quot;&gt;10.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The expression &amp;quot;Hello there&amp;quot;.toLowerCase().equals(&amp;quot;hello   there&amp;quot;) will evaluate to true. The equals() method in the String class   will only return true   if the two strings have the same sequence of characters.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec9.html#ch10qa4q12&quot; target=&quot;_top&quot;&gt;10.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;The variable middle is assigned the value 6. The variable nt is assigned   the string &amp;quot;nt&amp;quot;.   The substring &amp;quot;nt&amp;quot;   occurs three times in the string &amp;quot;Contentment!&amp;quot;, starting at   indexes 2, 5, and 9. The call s.lastIndexOf(nt, middle) returns the start index   of the last occurrence of &amp;quot;nt&amp;quot;,   searching backwards from position 6.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec11.html#ch10qa5q1&quot; target=&quot;_top&quot;&gt;10.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The code will fail to compile since the expression (s == sb) is   illegal. It compares references of two classes that are not related.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec11.html#ch10qa5q2&quot; target=&quot;_top&quot;&gt;10.29&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (e)&lt;br&gt;The program will compile without errors and will print have a when   run. The contents of the string buffer are truncated down to 6 characters.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec11.html#ch10qa5q3&quot; target=&quot;_top&quot;&gt;10.30&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), and (d)&lt;br&gt;The StringBuffer   class does not have a constructor that takes an array of char as a   parameter.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec11.html#ch10qa5q4&quot; target=&quot;_top&quot;&gt;10.31&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;The StringBuffer   class does not define a trim()   method.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch10lev1sec11.html#ch10qa5q5&quot; target=&quot;_top&quot;&gt;10.32&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will construct an immutable String object   containing &amp;quot;eenny&amp;quot;   and a StringBuffer   object containing &amp;quot;   miny&amp;quot;. The   concat()   method returns a reference value to a new immutable String object   containing &amp;quot;eenny   meeny&amp;quot;, but the reference value is not stored. The append()   method appends the string &amp;quot;   mo&amp;quot; to the string buffer.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Collections and Maps&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec3.html#ch11qa1q1&quot; target=&quot;_top&quot;&gt;11.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (d), and (e)&lt;br&gt;Set,   Collection   and Map   are core interfaces in the collections framework. LinkedList is a class that   implements the List   interface. There is no class or interface named Bag.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec3.html#ch11qa1q2&quot; target=&quot;_top&quot;&gt;11.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (e)&lt;br&gt;The java.util   package provides map implementations named HashMap and TreeMap. It   does not provide any implementations named HashList, ArraySet, and ArrayMap.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec3.html#ch11qa1q3&quot; target=&quot;_top&quot;&gt;11.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The List   interface is implemented by collections that maintain sequences of possibly   non-unique elements. Elements retain their ordering in the sequence.   Collection classes implementing SortedSet only allow unique elements that are   maintained in a sorted order.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec6.html#ch11qa2q1&quot; target=&quot;_top&quot;&gt;11.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (c)&lt;br&gt;Some operations on a collection may throw an UnsupportedOperationException.   This exception type is unchecked, and the code is not required to explicitly   handle unchecked exceptions. A List allows duplicate elements. An ArrayList   implements a resizable array. The capacity of the array will be expanded   automatically when needed. The List interface defines a get() method,   but there is no method by that name in the Collection interface.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec6.html#ch11qa2q2&quot; target=&quot;_top&quot;&gt;11.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (d)&lt;br&gt;The program will compile without error, and will print all   primes below 25 when run. All the collection implementations used in the   program implement the Collection   interface. The implementation instances are interchangeable when denoted by Collection   references. None of the operations performed on the implementations will throw   an UnsupportedOperationException.   The program finds the primes below 25 by removing all values divisible by 2,   3, and 5 from the set of values from 2 through 25.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec6.html#ch11qa2q3&quot; target=&quot;_top&quot;&gt;11.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a), (b), and (d)&lt;br&gt;The methods add(), retainAll(), and iterator() are   defined in the Collection   interface. The get()   and indexOf()   methods are defined in the List interface.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec6.html#ch11qa2q4&quot; target=&quot;_top&quot;&gt;11.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b)&lt;br&gt;The remove()   method removes the last element returned by either next() or previous().   The four next()   calls return A,   B, C, and D. D is   subsequently removed. The two previous() calls return C and B. B is   subsequently removed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec6.html#ch11qa2q5&quot; target=&quot;_top&quot;&gt;11.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (d)&lt;br&gt;The methods add() and retainAll(), return the value true if the   collection was modified during the operation. The contains() and containsAll()   methods return a boolean   value, but these membership operations never modify the current collection,   and the return value indicates the result of the membership test. The clear() method   does not have a return value.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec9.html#ch11qa3q1&quot; target=&quot;_top&quot;&gt;11.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (d)&lt;br&gt;The Map   interface defines the methods remove() and values(). It does not define methods contains(), addAll(), and toArray().   Methods with these names are defined in the Collection interface, but Map does not   inherit from Collection.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec9.html#ch11qa3q2&quot; target=&quot;_top&quot;&gt;11.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b) and (d)&lt;br&gt;Although all the keys in a map must be unique, multiple   identical values may exist. Since values are not unique, the values()   method returns a Collection   instance and not a Set   instance. The collection objects returned by the keySet(), entrySet(),   and values()   methods are backed by the original Map object. This means that changes   made in one are reflected in the other. Although implementations of SortedMap keep   the entries sorted on the keys, this is not a requirement for classes that   implement Map.   For instance, the entries in a HashMap are not sorted.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec9.html#ch11qa3q3&quot; target=&quot;_top&quot;&gt;11.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a)&lt;br&gt;[1,   3, 2] is printed. First, &amp;quot;1&amp;quot; and &amp;quot;2&amp;quot;   are appended to an empty list. Next, &amp;quot;3&amp;quot; is inserted between &amp;quot;1&amp;quot;   and &amp;quot;2&amp;quot;,   and then the list is duplicated. The original list is concatenated with the   copy. The sequence of elements in the list is now &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;,   &amp;quot;2&amp;quot;,   &amp;quot;1&amp;quot;,   &amp;quot;3&amp;quot;,   &amp;quot;2&amp;quot;.   Then a sublist view allowing access to elements from index 2 to index 5   (exclusive) is created (i.e., the subsequence &amp;quot;2&amp;quot;, &amp;quot;1&amp;quot;,   &amp;quot;3&amp;quot;).   The sublist is cleared, thus removing the elements. This is reflected in the   original list and the sequence of elements is now &amp;quot;1&amp;quot;, &amp;quot;3&amp;quot;,   &amp;quot;2&amp;quot;.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec9.html#ch11qa3q4&quot; target=&quot;_top&quot;&gt;11.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c) and (e)&lt;br&gt;The classes TreeSet and TreeMap implement the comparator()   method. The comparator()   method is defined in the SortedSet   and SortedMap   interfaces, and the TreeSet   and TreeMap   classes implement these interfaces.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec9.html#ch11qa3q5&quot; target=&quot;_top&quot;&gt;11.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (d)&lt;br&gt;The key of a Map.Entry cannot be changed since the key is used   for locating the entry within the list. Although iterators obtained for the   entry set of a map have a remove()   method, the entries themselves do not. Map.Entry has a method named setValue, but   its return type is Object.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;16&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec12.html#ch11qa4q1&quot; target=&quot;_top&quot;&gt;11.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (c)&lt;br&gt;(b) is eliminated since the hashCode() method cannot claim   inequality if the equals()   method claims equality. (d) and (e) are eliminated since the equal() method   must be reflexive, and the hashCode() method must consistently return the   same hash value during the execution.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec12.html#ch11qa4q2&quot; target=&quot;_top&quot;&gt;11.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (b), (d), and (e)&lt;br&gt;(a) and (c) fail to satisfy the properties of an equivalence   relation. (a) is not transitive and (c) is not symmetric.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec12.html#ch11qa4q3&quot; target=&quot;_top&quot;&gt;11.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (c)&lt;br&gt;Of all the collection classes in the java.util   package, only Vector   and HashTable   are thread-safe. The Collections   class contains a static synchronizedCollectionType() method that creates thread-safe   instances based on collections, which are not.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;      &lt;/td&gt;   &lt;td&gt;      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_ch11lev1sec12.html#ch11qa4q4&quot; target=&quot;_top&quot;&gt;11.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   (a) and (e)&lt;br&gt;(b) is not correct since it will throw an ArithmeticException   when called on a newly created Measurement object. (c) and (d) are not correct   since they may return unequal hash values for two objects that are equal   according to the equals()   method.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>Review of Java</title><link>http://faqworldofrastogi.wetpaint.com/page/Review+of+Java</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/Review+of+Java</guid><pubDate>Fri, 14 Sep 2007 00:32:33 CDT</pubDate><description>  &lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;Review of Java Language&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Basics of Java Programming&lt;/u&gt;&lt;/b&gt;&lt;br&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;1.1&lt;/b&gt;&lt;a name=&quot;ch01qa1q1&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true about a method? Select   the one correct answer.&lt;br&gt;a.   A method is an implementation of an abstraction.&lt;br&gt;b.   A method is an attribute defining the property of a   particular abstraction.&lt;br&gt;c.   A method is a category of objects.&lt;br&gt;d.   A method is an operation defining the behavior for a   particular abstraction.&lt;br&gt;e.   A method is a blueprint for making operations.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;1.2&lt;/b&gt;&lt;a name=&quot;ch01qa1q2&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true about an object?   Select the one correct answer.&lt;br&gt;a.   An object is what classes are instantiated from.&lt;br&gt;b.   An object is an instance of a class.&lt;br&gt;c.   An object is a blueprint for creating concrete realization   of abstractions.&lt;br&gt;d.   An object is a reference to an attribute.&lt;br&gt;e.   An object is a variable.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;1.3&lt;/b&gt;&lt;a name=&quot;ch01qa1q3&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which line contains a constructor in this class definition?&lt;br&gt;public class Counter { // (1) int current, step; public Counter(int startValue, int stepValue) { // (2) set(startValue); setStepValue(stepValue); } public int get() { return current; } // (3) public void set(int value) { current = value; } // (4) public void setStepValue(int stepValue) { step = stepValue; } // (5)}Select the one correct answer.   a.   Code marked with (1) is a constructor.&lt;br&gt;b.   Code marked with (2) is a constructor.&lt;br&gt;c.   Code marked with (3) is a constructor.&lt;br&gt;d.   Code marked with (4) is a constructor.&lt;br&gt;e.   Code marked with (5) is a constructor.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec1.html#ch01qa1q4a1&quot; target=&quot;_top&quot;&gt;1.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given that Thing is a class, how many objects and how many   reference variables are created by the following code?&lt;br&gt;Thing item, stuff;item = new Thing();Thing entity = new Thing();   Select the two correct answers.&lt;br&gt;a.   One object is created.&lt;br&gt;b.   Two objects are created.&lt;br&gt;c.   Three objects are created.&lt;br&gt;d.   One reference variable is created.&lt;br&gt;e.   Two reference variables are created.&lt;br&gt;f.   Three reference variables are created.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec1.html#ch01qa1q5a1&quot; target=&quot;_top&quot;&gt;1.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true about an instance method?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   An instance member is also called a static member.&lt;br&gt;b.   An instance member is always a field.&lt;br&gt;c.   An instance member is never a method.&lt;br&gt;d.   An instance member belongs to an instance, not to the class   as a whole.&lt;br&gt;e.   An instance member always represents an operation.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec1.html#ch01qa1q6a1&quot; target=&quot;_top&quot;&gt;1.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   How do objects pass messages in Java?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   They pass messages by modifying each other&amp;#39;s fields.&lt;br&gt;b.   They pass messages by modifying the static variables of each   other&amp;#39;s classes.&lt;br&gt;c.   They pass messages by calling each other&amp;#39;s instance methods.&lt;br&gt;d.   They pass messages by calling static methods of each other&amp;#39;s   classes.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec1.html#ch01qa1q7a1&quot; target=&quot;_top&quot;&gt;1.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following code, which statements are true?&lt;br&gt;class A { int value1;}class B extends A { int value2;}   Select the two correct answers.&lt;br&gt;a.   Class A   extends class B.&lt;br&gt;b.   Class B   is the superclass of class A.&lt;br&gt;c.   Class A   inherits from class B.&lt;br&gt;d.   Class B   is a subclass of class A.&lt;br&gt;e.   Objects of class A have a field named value2.&lt;br&gt;f.   Objects of class B have a field named value1.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec1.html#ch01qa2q1a1&quot; target=&quot;_top&quot;&gt;1.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What command in the Java 2 SDK should be used to compile the   following code contained in a file called SmallProg.java?&lt;br&gt;public class SmallProg {&lt;br&gt;public static void   main(String[] args) { System.out.println(&amp;quot;Good luck!&amp;quot;); }&lt;br&gt;}Select the one correct answer.&lt;br&gt;a.   java   SmallProg&lt;br&gt;b.   javac   SmallProg&lt;br&gt;c.   java   SmallProg.java&lt;br&gt;d.   javac   SmallProg.java&lt;br&gt;e.   java   SmallProg main   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec1.html#ch01qa2q2a1&quot; target=&quot;_top&quot;&gt;1.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What command in the Java 2 SDK should be used to execute the   main()   method of a class named SmallProg?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   java   SmallProg&lt;br&gt;b.   javac   SmallProg&lt;br&gt;c.   java   SmallProg.java&lt;br&gt;d.   java   SmallProg.class&lt;br&gt;e.   java   SmallProg.main()   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;br&gt;&lt;b&gt;&lt;u&gt;Language Fundamental&lt;/u&gt;&lt;/b&gt;&lt;br&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa1q1a1&quot; target=&quot;_top&quot;&gt;2.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of the following is not a legal identifier?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   a2z&lt;br&gt;b.   &amp;ouml;dipus&lt;br&gt;c.   52pickup&lt;br&gt;d.   _class&lt;br&gt;e.   ca$h&lt;br&gt;f.   total#   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa1q2a1&quot; target=&quot;_top&quot;&gt;2.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   new   and delete   are keywords in the Java language.&lt;br&gt;b.   try,   catch,   and thrown   are keywords in the Java language.&lt;br&gt;c.   static,   unsigned,   and long   are keywords in the Java language.&lt;br&gt;d.   exit,   class,   and while   are keywords in the Java language.&lt;br&gt;e.   return,   goto,   and default   are keywords in the Java language.&lt;br&gt;f.   for,   while,   and next   are keywords in the Java language.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa1q3a1&quot; target=&quot;_top&quot;&gt;2.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Is this a complete and legal comment?&lt;br&gt;/* // */   Select the one correct answer.&lt;br&gt;a.   No, the block comment (/* ... */) is not ended since the   single-line comment (//   ...) comments out the closing part.&lt;br&gt;b.   It is a completely valid comment. The // part is   ignored by the compiler.&lt;br&gt;c.   This combination of comments is illegal and the compiler   will reject it.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa2q1a1&quot; target=&quot;_top&quot;&gt;2.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of the following do not denote a primitive data value in Java?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   &amp;quot;t&amp;quot;&lt;br&gt;b.   &amp;#39;k&amp;#39;&lt;br&gt;c.   50.5F&lt;br&gt;d.   &amp;quot;hello&amp;quot;&lt;br&gt;e.   false   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa2q2a1&quot; target=&quot;_top&quot;&gt;2.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of the following primitive data types are not integer types?&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   Type boolean&lt;br&gt;b.   Type byte&lt;br&gt;c.   Type float&lt;br&gt;d.   Type short&lt;br&gt;e.   Type double   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa2q3a1&quot; target=&quot;_top&quot;&gt;2.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   integral type in Java has the exact range from -2147483648 (-231) to 2147483647 (231-1),   inclusive?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Type byte&lt;br&gt;b.   Type short&lt;br&gt;c.   Type int&lt;br&gt;d.   Type long&lt;br&gt;e.   Type char   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa3q1a1&quot; target=&quot;_top&quot;&gt;2.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which of the following lines are valid declarations?Select the three correct answers.   a.   char a = &amp;#39;\u0061&amp;#39;;&lt;br&gt;b.   char &amp;#39;a&amp;#39; = &amp;#39;a&amp;#39;;&lt;br&gt;c.   char \u0061 = &amp;#39;a&amp;#39;;&lt;br&gt;d.   ch\u0061r a = &amp;#39;a&amp;#39;;&lt;br&gt;e.   ch&amp;#39;a&amp;#39;r a = &amp;#39;a&amp;#39;;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa3q2a1&quot; target=&quot;_top&quot;&gt;2.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Given the following code within a method, which statement is true?int a, b;b = 5;Select the one correct answer.   a.   Local variable a is   not declared.&lt;br&gt;b.   Local variable b is   not declared.&lt;br&gt;c.   Local variable a is   declared but not initialized.&lt;br&gt;d.   Local variable b is   declared but not initialized.&lt;br&gt;e.   Local variable b is   initialized but not declared.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa3q3a1&quot; target=&quot;_top&quot;&gt;2.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;In which of these variable declarations will the variable remain uninitialized unless explicitly initialized?Select the one correct answer.   a.   Declaration of an instance variable of type int.&lt;br&gt;b.   Declaration of a static variable of type float.&lt;br&gt;c.   Declaration of a local variable of type float.&lt;br&gt;d.   Declaration of a static variable of type Object.&lt;br&gt;e.   Declaration of an instance variable of type int[].   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa4q1a1&quot; target=&quot;_top&quot;&gt;2.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;What will be the result of attempting to compile this class?import java.util.*;package com.acme.toolkit;public class AClass { public Other anInstance;}class Other { int value;}Select the one correct answer.   a.   The   class will fail to compile, since the class Other has not yet been   declared when referenced in class AClass.&lt;br&gt;b.   The   class will fail to compile, since import statements must never be at   the very top of a file.&lt;br&gt;c.   The   class will fail to compile, since the package declaration can never   occur after an import statement.&lt;br&gt;d.   The   class will fail to compile, since the class Other must be defined in   a file called Other.java.&lt;br&gt;e.   The   class will fail to compile, since the class Other must be declared public.&lt;br&gt;f.   The   class will compile without errors.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa4q2a1&quot; target=&quot;_top&quot;&gt;2.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Is an empty file a valid source file?Answer true or false.&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa5q1a1&quot; target=&quot;_top&quot;&gt;2.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which of these are valid declarations of the main() method in order to start the execution of a Java application?Select the two correct answers.   a.   static   void main(String[] args) { /* ... */ }&lt;br&gt;b.   public   static int main(String[] args) { /* ... */ }&lt;br&gt;c.   public   static void main(String args) { /* ... */ }&lt;br&gt;d.   final   public static void main(String[] arguments) { /* ... */ }&lt;br&gt;e.   public   int main(Strings[] args, int argc) { /* ... */ }&lt;br&gt;f.   static   public void main(String args[]) { /* ... */ }   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec2.html#ch02qa5q2a1&quot; target=&quot;_top&quot;&gt;2.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which of the following are reserved keywords?Select the three correct answers.   a.   public&lt;br&gt;b.   static&lt;br&gt;c.   void&lt;br&gt;d.   main&lt;br&gt;e.   String&lt;br&gt;f.   args   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Operator &amp;amp; Assignment&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa1q1a1&quot; target=&quot;_top&quot;&gt;3.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given char   c = &amp;#39;A&amp;#39;;&lt;br&gt;What is the simplest way to convert the character value in c into an int?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   int   i = c;&lt;br&gt;b.   int   i = (int) c;&lt;br&gt;c.   int   i = Character.getNumericValue(c);   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa1q2a1&quot; target=&quot;_top&quot;&gt;3.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following class?&lt;br&gt;public class Assignment { public static void main(String[] args) { int a, b, c; b = 10; a = b = c = 20; System.out.println(a); }}   Select the one correct answer.&lt;br&gt;a.   The code will fail to compile, since the compiler will   recognize that the variable c in the assignment statement a = b = c = 20;   has not been initialized.&lt;br&gt;b.   The code will fail to compile because the assignment   statement a = b   = c = 20; is illegal.&lt;br&gt;c.   The code will compile correctly and will display 10 when run.&lt;br&gt;d.   The code will compile correctly and will display 20 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa1q3a1&quot; target=&quot;_top&quot;&gt;3.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class MyClass { public static void main(String[] args) { String a, b, c; c = new String(&amp;quot;mouse&amp;quot;); a = new String(&amp;quot;cat&amp;quot;); b = a; a = new String(&amp;quot;dog&amp;quot;); c = b; System.out.println(c); }}   Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will print mouse when run.&lt;br&gt;c.   The program will print cat when run.&lt;br&gt;d.   The program will print dog when run.&lt;br&gt;e.   The program will randomly print either cat or dog when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa2q1a1&quot; target=&quot;_top&quot;&gt;3.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of the following expressions will be evaluated using floating-point   arithmetic?&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   2.0 * 3.0&lt;br&gt;b.   2 * 3&lt;br&gt;c.   2/3 + 5/7&lt;br&gt;d.   2.4 + 1.6&lt;br&gt;e.   0x10 * 1L * 300.0   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa2q2a1&quot; target=&quot;_top&quot;&gt;3.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   is the value of the expression (1 / 2 + 3 / 2 + 0.1)?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   1&lt;br&gt;b.   1.1&lt;br&gt;c.   1.6&lt;br&gt;d.   2&lt;br&gt;e.   2.1   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa2q3a1&quot; target=&quot;_top&quot;&gt;3.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   will be the result of attempting to compile and run the following program?&lt;br&gt;public   class Integers {&lt;br&gt; public static void main(String[] args) {&lt;br&gt; System.out.println(0x10 + 10 + 010);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   The program will not compile. The compiler will complain   about the expression 0x10 + 10 + 010.&lt;br&gt;b.   When run, the program will print 28.&lt;br&gt;c.   When run, the program will print 30.&lt;br&gt;d.   When run, the program will print 34.&lt;br&gt;e.   When run, the program will print 36.&lt;br&gt;f.   When run, the program will print 101010.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa2q4a1&quot; target=&quot;_top&quot;&gt;3.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of the following expressions are valid?&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   (- 1 -)&lt;br&gt;b.   (+ + 1)&lt;br&gt;c.   (+-+-+-1)&lt;br&gt;d.   (--1)&lt;br&gt;e.   (1 * * 1)&lt;br&gt;f.   (- -1)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa2q5a1&quot; target=&quot;_top&quot;&gt;3.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   is the value of evaluating the following expression (- -1-3 * 10 / 5-1)?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   &amp;ndash;8&lt;br&gt;b.   &amp;ndash;6&lt;br&gt;c.   7&lt;br&gt;d.   8&lt;br&gt;e.   10&lt;br&gt;f.   None of the above.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa2q6a1&quot; target=&quot;_top&quot;&gt;3.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of these assignments are valid?&lt;br&gt;Select   the four correct answers.&lt;br&gt;a.   short s = 12;&lt;br&gt;b.   long l = 012;&lt;br&gt;c.   int other = (int) true;&lt;br&gt;d.   float f = -123;&lt;br&gt;e.   double d = 0x12345678;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa3q1a1&quot; target=&quot;_top&quot;&gt;3.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which statements are true?Select the three correct answers.   a.   The result of the expression (1   + 2 + &amp;quot;3&amp;quot;) would be the string &amp;quot;33&amp;quot;.&lt;br&gt;b.   The result of the expression (&amp;quot;1&amp;quot;   + 2 + 3) would be the string &amp;quot;15&amp;quot;.&lt;br&gt;c.   The result of the expression (4   + 1.0f) would be the float   value 5.0f.&lt;br&gt;d.   The result of the expression (10/9)   would be the int value 1.&lt;br&gt;e.   The result of the expression (&amp;#39;a&amp;#39;   + 1) would be the char   value &amp;#39;b&amp;#39;.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa3q2a1&quot; target=&quot;_top&quot;&gt;3.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;What happens when you try to compile and run the following program?public class Prog1 { public static void main(String[] args) { int k = 1; int i = ++k + k++ + + k; System.out.println(i); }}Select the one correct answer.   a.   The program will not compile. The compiler will complain   about the expression ++k + k++ + + k.&lt;br&gt;b.   The program will compile and will print the value 3 when run.&lt;br&gt;c.   The program will compile and will print the value 4 when run.&lt;br&gt;d.   The program will compile and will print the value 7 when run.&lt;br&gt;e.   The program will compile and will print the value 8 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa3q3a1&quot; target=&quot;_top&quot;&gt;3.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which is the first incorrect line that will cause a compile time error in the following program?public class MyClass { public static void main(String[] args) { char c; int i; c = &amp;#39;a&amp;#39;; // (1) i = c; // (2) i++; // (3) c = i; // (4) c++; // (5) }}Select the one correct answer.   a.   The line labeled (1)&lt;br&gt;b.   The line labeled (2)&lt;br&gt;c.   The line labeled (3)&lt;br&gt;d.   The line labeled (4)&lt;br&gt;e.   The line labeled (5)&lt;br&gt;f.   None of the lines are incorrect. The program will compile   just fine.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa3q4a1&quot; target=&quot;_top&quot;&gt;3.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;What happens when you try to compile and run the following program?public class Cast { public static void main(String[] args) { byte b = 128; int i = b; System.out.println(i); }}Select the one correct answer.   a.   The compiler will refuse to compile it, since you cannot   assign a byte to an int without a cast.&lt;br&gt;b.   The program will compile and will print 128 when run.&lt;br&gt;c.   The compiler will refuse to compile it, since 128 is outside the legal range of values for a   byte.&lt;br&gt;d.   The program will compile, but will throw a ClassCastException when run.&lt;br&gt;e.   The program will compile and will print 255 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa3q5a1&quot; target=&quot;_top&quot;&gt;3.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;What will the following program print when run?public class EvaluationOrder { public static void main(String[] args) { int[] array = { 4, 8, 16 }; int i=1; array[++i] = --i; System.out.println(array[0] + array[1] + array[2]); }}Select the one correct answer.   a.   13&lt;br&gt;b.   14&lt;br&gt;c.   20&lt;br&gt;d.   21&lt;br&gt;e.   24   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa4q1a1&quot; target=&quot;_top&quot;&gt;3.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which of the following expressions evaluates to true?Select the two correct answers.   a.   (false   | true)&lt;br&gt;b.   (null   != null)&lt;br&gt;c.   (4   &amp;lt;= 4)&lt;br&gt;d.   (!true)&lt;br&gt;e.   (true   &amp;amp; false)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa4q2a1&quot; target=&quot;_top&quot;&gt;3.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which statements are true?Select the two correct answers.   a.   The   remainder operator % can only be used with integral operands.&lt;br&gt;b.   Identifiers   in Java are case insensitive.&lt;br&gt;c.   The   arithmetic operators *, /, and % have the same   level of precedence.&lt;br&gt;d.   A   short value ranges from -128 to +127 inclusive.&lt;br&gt;e.   (+15) is a legal expression.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa4q3a1&quot; target=&quot;_top&quot;&gt;3.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which statements are true about the lines of output printed by the following program?public class BoolOp { static void op(boolean a, boolean b) { boolean c = a != b; boolean d = a ^ b; boolean e = c == d; System.out.println(e); } public static void main(String[] args) { op(false, false); op(true, false); op(false, true); op(true, true); }}Select the three correct answers.   a.   All   lines printed are the same.&lt;br&gt;b.   At   least one line contains false.&lt;br&gt;c.   At   least one line contains true.&lt;br&gt;d.   The   first line contains false.&lt;br&gt;e.   The   last line contains true.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa4q4a1&quot; target=&quot;_top&quot;&gt;3.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;What happens during execution of the following program?public class OperandOrder { public static void main(String[] args) { int i = 0; int[] a = {3,6}; a[i] = i = 9; System.out.println(i + &amp;quot; &amp;quot; + a[0] + &amp;quot; &amp;quot; + a[1]); }}Select the one correct answer.   a.   Throws   an exception of type ArrayIndexOutOfBoundsException&lt;br&gt;b.   Prints   &amp;quot;9 9 6&amp;quot;&lt;br&gt;c.   Prints   &amp;quot;9 0 6&amp;quot;&lt;br&gt;d.   Prints   &amp;quot;9 3 6&amp;quot;&lt;br&gt;e.   Prints   &amp;quot;9 3 9&amp;quot;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;/td&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa4q5a1&quot; target=&quot;_top&quot;&gt;3.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which statements are true about the output of the following program?public class Logic { public static void main(String[] args) { int i = 0; int j = 0; boolean t = true; boolean r; r = (t &amp;amp; 0&amp;lt;(i+=1)); r = (t &amp;amp;&amp;amp; 0&amp;lt;(i+=2)); r = (t | 0&amp;lt;(j+=1)); r = (t || 0&amp;lt;(j+=2)); System.out.println(i + &amp;quot; &amp;quot; + j); }}Select the two correct answers.   a.   The   first digit printed is 1.&lt;br&gt;b.   The   first digit printed is 2.&lt;br&gt;c.   The   first digit printed is 3.&lt;br&gt;d.   The   second digit printed is 1.&lt;br&gt;e.   The   second digit printed is 2.&lt;br&gt;f.   The   second digit printed is 3.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa5q1a1&quot; target=&quot;_top&quot;&gt;3.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   What would be printed during execution of the following   program?&lt;br&gt;public class MyClass { public static void main(String[] args) { test(1&amp;lt;&amp;lt;32, &amp;quot;1&amp;lt;&amp;lt;32&amp;quot;); test(1&amp;lt;&amp;lt;31, &amp;quot;1&amp;lt;&amp;lt;31&amp;quot;); test(1&amp;lt;&amp;lt;30, &amp;quot;1&amp;lt;&amp;lt;30&amp;quot;); test(1, &amp;quot;1&amp;quot; ); test(0, &amp;quot;0&amp;quot; ); test(-1, &amp;quot;-1&amp;quot; ); } public static void test(int i, String exp) { if ((i &amp;gt;&amp;gt; 1) != (i &amp;gt;&amp;gt;&amp;gt; 1)) System.out.println(exp); }}   Select the two correct answers.&lt;br&gt;a.   &amp;quot;1&amp;lt;&amp;lt;32&amp;quot;&lt;br&gt;b.   &amp;quot;1&amp;lt;&amp;lt;31&amp;quot;&lt;br&gt;c.   &amp;quot;1&amp;lt;&amp;lt;30&amp;quot;&lt;br&gt;d.   &amp;quot;1&amp;quot;&lt;br&gt;e.   &amp;quot;0&amp;quot;&lt;br&gt;f.   &amp;quot;-1&amp;quot;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa5q2a1&quot; target=&quot;_top&quot;&gt;3.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   Which of the following are not operators in Java?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   %&lt;br&gt;b.   &amp;lt;&amp;lt;&amp;lt;&lt;br&gt;c.   &amp;amp;&lt;br&gt;d.   %=&lt;br&gt;e.   &amp;gt;&amp;gt;&amp;gt;&lt;br&gt;f.   &amp;lt;=&lt;br&gt;g.   &amp;amp;&amp;amp;=   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa5q3a1&quot; target=&quot;_top&quot;&gt;3.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   Given a variable x of type int (which may contain a   negative value), which are correct ways of doubling the value of x, barring any   wrapping of out-of-range intermediate values?&lt;br&gt;Select the four correct answers.&lt;br&gt;a.   x   &amp;lt;&amp;lt; 1;&lt;br&gt;b.   x   = x * 2;&lt;br&gt;c.   x   *= 2;&lt;br&gt;d.   x   += x;&lt;br&gt;e.   x   &amp;lt;&amp;lt;= 1;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa5q4a1&quot; target=&quot;_top&quot;&gt;3.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   Which of the following operators can be used both as an   integer bitwise operator and a boolean logical operator?&lt;br&gt;Select the three correct answers.&lt;br&gt;a.   ^&lt;br&gt;b.   !&lt;br&gt;c.   &amp;amp;&lt;br&gt;d.   |&lt;br&gt;e.   ~   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa5q5a1&quot; target=&quot;_top&quot;&gt;3.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   Given these declarations, which of the following expressions   are valid?&lt;br&gt;byte b = 1;char c = 1;short s = 1;int i = 1;   Select the three correct answers.&lt;br&gt;a.   s   = b * 2;&lt;br&gt;b.   i   = b &amp;lt;&amp;lt; s;&lt;br&gt;c.   b   &amp;lt;&amp;lt;= s;&lt;br&gt;d.   c   = c + b;&lt;br&gt;e.   s   += i;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa6q1a1&quot; target=&quot;_top&quot;&gt;3.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   What will be printed when the following program is run?&lt;br&gt;public class ParameterPass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; int i = 0;&lt;br&gt; addTwo(i++);&lt;br&gt;   System.out.println(i);&lt;br&gt; }&lt;br&gt;&lt;br&gt; static void   addTwo(int i) {&lt;br&gt; i += 2;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   0&lt;br&gt;b.   1&lt;br&gt;c.   2&lt;br&gt;d.   3   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa6q2a1&quot; target=&quot;_top&quot;&gt;3.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   What will be the result of attempting to compile and run the   following class?&lt;br&gt;public class Passing {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; int a = 0;   int b = 0;&lt;br&gt; int[] bArr =   new int[1]; bArr[0] = b;&lt;br&gt;&lt;br&gt; inc1(a);   inc2(bArr);&lt;br&gt;&lt;br&gt; System.out.println(&amp;quot;a=&amp;quot;   + a + &amp;quot; b=&amp;quot; + b + &amp;quot; bArr[0]=&amp;quot; + bArr[0]);&lt;br&gt; }&lt;br&gt;&lt;br&gt; public static   void inc1(int x) { x++; }&lt;br&gt;&lt;br&gt; public static   void inc2(int[] x) { x[0]++; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile, since x[0]++; is not   a legal statement.&lt;br&gt;b.   The code will compile and will print &amp;quot;a=1 b=1   bArr[0]=1&amp;quot; when run.&lt;br&gt;c.   The code will compile and will print &amp;quot;a=0 b=1   bArr[0]=1&amp;quot; when run.&lt;br&gt;d.   The code will compile and will print &amp;quot;a=0 b=0   bArr[0]=1&amp;quot; when run.&lt;br&gt;e.   The code will compile and will print &amp;quot;a=0 b=0 bArr[0]=0&amp;quot;   when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa6q3a1&quot; target=&quot;_top&quot;&gt;3.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   Given the class&lt;br&gt;// Filename: Args.java&lt;br&gt;public class Args {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt;   System.out.println(args[0] + &amp;quot; &amp;quot; + args[args.length-1]);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;what would be the result of executing the following on the   command line?&lt;br&gt;java Args In politics stupidity is not a handicap&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The program will throw ArrayIndexOutOfBoundsException.&lt;br&gt;b.   The program will print &amp;quot;java handicap&amp;quot;.&lt;br&gt;c.   The program will print &amp;quot;Args handicap&amp;quot;.&lt;br&gt;d.   The program will print &amp;quot;In handicap&amp;quot;.&lt;br&gt;e.   The program will print &amp;quot;Args a&amp;quot;.&lt;br&gt;f.   The program will print &amp;quot;In a&amp;quot;.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td colspan=&quot;2&quot; width=&quot;43&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec3.html#ch03qa6q4a1&quot; target=&quot;_top&quot;&gt;3.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;548&quot;&gt;   Which statements would cause a compilation error if inserted   in the location indicated in the following program?&lt;br&gt;public class ParameterUse {&lt;br&gt; static void   main(String[] args) {&lt;br&gt; int a = 0;&lt;br&gt; final int b =   1;&lt;br&gt; int[] c = { 2   };&lt;br&gt; final int[] d   = { 3 };&lt;br&gt; useArgs(a, b,   c, d);&lt;br&gt; } static void useArgs(final int a, int b,   final int[] c, int[] d) {&lt;br&gt; // INSERT   STATEMENT HERE.&lt;br&gt; }&lt;br&gt;} Select the two correct answers.&lt;br&gt;a.   a++;&lt;br&gt;b.   b++;&lt;br&gt;c.   b   = a;&lt;br&gt;d.   c[0]++;&lt;br&gt;e.   d[0]++;&lt;br&gt;f.   c   = d;   &lt;/td&gt;  &lt;/tr&gt;    &lt;tr&gt;   &lt;td width=&quot;0&quot;&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;46&quot;&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;544&quot;&gt;&lt;br&gt;&lt;/td&gt;  &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Declarations and Access Control&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa1q1a1&quot; target=&quot;_top&quot;&gt;4.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following declaration, which expression returns   the size of the array, assuming the array has been initialized?&lt;br&gt;int[] array;   Select the one correct answer.&lt;br&gt;a.   array[].length()&lt;br&gt;b.   array.length()&lt;br&gt;c.   array[].length&lt;br&gt;d.   array.length&lt;br&gt;e.   array[].size()&lt;br&gt;f.   array.size()   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa1q2a1&quot; target=&quot;_top&quot;&gt;4.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Is it possible to create arrays of length zero?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   Yes, you can create arrays of any type with length zero.&lt;br&gt;b.   Yes, but only for primitive data types.&lt;br&gt;c.   Yes, but only for arrays of object references.&lt;br&gt;d.   No, you cannot create zero-length arrays, but the main() method   may be passed a zero-length array of String references when no program   arguments are specified.&lt;br&gt;e.   No, it is not possible to create arrays of length zero in   Java.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa1q3a1&quot; target=&quot;_top&quot;&gt;4.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which one of the following array declaration statements is   not legal?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   int   []a[] = new int [4][4];&lt;br&gt;b.   int   a[][] = new int [4][4];&lt;br&gt;c.   int   a[][] = new int [][4];&lt;br&gt;d.   int   []a[] = new int [4][];&lt;br&gt;e.   int   [][]a = new int [4][4];   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa1q4a1&quot; target=&quot;_top&quot;&gt;4.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of these array declaration statements are not legal?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   int[]   i[] = { { 1, 2 }, { 1 }, {}, { 1, 2, 3 } };&lt;br&gt;b.   int   i[] = new int[2] {1, 2};&lt;br&gt;c.   int   i[][] = new int[][] { {1, 2, 3}, {4, 5, 6} };&lt;br&gt;d.   int   i[][] = { { 1, 2 }, new int[ 2 ] };&lt;br&gt;e.   int   i[4] = { 1, 2, 3, 4 };   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa1q5a1&quot; target=&quot;_top&quot;&gt;4.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What would be the result of attempting to compile and run   the following program?&lt;br&gt;// Filename: MyClass.javaclass MyClass { public static void main(String[] args) { int size = 20; int[] arr = new int[ size ]; for (int i = 0; i &amp;lt; size; ++i) { System.out.println(arr[i]); } }}   Select the one correct answer.&lt;br&gt;a.   The code will fail to compile because the array type int[] is   incorrect.&lt;br&gt;b.   The program will compile, but will throw an ArrayIndexOutOfBoundsException   when run.&lt;br&gt;c.   The program will compile and run without error, but will   produce no output.&lt;br&gt;d.   The program will compile and run without error and will   print the numbers 0 through 19.&lt;br&gt;e.   The program will compile and run without error and will   print 0   twenty times.&lt;br&gt;f.   The program will compile and run without error and will   print null   twenty times.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa1q6a1&quot; target=&quot;_top&quot;&gt;4.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following program, which statement is true?&lt;br&gt;class MyClass { public static void main(String[] args) { String[] numbers = { &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;, &amp;quot;four&amp;quot; }; if (args.length == 0) { System.out.println(&amp;quot;no arguments&amp;quot;); } else { System.out.println(numbers[ args.length ] + &amp;quot; arguments&amp;quot;); } }}   Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will throw a NullPointerException when run with   zero program arguments.&lt;br&gt;c.   The program will print &amp;quot;no arguments&amp;quot; and &amp;quot;two arguments&amp;quot;   when called with zero and three program arguments, respectively.&lt;br&gt;d.   The program will print &amp;quot;no arguments&amp;quot; and &amp;quot;three   arguments&amp;quot; when called with zero and three program   arguments, respectively.&lt;br&gt;e.   The program will print &amp;quot;no arguments&amp;quot; and &amp;quot;four arguments&amp;quot;   when called with zero and three program arguments, respectively.&lt;br&gt;f.   The program will print &amp;quot;one arguments&amp;quot; and &amp;quot;four arguments&amp;quot;   when called with zero and three program arguments, respectively.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa1q7a1&quot; target=&quot;_top&quot;&gt;4.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What would be the result of trying to compile and run the   following program?&lt;br&gt;public class DefaultValuesTest { int[] ia = new int[1]; boolean b; int i; Object o; public static void main(String[] args) { DefaultValuesTest instance = new DefaultValuesTest(); instance.print(); } public void print() { System.out.println(ia[0] + &amp;quot; &amp;quot; + b + &amp;quot; &amp;quot; + i + &amp;quot; &amp;quot; + o); }}   Select the one correct answer.&lt;br&gt;a.   The program will fail to compile because of uninitialized   variables.&lt;br&gt;b.   The program will throw a java.lang.NullPointerException when   run.&lt;br&gt;c.   The program will print &amp;quot;0 false NaN null&amp;quot;.&lt;br&gt;d.   The program will print &amp;quot;0 false 0 null&amp;quot;.&lt;br&gt;e.   The program will print &amp;quot;null 0 0 null&amp;quot;.&lt;br&gt;f.   The program will print &amp;quot;null false 0 null&amp;quot;.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa2q1a1&quot; target=&quot;_top&quot;&gt;4.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   one of these is a valid method declaration?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   void method1 { /* ... */ }&lt;br&gt;b.   void method2() { /* ... */ }&lt;br&gt;c.   void method3(void) { /* ... */ }&lt;br&gt;d.   method4() { /* ... */ }&lt;br&gt;e.   method5(void) { /* ... */ }   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa2q2a1&quot; target=&quot;_top&quot;&gt;4.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   the following code, which statements can be placed at the indicated position   without causing compilation errors?&lt;br&gt;public   class ThisUsage {&lt;br&gt; int planets;&lt;br&gt; static int suns;&lt;br&gt; public void gaze() {&lt;br&gt; int i;&lt;br&gt; // ... insert statements here ...&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   i = this.planets;&lt;br&gt;b.   i = this.suns;&lt;br&gt;c.   this = new ThisUsage();&lt;br&gt;d.   this.i = 4;&lt;br&gt;e.   this.suns = planets;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa2q3a1&quot; target=&quot;_top&quot;&gt;4.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   the following pairs of method declarations, which statements are true?&lt;br&gt;void   fly(int distance) {}&lt;br&gt;int fly(int time, int speed) { return   time*speed; }&lt;br&gt;void   fall(int time) {}&lt;br&gt;int fall(int distance) { return distance; }&lt;br&gt;void   glide(int time) {}&lt;br&gt;void   Glide(int time) {}&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   The first pair of methods will compile correctly and   overload the method name fly.&lt;br&gt;b.   The second pair of methods will compile correctly and   overload the method name fall.&lt;br&gt;c.   The third pair of methods will compile correctly and   overload the method name glide.&lt;br&gt;d.   The second pair of methods will not compile correctly.&lt;br&gt;e.   The third pair of methods will not compile correctly.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa2q4a1&quot; target=&quot;_top&quot;&gt;4.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   a class named Book,   which one of these is a valid constructor declaration for the class?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Book(Book b) {}&lt;br&gt;b.   Book Book() {}&lt;br&gt;c.   private final Book() {}&lt;br&gt;d.   void Book() {}&lt;br&gt;e.   public static void Book(String[]   args) {}&lt;br&gt;f.   abstract Book() {}   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa2q5a1&quot; target=&quot;_top&quot;&gt;4.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   All classes must define a constructor.&lt;br&gt;b.   A constructor can be declared private.&lt;br&gt;c.   A constructor can return a value.&lt;br&gt;d.   A constructor must initialize all the fields of a class.&lt;br&gt;e.   A constructor can access the non-static members of a class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa2q6a1&quot; target=&quot;_top&quot;&gt;4.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   will be the result of attempting to compile the following program?&lt;br&gt;public   class MyClass {&lt;br&gt; long var;&lt;br&gt; public void MyClass(long param) { var = param; } // (1)&lt;br&gt; public static void main(String[] args) {&lt;br&gt; MyClass a, b;&lt;br&gt; a = new MyClass(); // (2)&lt;br&gt; b = new MyClass(5); // (3)&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   A compilation error will occur at (1), since constructors   cannot specify a return value.&lt;br&gt;b.   A compilation error will occur at (2), since the class does   not have a default constructor.&lt;br&gt;c.   A compilation error will occur at (3), since the class does   not have a constructor which takes one argument of type int.&lt;br&gt;d.   The program will compile correctly.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa3q1a1&quot; target=&quot;_top&quot;&gt;4.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following class, which of these are valid ways of   referring to the class from outside of the package net.basemaster?&lt;br&gt;package net.basemaster;&lt;br&gt;&lt;br&gt;public class Base {&lt;br&gt; // ...&lt;br&gt;}&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   By simply referring to the class as Base.&lt;br&gt;b.   By simply referring to the class as basemaster.Base.&lt;br&gt;c.   By simply referring to the class as net.basemaster.Base.&lt;br&gt;d.   By importing with net.basemaster.* and referring to the   class as Base.&lt;br&gt;e.   By importing with net.* and referring to the class as basemaster.Base.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa3q2a1&quot; target=&quot;_top&quot;&gt;4.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which one of the following class definitions is a valid   definition of a class that cannot be instantiated?&lt;br&gt;Select the one correct answer.&lt;br&gt;a. class Ghost {b. abstract void haunt();c. }   &lt;ol start=&quot;4&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;/li&gt;&lt;/ol&gt;   e. abstract class Ghost {f. void haunt();g. }   &lt;ol start=&quot;8&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;/li&gt;&lt;/ol&gt;   i. abstract class Ghost {j. void haunt() {};k. }   &lt;ol start=&quot;12&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;/li&gt;&lt;/ol&gt;   m. abstract Ghost {n. abstract void haunt();o. }   &lt;ol start=&quot;16&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;/li&gt;&lt;/ol&gt;   q. static class Ghost {r. abstract haunt();s. }   &lt;ol start=&quot;20&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa3q3a1&quot; target=&quot;_top&quot;&gt;4.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which one of the following class definitions is a valid   definition of a class that cannot be extended?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   class   Link { }&lt;br&gt;b.   abstract   class Link { }&lt;br&gt;c.   native   class Link { }&lt;br&gt;d.   static   class Link { }&lt;br&gt;e.   final   class Link { }&lt;br&gt;f.   private   class Link { }&lt;br&gt;g.   abstract   final class Link { }   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa4q1a1&quot; target=&quot;_top&quot;&gt;4.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Given the following definition of a class, which fields are accessible from outside the package com.corporation.project?package com.corporation.project;public class MyClass { int i; public int j; protected int k; private int l;}Select the two correct answers.   a.   Field i   is accessible in all classes in other packages.&lt;br&gt;b.   Field j   is accessible in all classes in other packages.&lt;br&gt;c.   Field k   is accessible in all classes in other packages.&lt;br&gt;d.   Field k   is accessible in subclasses only in other packages.&lt;br&gt;e.   Field l   is accessible in all classes in other packages.&lt;br&gt;f.   Field l   is accessible in subclasses only in other packages.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa4q2a1&quot; target=&quot;_top&quot;&gt;4.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;How restrictive is the default accessibility compared to public, protected, and private accessibility?Select the one correct answer.   a.   Less restrictive than public.&lt;br&gt;b.   More restrictive than public, but less restrictive than protected.&lt;br&gt;c.   More restrictive than protected, but less restrictive than private.&lt;br&gt;d.   More restrictive than private.&lt;br&gt;e.   Less restrictive than protected from within a package, and   more restrictive than protected   from outside a package.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa4q3a1&quot; target=&quot;_top&quot;&gt;4.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which statement is true about accessibility of members?Select the one correct answer.   a.   Private members are always accessible from within the same   package.&lt;br&gt;b.   Private members can only be accessed by code from within the   class of the member.&lt;br&gt;c.   A member with default accessibility can be accessed by any   subclass of the class in which it is defined.&lt;br&gt;d.   Private members cannot be accessed at all.&lt;br&gt;e.   Package/default accessibility for a member can be declared   using the keyword default.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q1a1&quot; target=&quot;_top&quot;&gt;4.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true about the use of modifiers?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   If no accessibility modifier (public, protected, and   private)   is specified for a member declaration, the member is only accessible for   classes in the package of its class and subclasses of its class anywhere.&lt;br&gt;b.   You cannot specify accessibility of local variables. They   are only accessible within the block in which they are declared.&lt;br&gt;c.   Subclasses of a class must reside in the same package as the   class they extend.&lt;br&gt;d.   Local variables can be declared static.&lt;br&gt;e.   Objects themselves do not have any accessibility modifiers,   only the object references do.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q2a1&quot; target=&quot;_top&quot;&gt;4.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   the following source code, which comment line can be uncommented without   introducing errors?&lt;br&gt;abstract   class MyClass {&lt;br&gt; abstract void f();&lt;br&gt; final   void g() {}&lt;br&gt;// final   void h() {}   // (1)&lt;br&gt;&lt;br&gt; protected static int i;&lt;br&gt; private int j;&lt;br&gt;}&lt;br&gt;&lt;br&gt;final   class MyOtherClass extends MyClass {&lt;br&gt;// MyOtherClass(int n) { m = n; } // (2)&lt;br&gt;&lt;br&gt; public static void main(String[] args) {&lt;br&gt; MyClass mc = new MyOtherClass();&lt;br&gt; }&lt;br&gt;&lt;br&gt; void f() {}&lt;br&gt; void h() {}&lt;br&gt;// void k() { i++; } // (3)&lt;br&gt;// void l() { j++; } // (4)&lt;br&gt;&lt;br&gt; int m;&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a. final void h() {} // (1)b. MyOtherClass(int n) { m = n; } // (2)c. void k() { i++; } // (3)d. void l() { j++; } // (4)      &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q3a1&quot; target=&quot;_top&quot;&gt;4.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   would be the result of attempting to compile and run the following program?&lt;br&gt;class   MyClass {&lt;br&gt; static MyClass ref;&lt;br&gt; String[] arguments;&lt;br&gt;&lt;br&gt; public static void main(String[] args) {&lt;br&gt; ref = new MyClass();&lt;br&gt; ref.func(args);&lt;br&gt; }&lt;br&gt;&lt;br&gt; public void func(String[] args) {&lt;br&gt; ref.arguments = args;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   The program will fail to compile, since the static method main() cannot   have a call to the non-static method func().&lt;br&gt;b.   The program will fail to compile, since the non-static   method func()   cannot access the static variable ref.&lt;br&gt;c.   The program will fail to compile, since the argument args passed to   the static method main()   cannot be passed on to the non-static method func().&lt;br&gt;d.   The program will fail to compile, since the method func() cannot   assign the value of the static variable ref to the non-static variable arguments.&lt;br&gt;e.   The program will compile, but will throw an exception when   run.&lt;br&gt;f.   The program will compile and run successfully.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q4a1&quot; target=&quot;_top&quot;&gt;4.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   the following member declarations, which statement is true?&lt;br&gt;int   a; // (1)&lt;br&gt;static   int a; // (2)&lt;br&gt;int   f() { return a; } // (3)&lt;br&gt;static   int f() { return a; } // (4)&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Declarations (1) and (3) cannot occur in the same class   definition.&lt;br&gt;b.   Declarations (2) and (4) cannot occur in the same class   definition.&lt;br&gt;c.   Declarations (1) and (4) cannot occur in the same class   definition.&lt;br&gt;d.   Declarations (2) and (3) cannot occur in the same class   definition.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q5a1&quot; target=&quot;_top&quot;&gt;4.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statement is true?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   A static method can call other non-static methods in the same   class by using the this   keyword.&lt;br&gt;b.   A class may contain both static and non-static variables and   both static and non-static methods.&lt;br&gt;c.   Each object of a class has its own instance of each static   variable.&lt;br&gt;d.   Instance methods may access local variables of static   methods.&lt;br&gt;e.   All methods in a class are implicitly passed a this parameter   when called.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q6a1&quot; target=&quot;_top&quot;&gt;4.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What,   if anything, is wrong with the following code?&lt;br&gt;abstract   class MyClass {&lt;br&gt; transient int j;&lt;br&gt; synchronized int k;&lt;br&gt;&lt;br&gt; final void MyClass() {}&lt;br&gt;&lt;br&gt; static void f() {}&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   The class MyClass cannot be declared abstract.&lt;br&gt;b.   The field j cannot be declared transient.&lt;br&gt;c.   The field k cannot be declared synchronized.&lt;br&gt;d.   The method MyClass() cannot be declared final.&lt;br&gt;e.   The method f() cannot be declared static.&lt;br&gt;f.   Nothing is wrong with the code; it will compile without   errors.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q7a1&quot; target=&quot;_top&quot;&gt;4.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   one of these is not a legal member declaration within a class?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   static   int a;&lt;br&gt;b.   final   Object[] fudge = { null };&lt;br&gt;c.   abstract   int t;&lt;br&gt;d.   native   void sneeze();&lt;br&gt;e.   final   static private double PI = 3.14159265358979323846;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q8a1&quot; target=&quot;_top&quot;&gt;4.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true about modifiers?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   Abstract classes can contain final methods.&lt;br&gt;b.   Fields can be declared native.&lt;br&gt;c.   Non-abstract   methods can be declared in abstract classes.&lt;br&gt;d.   Classes can be declared native.&lt;br&gt;e.   Abstract classes can be declared final.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec4.html#ch04qa5q9a1&quot; target=&quot;_top&quot;&gt;4.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statement is true?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Transient fields will not be saved during serialization.&lt;br&gt;b.   Constructors can be declared abstract.&lt;br&gt;c.   The initial state of an array object constructed with the   statement int[]   a = new int[10] will depend on whether the array variable a is a local   variable or a field.&lt;br&gt;d.   A subclass of a class with an abstract method must provide an   implementation for the abstract   method.&lt;br&gt;e.   Only static methods can access static members.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;br&gt;&lt;b&gt;&lt;u&gt;Control Flow, Exception Handling, and Assertions&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa1q1a1&quot; target=&quot;_top&quot;&gt;5.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What will be the result of attempting to compile and run the   following class?&lt;br&gt;public class IfTest { public static void main(String[] args) { if (true) if (false) System.out.println(&amp;quot;a&amp;quot;); else System.out.println(&amp;quot;b&amp;quot;); }}   Select the one correct answer.&lt;br&gt;a.   The code will fail to compile because the syntax of the if statement   is incorrect.&lt;br&gt;b.   The code will fail to compile because the compiler will not   be able to determine which if statement the else clause belongs to.&lt;br&gt;c.   The code will compile correctly and display the letter a when run.&lt;br&gt;d.   The code will compile correctly and display the letter b when run.&lt;br&gt;e.   The code will compile correctly, but will not display any   output.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa1q2a1&quot; target=&quot;_top&quot;&gt;5.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which statements are true?&lt;br&gt;Select the three correct answers.&lt;br&gt;a.   The conditional expression in an if statement can have method   calls.&lt;br&gt;b.   If a   and b   are of type boolean,   the expression (a   = b) can be the conditional expression of an if statement.&lt;br&gt;c.   An if   statement can have either an if clause or an else clause.&lt;br&gt;d.   The statement if (false) ; else ; is illegal.&lt;br&gt;e.   Only expressions which evaluate to a boolean value   can be used as the condition in an if statement.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa1q3a1&quot; target=&quot;_top&quot;&gt;5.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What, if anything, is wrong with the following code?&lt;br&gt;void test(int x) { switch (x) { case 1: case 2: case 0: default: case 4: }}   Select the one correct answer.&lt;br&gt;a.   The variable x does not have the right type for a switch   expression.&lt;br&gt;b.   The case   label 0   must precede case   label 1.&lt;br&gt;c.   Each case   section must end with a break   statement.&lt;br&gt;d.   The default   label must be the last label in the switch statement.&lt;br&gt;e.   The body of the switch statement must contain at least   one statement.&lt;br&gt;f.   There is nothing wrong with the code.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa1q4a1&quot; target=&quot;_top&quot;&gt;5.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which of these combinations of switch expression types and case label   value types are legal within a switch statement?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   switch   expression of type int   and case   label value of type char.&lt;br&gt;b.   switch   expression of type float   and case   label value of type int.&lt;br&gt;c.   switch   expression of type byte   and case   label value of type float.&lt;br&gt;d.   switch   expression of type char   and case   label value of type long.&lt;br&gt;e.   switch   expression of type boolean   and case   value of type boolean.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q1a1&quot; target=&quot;_top&quot;&gt;5.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What will be the result of attempting to compile and run the   following code?&lt;br&gt;class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; boolean b =   false;&lt;br&gt; int i = 1;&lt;br&gt; do {&lt;br&gt; i++;&lt;br&gt; b = ! b;&lt;br&gt; } while (b);&lt;br&gt;   System.out.println(i);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile, since b is an   invalid conditional expression for the do-while statement.&lt;br&gt;b.   The code will fail to compile, since the assignment b = ! b is not   allowed.&lt;br&gt;c.   The code will compile without error and will print 1 when run.&lt;br&gt;d.   The code will compile without error and will print 2 when run.&lt;br&gt;e.   The code will compile without error and will print 3 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q2a1&quot; target=&quot;_top&quot;&gt;5.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What will be the output when running the following program?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; int i=0;&lt;br&gt; int j;&lt;br&gt; for (j=0;   j&amp;lt;10; ++j) { i++; }&lt;br&gt;   System.out.println(i + &amp;quot; &amp;quot; + j);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   The first number printed will be 9.&lt;br&gt;b.   The first number printed will be 10.&lt;br&gt;c.   The first number printed will be 11.&lt;br&gt;d.   The second number printed will be 9.&lt;br&gt;e.   The second number printed will be 10.&lt;br&gt;f.   The second number printed will be 11.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q3a1&quot; target=&quot;_top&quot;&gt;5.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which one of these for statements is valid?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   int   j=10; for (int i=0, j+=90; i&amp;lt;j; i++) { j--; }&lt;br&gt;b.   for   (int i=10; i=0; i--) {}&lt;br&gt;c.   for   (int i=0, j=100; i&amp;lt;j; i++, --j) {;}&lt;br&gt;d.   int   i, j; for (j=100; i&amp;lt;j; j--) { i += 2; }&lt;br&gt;e.   int   i=100; for ((i&amp;gt;0); i--) {}   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q4a1&quot; target=&quot;_top&quot;&gt;5.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; int i = 0;&lt;br&gt; for ( ; i&amp;lt;10; i++) ; // (1)&lt;br&gt; for   (i=0; ; i++) break; // (2)&lt;br&gt; for (i=0;   i&amp;lt;10; ) i++; // (3)&lt;br&gt; for ( ;   ; ) ; // (4)&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile, since the for statement   (1) is missing the expression in the first section.&lt;br&gt;b.   The code will fail to compile, since the for statement   (2) is missing the expression in the middle section.&lt;br&gt;c.   The code will fail to compile, since the for statement   (3) is missing the expression in the last section.&lt;br&gt;d.   The code will fail to compile, since the for statement   (4) is invalid.&lt;br&gt;e.   The code will compile without error, and the program will   run and terminate without any output.&lt;br&gt;f.   The code will compile without error, but will never   terminate when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q5a1&quot; target=&quot;_top&quot;&gt;5.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which statements are valid when occurring on their own?&amp;gt;&lt;br&gt;Select the three correct answers.&lt;br&gt;a.   while   () break;&lt;br&gt;b.   do   { break; } while (true);&lt;br&gt;c.   if   (true) { break; }&lt;br&gt;d.   switch   (1) { default: break; }&lt;br&gt;e.   for   (;true;) break;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q6a1&quot; target=&quot;_top&quot;&gt;5.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Given the following code fragment, which of the following   lines will be a part of the output?&lt;br&gt;outer:&lt;br&gt;for (int i = 0; i &amp;lt; 3; i++) {&lt;br&gt; for (int j = 0; j   &amp;lt; 2; j++) {&lt;br&gt; if (i == j) {&lt;br&gt; continue outer;&lt;br&gt; }&lt;br&gt;   System.out.println(&amp;quot;i=&amp;quot; + i + &amp;quot;, j=&amp;quot; + j);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   i=1,   j=0&lt;br&gt;b.   i=0,   j=1&lt;br&gt;c.   i=1,   j=2&lt;br&gt;d.   i=2,   j=1&lt;br&gt;e.   i=2,   j=2&lt;br&gt;f.   i=3,   j=3&lt;br&gt;g.   i=3,   j=2   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q7a1&quot; target=&quot;_top&quot;&gt;5.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What will be the result of attempting to compile and run the   following code?&lt;br&gt;class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; for (int i =   0; i&amp;lt;10; i++) {&lt;br&gt; switch(i)   {&lt;br&gt; case   0:&lt;br&gt;   System.out.println(i);&lt;br&gt; }&lt;br&gt; if (i) {&lt;br&gt;   System.out.println(i);&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile, owing to an illegal switch   expression in the switch   statement.&lt;br&gt;b.   The code will fail to compile, owing to an illegal   conditional expression in the if statement.&lt;br&gt;c.   The code will compile without error and will print the   numbers 0   through 10   when run.&lt;br&gt;d.   The code will compile without error and will print the   number 0   when run.&lt;br&gt;e.   The code will compile without error and will print the   number 0   twice when run.&lt;br&gt;f.   The code will compile without error and will print the   numbers 1   through 10   when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q8a1&quot; target=&quot;_top&quot;&gt;5.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which of the following implementations of a max() method   will correctly return the largest value?&lt;br&gt;// (1)&lt;br&gt;int max(int x, int y) {&lt;br&gt; return (if (x   &amp;gt; y) { x; } else { y; });&lt;br&gt;}&lt;br&gt;// (2)&lt;br&gt;int max(int x, int y) {&lt;br&gt; return (if (x   &amp;gt; y) { return x; } else { return y; });&lt;br&gt;}&lt;br&gt;// (3)&lt;br&gt;int max(int x, int y) {&lt;br&gt; switch (x &amp;lt; y)   {&lt;br&gt; case true:&lt;br&gt; return y;&lt;br&gt; default:&lt;br&gt; return x;&lt;br&gt; };&lt;br&gt;}&lt;br&gt;// (4)&lt;br&gt;int max(int x, int y) {&lt;br&gt; if (x&amp;gt;y)   return x;&lt;br&gt; return y;&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   Implementation labeled (1).&lt;br&gt;b.   Implementation labeled (2).&lt;br&gt;c.   Implementation labeled (3).&lt;br&gt;d.   Implementation labeled (4).   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q9a1&quot; target=&quot;_top&quot;&gt;5.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Given the following code, which statement is true?&lt;br&gt;class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; int k=0;&lt;br&gt; int l=0;&lt;br&gt; for (int i=0;   i &amp;lt;= 3; i++) {&lt;br&gt; k++;&lt;br&gt; if (i ==   2) break;&lt;br&gt; l++;&lt;br&gt; }&lt;br&gt;   System.out.println(k + &amp;quot;, &amp;quot; + l);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will print 3, 3 when run.&lt;br&gt;c.   The program will print 4, 3 when run if break is   replaced by continue.&lt;br&gt;d.   The program will fail to compile if break is   replaced by return.&lt;br&gt;e.   The program will fail to compile if break is   simply removed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa2q10a1&quot; target=&quot;_top&quot;&gt;5.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which statements are true?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   {{}}   is a valid statement block.&lt;br&gt;b.   {   continue; } is a valid statement block.&lt;br&gt;c.   block:   { break block; } is a valid statement block.&lt;br&gt;d.   block:   { continue block; } is a valid statement block.&lt;br&gt;e.   The break   statement can only be used in a loop (while, do-while or for) or a switch   statement.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q1a1&quot; target=&quot;_top&quot;&gt;5.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which digits, and in which order, will be printed when the   following program is run?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; int k=0;&lt;br&gt; try {&lt;br&gt; int i =   5/k;&lt;br&gt; } catch   (ArithmeticException e) {&lt;br&gt;   System.out.println(&amp;quot;1&amp;quot;);&lt;br&gt; } catch (RuntimeException   e) {&lt;br&gt;   System.out.println(&amp;quot;2&amp;quot;);&lt;br&gt; return;&lt;br&gt; } catch   (Exception e) {&lt;br&gt;   System.out.println(&amp;quot;3&amp;quot;);&lt;br&gt; } finally {&lt;br&gt;   System.out.println(&amp;quot;4&amp;quot;);&lt;br&gt; }&lt;br&gt;   System.out.println(&amp;quot;5&amp;quot;);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The program will only print 5.&lt;br&gt;b.   The program will only print 1 and 4, in that order.&lt;br&gt;c.   The program will only print 1, 2, and 4, in that order.&lt;br&gt;d.   The program will only print 1, 4, and 5, in that order.&lt;br&gt;e.   The program will only print 1, 2, 4, and 5, in that order.&lt;br&gt;f.   The program will only print 3 and 5, in that order.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q2a1&quot; target=&quot;_top&quot;&gt;5.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Given the following program, which statements are true?&lt;br&gt;public class Exceptions {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; try {&lt;br&gt; if   (args.length == 0) return;&lt;br&gt;   System.out.println(args[0]);&lt;br&gt; } finally {&lt;br&gt;   System.out.println(&amp;quot;The end&amp;quot;);&lt;br&gt; }&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   If run with no arguments, the program will produce no   output.&lt;br&gt;b.   If run with no arguments, the program will print &amp;quot;The end&amp;quot;.&lt;br&gt;c.   The program will throw an ArrayIndexOutOfBoundsException.&lt;br&gt;d.   If run with one argument, the program will simply print the   given argument.&lt;br&gt;e.   If run with one argument, the program will print the given   argument followed by &amp;quot;The   end&amp;quot;.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q3a1&quot; target=&quot;_top&quot;&gt;5.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt;   RuntimeException re = null;&lt;br&gt; throw re;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile, since the main() method   does not declare that it throws RuntimeException in its declaration.&lt;br&gt;b.   The program will fail to compile, since it cannot throw re.&lt;br&gt;c.   The program will compile without error and will throw java.lang.RuntimeException   when run.&lt;br&gt;d.   The program will compile without error and will throw java.lang.NullpointerException   when run.&lt;br&gt;e.   The program will compile without error and will run and   terminate without any output.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q4a1&quot; target=&quot;_top&quot;&gt;5.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which statements are true?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   If an exception is uncaught in a method, the method will   terminate and normal execution will resume.&lt;br&gt;b.   An overriding method must declare that it throws the same   exception classes as the method it overrides.&lt;br&gt;c.   The main()   method of a program can declare that it throws checked exceptions.&lt;br&gt;d.   A method declaring that it throws a certain exception class   may throw instances of any subclass of that exception class.&lt;br&gt;e.   finally   blocks are executed if, and only if, an exception gets thrown while inside   the corresponding try   block.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q5a1&quot; target=&quot;_top&quot;&gt;5.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which digits, and in which order, will be printed when the   following program is compiled and run?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; try {&lt;br&gt; f();&lt;br&gt; } catch   (InterruptedException e) {&lt;br&gt;   System.out.println(&amp;quot;1&amp;quot;);&lt;br&gt; throw new   RuntimeException();&lt;br&gt; } catch   (RuntimeException e) {&lt;br&gt;   System.out.println(&amp;quot;2&amp;quot;);&lt;br&gt; return;&lt;br&gt; } catch   (Exception e) {&lt;br&gt;   System.out.println(&amp;quot;3&amp;quot;);&lt;br&gt; } finally {&lt;br&gt;   System.out.println(&amp;quot;4&amp;quot;);&lt;br&gt; }&lt;br&gt;   System.out.println(&amp;quot;5&amp;quot;);&lt;br&gt; }&lt;br&gt; //   InterruptedException is a direct subclass of Exception.&lt;br&gt; static void f()   throws InterruptedException {&lt;br&gt; throw new   InterruptedException(&amp;quot;Time for lunch.&amp;quot;);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The program will print 5.&lt;br&gt;b.   The program will print 1 and 4, in that order.&lt;br&gt;c.   The program will print 1, 2, and 4, in that order.&lt;br&gt;d.   The program will print 1, 4, and 5, in that order.&lt;br&gt;e.   The program will print 1, 2, 4, and 5, in that order.&lt;br&gt;f.   The program will print 3 and 5, in that order.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q6a1&quot; target=&quot;_top&quot;&gt;5.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which digits, and in which order, will be printed when the   following program is run?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) throws InterruptedException {&lt;br&gt; try {&lt;br&gt; f();&lt;br&gt;   System.out.println(&amp;quot;1&amp;quot;);&lt;br&gt; } finally {&lt;br&gt;   System.out.println(&amp;quot;2&amp;quot;);&lt;br&gt; }&lt;br&gt;   System.out.println(&amp;quot;3&amp;quot;);&lt;br&gt; }&lt;br&gt; // InterruptedException   is a direct subclass of Exception.&lt;br&gt; static void f()   throws InterruptedException {&lt;br&gt; throw new   InterruptedException(&amp;quot;Time to go home.&amp;quot;);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The program will print 2 and throw InterruptedException.&lt;br&gt;b.   The program will print 1 and 2, in that order.&lt;br&gt;c.   The program will print 1, 2, and 3, in that order.&lt;br&gt;d.   The program will print 2 and 3, in that order.&lt;br&gt;e.   The program will print 3 and 2, in that order.&lt;br&gt;f.   The program will print 1 and 3, in that order.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q7a1&quot; target=&quot;_top&quot;&gt;5.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What is wrong with the following code?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) throws A {&lt;br&gt; try {&lt;br&gt; f();&lt;br&gt; } finally {&lt;br&gt;   System.out.println(&amp;quot;Done.&amp;quot;);&lt;br&gt; } catch (A e)   {&lt;br&gt; throw e;&lt;br&gt; }&lt;br&gt; }&lt;br&gt;&lt;br&gt; public static   void f() throws B {&lt;br&gt; throw new B();&lt;br&gt; }&lt;br&gt;}&lt;br&gt;class A extends Throwable {}&lt;br&gt;&lt;br&gt;class B extends A {}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The main()   method must declare that it throws B.&lt;br&gt;b.   The finally   block must follow the catch   block in the main()   method.&lt;br&gt;c.   The catch   block in the main()   method must declare that it catches B rather than A.&lt;br&gt;d.   A single try   block cannot be followed by both a finally and a catch block.&lt;br&gt;e.   The declaration of class A is illegal.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q8a1&quot; target=&quot;_top&quot;&gt;5.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What is the minimal list of exception classes that the   overriding method f()   in the following code must declare in its throws clause before the code will   compile correctly?&lt;br&gt;class A {&lt;br&gt; //   InterruptedException is a direct subclass of Exception.&lt;br&gt; void f() throws   ArithmeticException, InterruptedException {&lt;br&gt; div(5, 5);&lt;br&gt; }&lt;br&gt; int div(int i,   int j) throws ArithmeticException {&lt;br&gt; return i/j;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;public class MyClass extends A {&lt;br&gt; void f() /*   throws [...list of exceptions...] */ {&lt;br&gt; try {&lt;br&gt; div(5,   0);&lt;br&gt; } catch   (ArithmeticException e) {&lt;br&gt; return;&lt;br&gt; }&lt;br&gt; throw new   RuntimeException(&amp;quot;ArithmeticException was expected.&amp;quot;);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   Does not need to specify any exceptions.&lt;br&gt;b.   Needs to specify that it throws ArithmeticException.&lt;br&gt;c.   Needs to specify that it throws InterruptedException.&lt;br&gt;d.   Needs to specify that it throws RuntimeException.&lt;br&gt;e.   Needs to specify that it throws both ArithmeticException   and InterruptedException.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa3q9a1&quot; target=&quot;_top&quot;&gt;5.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What, if anything, would cause the following code not to   compile?&lt;br&gt;class A {&lt;br&gt; void f() throws   ArithmeticException {&lt;br&gt; //...&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;public class MyClass extends A {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; A obj = new   MyClass();&lt;br&gt;&lt;br&gt; try {&lt;br&gt; obj.f();&lt;br&gt; } catch   (ArithmeticException e) {&lt;br&gt; return;&lt;br&gt; } catch   (Exception e) {&lt;br&gt;   System.out.println(e);&lt;br&gt; throw new   RuntimeException(&amp;quot;Something wrong here&amp;quot;);&lt;br&gt; }&lt;br&gt; }&lt;br&gt; //   InterruptedException is a direct subclass of Exception.&lt;br&gt; void f() throws   InterruptedException {&lt;br&gt; //...&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The main()   method must declare that it throws RuntimeException.&lt;br&gt;b.   The overriding f() method in MyClass must declare that it throws ArithmeticException,   since the f()   method in class A   declares that it does.&lt;br&gt;c.   The overriding f() method in MyClass is not allowed to throw InterruptedException,   since the f()   method in class A   does not throw this exception.&lt;br&gt;d.   The compiler will complain that the catch(ArithmeticException)   block shadows the catch(Exception)   block.&lt;br&gt;e.   You cannot throw exceptions from a catch block.&lt;br&gt;f.   Nothing is wrong with the code, it will compile without   errors.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q1a1&quot; target=&quot;_top&quot;&gt;5.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Assuming   assertions are enabled, which of these assertion statements will throw an   error?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   assert true : true;&lt;br&gt;b.   assert true : false;&lt;br&gt;c.   assert false : true;&lt;br&gt;d.   assert false : false;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q2a1&quot; target=&quot;_top&quot;&gt;5.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which   of the following are valid runtime options?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   -ae&lt;br&gt;b.   -enableassertions&lt;br&gt;c.   -source 1.4&lt;br&gt;d.   -disablesystemassertions&lt;br&gt;e.   -dea   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q3a1&quot; target=&quot;_top&quot;&gt;5.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What   is the class name of the exception thrown by an assertion statement?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Depends on the assertion statement.&lt;br&gt;b.   FailedAssertion&lt;br&gt;c.   AssertionException&lt;br&gt;d.   RuntimeException&lt;br&gt;e.   AssertionError&lt;br&gt;f.   Error   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q4a1&quot; target=&quot;_top&quot;&gt;5.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What   can cause an assertion statement to be ignored?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Nothing.&lt;br&gt;b.   Using appropriate compiler options.&lt;br&gt;c.   Using appropriate runtime options.&lt;br&gt;d.   Using both appropriate compiler and runtime options.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q5a1&quot; target=&quot;_top&quot;&gt;5.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Given   the following method, which statements will throw an exception, assuming   assertions are enabled?&lt;br&gt;static   int inv(int value) {&lt;br&gt; assert value &amp;gt; -50 : value &amp;lt; 100;&lt;br&gt; return 100/value;&lt;br&gt;}&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   inv(-50);&lt;br&gt;b.   inv(0);&lt;br&gt;c.   inv(50);&lt;br&gt;d.   inv(100);&lt;br&gt;e.   inv(150);   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q6a1&quot; target=&quot;_top&quot;&gt;5.29&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which   runtime options would cause assertions to be enabled for the class org.example.ttp.Bottle?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   -ea&lt;br&gt;b.   -ea:Bottle&lt;br&gt;c.   -ea:org.example&lt;br&gt;d.   -ea:org...&lt;br&gt;e.   -enableexceptions:org.example.ttp.Bottle&lt;br&gt;f.   -ea:org.example.ttp   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q7a1&quot; target=&quot;_top&quot;&gt;5.30&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   What   will be the result of compiling and running the following code with   assertions enabled?&lt;br&gt;public   class TernaryAssertion {&lt;br&gt; public static void assertBounds(int low,   int high, int value) {&lt;br&gt; assert ( value &amp;gt; low ? value &amp;lt;   high : false )&lt;br&gt; : (value &amp;lt; high ? &amp;quot;too   low&amp;quot; : &amp;quot;too high&amp;quot; );&lt;br&gt; }&lt;br&gt; public static void main(String[] args) {&lt;br&gt; assertBounds(100, 200, 150);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   The compilation fails because the method name assertBounds cannot begin with the keyword assert.&lt;br&gt;b.   The compilation fails because the assert statement is invalid.&lt;br&gt;c.   The compilation succeeds and the program runs without   errors.&lt;br&gt;d.   The compilation succeeds and an AssertionError   with the error message &amp;quot;too low&amp;quot; is   thrown.&lt;br&gt;e.   The compilation succeeds and an AssertionError   with the error message &amp;quot;too high&amp;quot; is   thrown.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q8a1&quot; target=&quot;_top&quot;&gt;5.31&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which   statements are true about the AssertionError class?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   It is a checked exception.&lt;br&gt;b.   It has a method named toString().&lt;br&gt;c.   It has a method named getErrorMessage().&lt;br&gt;d.   It can be caught by a try-catch construct.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q9a1&quot; target=&quot;_top&quot;&gt;5.32&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Which   of these classes is the direct superclass of AssertionError?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Object&lt;br&gt;b.   Throwable&lt;br&gt;c.   Exception&lt;br&gt;d.   Error&lt;br&gt;e.   RuntimeError   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td width=&quot;50%&quot;&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec5.html#ch05qa4q10a1&quot; target=&quot;_top&quot;&gt;5.33&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td width=&quot;50%&quot;&gt;   Given   the following command, which classes would have assertions enabled?&lt;br&gt;java   -ea -da:com... net.example.LaunchTranslator&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   com.example.Translator&lt;br&gt;b.   java.lang.String&lt;br&gt;c.   dot.com.Boom&lt;br&gt;d.   net.example.LaunchTranslator&lt;br&gt;e.   java.lang.AssertionError   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Object-oriented Programming&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa1q1a1&quot; target=&quot;_top&quot;&gt;6.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statements are true?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   In Java the extends clause is used to specify inheritance.&lt;br&gt;b.   The subclass of a non-abstract class can be declared abstract.&lt;br&gt;c.   All the members of the superclass are inherited by the   subclass.&lt;br&gt;d.   A final   class can be abstract.&lt;br&gt;e.   A class in which all the members are declared private,   cannot be declared public.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa1q2a1&quot; target=&quot;_top&quot;&gt;6.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statements are true?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   Inheritance defines a has-a   relationship between a superclass and its subclasses.&lt;br&gt;b.   Every Java object has a public method named equals.&lt;br&gt;c.   Every Java object has a public method named length.&lt;br&gt;d.   A class can extend any number of other classes.&lt;br&gt;e.   A non-final   class can be extended by any number of classes.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa2q1a1&quot; target=&quot;_top&quot;&gt;6.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   A subclass must define all the methods from the superclass.&lt;br&gt;b.   It is possible for a subclass to define a method with the   same name and parameters as a method defined by the superclass.&lt;br&gt;c.   It is possible for a subclass to define a field with the   same name as a field defined by the superclass.&lt;br&gt;d.   It is possible for two classes to be the superclass of each   other.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa2q2a1&quot; target=&quot;_top&quot;&gt;6.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   the following classes and declarations, which statements are true?&lt;br&gt;// Classes&lt;br&gt;class Foo {&lt;br&gt; private int i;&lt;br&gt; public void f()   { /* ... */ }&lt;br&gt; public void g()   { /* ... */ }&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Bar extends Foo {&lt;br&gt; public int j;&lt;br&gt; public void g()   { /* ... */ }&lt;br&gt;}&lt;br&gt;&lt;br&gt;// Declarations:&lt;br&gt;// ...&lt;br&gt; Foo a = new   Foo();&lt;br&gt; Bar b = new   Bar();&lt;br&gt;// ...&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   The Bar class is a legal   subclass of Foo.&lt;br&gt;b.   The statement b.f();   is legal.&lt;br&gt;c.   The statement a.j = 5;   is legal.&lt;br&gt;d.   The statement a.g();   is legal.&lt;br&gt;e.   The statement b.i = 3;   is legal.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa2q3a1&quot; target=&quot;_top&quot;&gt;6.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statement is true?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Private methods cannot be overridden in subclasses.&lt;br&gt;b.   A subclass can override any method in a superclass.&lt;br&gt;c.   An overriding method can declare that it throws more   exceptions than the method it is overriding.&lt;br&gt;d.   The parameter list of an overriding method must be a subset   of the parameter list of the method that it is overriding.&lt;br&gt;e.   The overriding method can have a different return type than   the overridden method.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa2q4a1&quot; target=&quot;_top&quot;&gt;6.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   classes A,   B,   and C,   where B   extends A,   and C   extends B,   and where all classes implement the instance method void doIt().   How can the doIt()   method in A   be called from an instance method in C?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   doIt();&lt;br&gt;b.   super.doIt();&lt;br&gt;c.   super.super.doIt();&lt;br&gt;d.   this.super.doIt();&lt;br&gt;e.   A.this.doIt();&lt;br&gt;f.   ((A) this).doIt();&lt;br&gt;g.   It is not possible.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa2q5a1&quot; target=&quot;_top&quot;&gt;6.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   would be the result of attempting to compile and run the following code?&lt;br&gt;// Filename: MyClass.java&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; C c = new   C();&lt;br&gt;   System.out.println(c.max(13, 29));&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;class A {&lt;br&gt; int max(int x,   int y) { if (x&amp;gt;y) return x; else return y; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;class B extends A{&lt;br&gt; int max(int x,   int y) { return super.max(y, x) - 10; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;class C extends B {&lt;br&gt; int max(int x,   int y) { return super.max(x+10, y+10); }&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   The code will fail to compile because the max() method in B   passes the arguments in the call super.max(y, x)   in the wrong order.&lt;br&gt;b.   The code will fail to compile because a call to a max() method is ambiguous.&lt;br&gt;c.   The code will compile without errors and will print 13 when run.&lt;br&gt;d.   The code will compile without errors and will print 23 when run.&lt;br&gt;e.   The code will compile without errors and will print 29 when run.&lt;br&gt;f.   The code will compile without errors and will print 39 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa2q6a1&quot; target=&quot;_top&quot;&gt;6.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   the following code, which is the simplest print statement that can be   inserted into the print()   method?&lt;br&gt;// Filename: MyClass.java&lt;br&gt;public class MyClass extends MySuperclass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; MyClass   object = new MyClass();&lt;br&gt;   object.print();&lt;br&gt; }&lt;br&gt; public void   print() {&lt;br&gt; // INSERT   CODE HERE THAT WILL PRINT&lt;br&gt; // THE   &amp;quot;Hello, world!&amp;quot; STRING FROM THE Message&lt;br&gt; // CLASS.&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;class MySuperclass {&lt;br&gt; Message msg =   new Message();&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Message {&lt;br&gt; // The message   that should be printed:&lt;br&gt; String text =   &amp;quot;Hello, world!&amp;quot;;&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   System.out.println(text);&lt;br&gt;b.   System.out.println(Message.text);&lt;br&gt;c.   System.out.println(msg.text);&lt;br&gt;d.   System.out.println(object.msg.text);&lt;br&gt;e.   System.out.println(super.msg.text);&lt;br&gt;f.   System.out.println(object.super.msg.text);   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa3q1a1&quot; target=&quot;_top&quot;&gt;6.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following code, which of these constructors can be   added to MySubclass   without causing a compile-time error?&lt;br&gt;class MySuper {&lt;br&gt; int number;&lt;br&gt; MySuper(int i) {   number = i; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;class MySub extends MySuper {&lt;br&gt; int count;&lt;br&gt; MySub(int cnt,   int num) {&lt;br&gt; super(num);&lt;br&gt; count=cnt;&lt;br&gt; }&lt;br&gt; // INSERT   ADDITIONAL CONSTRUCTOR HERE&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   MySub()   {}&lt;br&gt;b.   MySub(int   cnt) { count = cnt; }&lt;br&gt;c.   MySub(int   cnt) { super(); count = cnt; }&lt;br&gt;d.   MySub(int   cnt) { count = cnt; super(cnt); }&lt;br&gt;e.   MySub(int   cnt) { this(cnt, cnt); }&lt;br&gt;f.   MySub(int   cnt) { super(cnt); this(cnt, 0); }   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa3q2a1&quot; target=&quot;_top&quot;&gt;6.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   A super()   or this()   call must always be provided explicitly as the first statement in the body of   a constructor.&lt;br&gt;b.   If both a subclass and its superclass do not have any   declared constructors, the implicit default constructor of the subclass will   call super()   when run.&lt;br&gt;c.   If neither super() nor this() is declared as the first   statement in the body of a constructor, then this() will implicitly be inserted as   the first statement.&lt;br&gt;d.   If super()   is the first statement in the body of a constructor, then this() can be   declared as the second statement.&lt;br&gt;e.   Calling super()   as the first statement in the body of a constructor of a subclass will always   work, since all superclasses have a default constructor.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa3q3a1&quot; target=&quot;_top&quot;&gt;6.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will the following program print when run?&lt;br&gt;// Filename: MyClass.java&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; B b = new   B(&amp;quot;Test&amp;quot;);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;class A {&lt;br&gt; A() {   this(&amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;); }&lt;br&gt;&lt;br&gt; A(String s,   String t) { this(s + t); }&lt;br&gt;&lt;br&gt; A(String s) {   System.out.println(s); }&lt;br&gt;}&lt;br&gt;class B extends A {&lt;br&gt; B(String s) {   System.out.println(s); }&lt;br&gt;&lt;br&gt; B(String s,   String t) { this(t + s + &amp;quot;3&amp;quot;); }&lt;br&gt;&lt;br&gt; B() {   super(&amp;quot;4&amp;quot;); };&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   It will simply print Test.&lt;br&gt;b.   It will print Test followed by Test.&lt;br&gt;c.   It will print 123 followed by Test.&lt;br&gt;d.   It will print 12 followed by Test.&lt;br&gt;e.   It will print 4 followed by Test.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa4q1a1&quot; target=&quot;_top&quot;&gt;6.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true about interfaces?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   Interfaces allow multiple implementation inheritance.&lt;br&gt;b.   Interfaces can be extended by any number of other   interfaces.&lt;br&gt;c.   Interfaces can extend any number of other interfaces.&lt;br&gt;d.   Members of an interface are never static.&lt;br&gt;e.   Members of an interface can always be declared static.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa4q2a1&quot; target=&quot;_top&quot;&gt;6.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of these field declarations are legal within the body of an interface?&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   public static int answer = 42;&lt;br&gt;b.   int answer;&lt;br&gt;c.   final static int answer = 42;&lt;br&gt;d.   public int answer = 42;&lt;br&gt;e.   private final static int answer = 42;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa4q3a1&quot; target=&quot;_top&quot;&gt;6.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true about interfaces?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   The keyword extends   is used to specify that an interface inherits from another interface.&lt;br&gt;b.   The keyword extends   is used to specify that a class inherits from an interface.&lt;br&gt;c.   The keyword implements   is used to specify that an interface inherits from another interface.&lt;br&gt;d.   The keyword implements   is used to specify that a class inherits from an interface.&lt;br&gt;e.   The keyword implements   is used to specify that a class inherits from another class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa4q4a1&quot; target=&quot;_top&quot;&gt;6.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statement is true about the following code?&lt;br&gt;//   Filename: MyClass.java&lt;br&gt;abstract   class MyClass implements Interface1, Interface2 {&lt;br&gt; public void f() { }&lt;br&gt; public void g() { }&lt;br&gt;}&lt;br&gt;&lt;br&gt;interface   Interface1 {&lt;br&gt; int VAL_A = 1;&lt;br&gt; int VAL_B = 2;&lt;br&gt;&lt;br&gt; void f();&lt;br&gt; void g();&lt;br&gt;}&lt;br&gt;&lt;br&gt;interface   Interface2 {&lt;br&gt; int VAL_B = 3;&lt;br&gt; int VAL_C = 4;&lt;br&gt;&lt;br&gt; void g();&lt;br&gt; void h();&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Interface1 and Interface2 do not match, therefore, MyClass cannot implement them both.&lt;br&gt;b.   MyClass only implements Interface1. Implementation for void h() from Interface2   is missing.&lt;br&gt;c.   The declarations of void   g() in the two interfaces conflict, therefore, the code will not   compile.&lt;br&gt;d.   The declarations of int   VAL_B in the two interfaces conflict, therefore, the code will   not compile.&lt;br&gt;e.   Nothing is wrong with the code, it will compile without   errors.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa4q5a1&quot; target=&quot;_top&quot;&gt;6.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   the following code, which declaration can be inserted at the indicated line   without causing a compilation error?&lt;br&gt;interface   MyConstants {&lt;br&gt; int r = 42;&lt;br&gt; int s = 69;&lt;br&gt; // INSERT CODE HERE&lt;br&gt;}&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   final double circumference =   2*Math.PI*r;&lt;br&gt;b.   int total = total + r + s;&lt;br&gt;c.   int AREA = r*s;&lt;br&gt;d.   public static MAIN = 15;&lt;br&gt;e.   protected int CODE = 31337;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa5q1a1&quot; target=&quot;_top&quot;&gt;6.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following program, which statement is true?&lt;br&gt;// Filename: MyClass.javapublic class MyClass { public static void main(String[] args) { A[] arrA; B[] arrB; arrA = new A[10]; arrB = new B[20]; arrA = arrB; // (1) arrB = (B[]) arrA; // (2) arrA = new A[10]; arrB = (B[]) arrA; // (3) }}class A {}class B extends A {}   Select the one correct answer.&lt;br&gt;a.   The program will fail to compile because of the assignment   at (1).&lt;br&gt;b.   The program will throw a java.lang.ClassCastException in the   assignment at (2) when run.&lt;br&gt;c.   The program will throw a java.lang.ClassCastException in the   assignment at (3) when run.&lt;br&gt;d.   The program will compile and run without errors, even if the   (B[])   cast in the statements at (2) and (3) is removed.&lt;br&gt;e.   The program will compile and run without errors, but will   not do so if the (B[])   cast in statements at (2) and (3) is removed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa5q2a1&quot; target=&quot;_top&quot;&gt;6.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which is the first line that will cause compilation to fail   in the following program?&lt;br&gt;// Filename: MyClass.javaclass MyClass { public static void main(String[] args) { MyClass a; MySubclass b; a = new MyClass(); // (1) b = new MySubclass(); // (2) a = b; // (3) b = a; // (4) a = new MySubclass(); // (5) b = new MyClass(); // (6) }}class MySubclass extends MyClass {}   Select the one correct answer.&lt;br&gt;a.   Line labeled (1).&lt;br&gt;b.   Line labeled (2).&lt;br&gt;c.   Line labeled (3).&lt;br&gt;d.   Line labeled (4).&lt;br&gt;e.   Line labeled (5).&lt;br&gt;f.   Line labeled (6).   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa5q3a1&quot; target=&quot;_top&quot;&gt;6.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following definitions and reference declarations,   which one of the following assignments is legal?&lt;br&gt;// Definitions:interface I1 {}interface I2 {}class C1 implements I1 {}class C2 implements I2 {}class C3 extends C1 implements I2 {}// Reference declarations:// ... C1 obj1; C2 obj2; C3 obj3;// ...   Select the one correct answer.&lt;br&gt;a.   obj2   = obj1;&lt;br&gt;b.   obj3   = obj1;&lt;br&gt;c.   obj3   = obj2;&lt;br&gt;d.   I1   a = obj2;&lt;br&gt;e.   I1   b = obj3;&lt;br&gt;f.   I2   c = obj1;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa5q4a1&quot; target=&quot;_top&quot;&gt;6.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following class definitions and the reference   declarations, what can be said about the statement y = (Sub) x?&lt;br&gt;// Class definitions:class Super {}class Sub extends Super {}// Reference declarations// ... Super x; Sub y;// ...   Select the one correct answer.&lt;br&gt;a.   Illegal at compile time.&lt;br&gt;b.   Legal at compile time, but might be illegal at runtime.&lt;br&gt;c.   Definitely legal at runtime, but the (Sub) cast is   not strictly needed.&lt;br&gt;d.   Definitely legal at runtime, and the (Sub) cast is   needed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa5q5a1&quot; target=&quot;_top&quot;&gt;6.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following class definitions and declaration   statements, which one of these assignments is legal at compile time?&lt;br&gt;// Definitions:interface A {}class B {}class C extends B implements A {}class D implements A {}// Declaration statements:// [...] B b = new B(); C c = new C(); D d = new D();// [...]   Select the one correct answer.&lt;br&gt;a.   c   = d;&lt;br&gt;b.   d   = c;&lt;br&gt;c.   A   a = d;&lt;br&gt;d.   d   = (D) c;&lt;br&gt;e.   c   = b;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa5q6a1&quot; target=&quot;_top&quot;&gt;6.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which letters will be printed when the following program is   run?&lt;br&gt;// Filename: MyClass.javapublic class MyClass { public static void main(String[] args) { B b = new C(); A a = b; if (a instanceof A) System.out.println(&amp;quot;A&amp;quot;); if (a instanceof B) System.out.println(&amp;quot;B&amp;quot;); if (a instanceof C) System.out.println(&amp;quot;C&amp;quot;); if (a instanceof D) System.out.println(&amp;quot;D&amp;quot;); }}class A {}class B extends A {}class C extends B {}class D extends C {}   Select the three correct answers.&lt;br&gt;a.   A   will be printed.&lt;br&gt;b.   B   will be printed.&lt;br&gt;c.   C   will be printed.&lt;br&gt;d.   D   will be printed.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa5q7a1&quot; target=&quot;_top&quot;&gt;6.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given three classes A, B, and C, where B is a   subclass of A   and C   is a subclass of B,   which one of these boolean expressions is true when an object denoted by   reference o   has actually been instantiated from class B as opposed to from A or C?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   (o   instanceof B) &amp;amp;&amp;amp; (!(o instanceof A))&lt;br&gt;b.   (o   instanceof B) &amp;amp;&amp;amp; (!(o instanceof C))&lt;br&gt;c.   !((o   instanceof A) || (o instanceof B))&lt;br&gt;d.   (o   instanceof B)&lt;br&gt;e.   (o   instanceof B) &amp;amp;&amp;amp; !((o instanceof A) || (o instanceof C))   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa5q8a1&quot; target=&quot;_top&quot;&gt;6.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   When the following program is run, it will print all the   letters I,   J, C, and D. Is this   statement true or false?&lt;br&gt;public class MyClass { public static void main(String[] args) { I x = new D(); if (x instanceof I) System.out.println(&amp;quot;I&amp;quot;); if (x instanceof J) System.out.println(&amp;quot;J&amp;quot;); if (x instanceof C) System.out.println(&amp;quot;C&amp;quot;); if (x instanceof D) System.out.println(&amp;quot;D&amp;quot;); }}interface I{}interface J{}class C implements I {}class D extends C implements J {}   Select the one correct answer.&lt;br&gt;a.   True.&lt;br&gt;b.   False.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_4061533.html&quot; target=&quot;_top&quot;&gt;&lt;/a&gt;&lt;b&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa6q1a1&quot; target=&quot;_top&quot;&gt;6.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class Polymorphism { public static void main(String[] args) { A ref1 = new C(); B ref2 = (B) ref1; System.out.println(ref2.f()); }}class A { int f() { return 0; } }class B extends A { int f() { return 1; } }class C extends B { int f() { return 2; } }   Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will compile without error, but will throw a ClassCastException   when run.&lt;br&gt;c.   The program will compile without error and print 0 when run.&lt;br&gt;d.   The program will compile without error and print 1 when run.&lt;br&gt;e.   The program will compile without error and print 2 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa6q2a1&quot; target=&quot;_top&quot;&gt;6.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class Polymorphism2 { public static void main(String[] args) { A ref1 = new C(); B ref2 = (B) ref1; System.out.println(ref2.g()); }}class A { private int f() { return 0; } public int g() { return 3; }}class B extends A { private int f() { return 1; } public int g() { return f(); }}class C extends B { public int f() { return 2; }}   Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will compile without error and print 0 when run.&lt;br&gt;c.   The program will compile without error and print 1 when run.&lt;br&gt;d.   The program will compile without error and print 2 when run.&lt;br&gt;e.   The program will compile without error and print 3 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa7q1a1&quot; target=&quot;_top&quot;&gt;6.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following code, which statements are true?&lt;br&gt;public interface HeavenlyBody { String describe(); }class Star { String starName; public String describe() { return &amp;quot;star &amp;quot; + starName; }}class Planet extends Star { String name; public String describe() { return &amp;quot;planet &amp;quot; + name + &amp;quot; orbiting star &amp;quot; + starName; }}   Select the two correct answers:&lt;br&gt;a.   The code will fail to compile.&lt;br&gt;b.   The use of inheritance is justified, since Planet is-a Star.&lt;br&gt;c.   The code will fail to compile if the name starName is   replaced with the name bodyName   throughout the declaration of the Star class.&lt;br&gt;d.   The code will fail to compile if the name starName is   replaced with the name name   throughout the declaration of the Star class.&lt;br&gt;e.   An instance of Planet is a valid instance of HeavenlyBody.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec6.html#ch06qa7q2a1&quot; target=&quot;_top&quot;&gt;6.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following code, which statement is true?&lt;br&gt;public interface HeavenlyBody { String describe(); }class Star implements HeavenlyBody { String starName; public String describe() { return &amp;quot;star &amp;quot; + starName; }}class Planet { String name; Star orbiting; public String describe() { return &amp;quot;planet &amp;quot; + name + &amp;quot; orbiting &amp;quot; + orbiting.describe(); }}   Select the one correct answer:&lt;br&gt;a.   The code will fail to compile.&lt;br&gt;b.   The use of aggregation is justified, since Planet has-a Star.&lt;br&gt;c.   The code will fail to compile if the name starName is   replaced with the name bodyName   throughout the declaration of the Star class.&lt;br&gt;d.   The code will fail to compile if the name starName is   replaced with the name name   throughout the declaration of the Star class.&lt;br&gt;e.   An instance of Planet is a valid instance of a HeavenlyBody.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_4061533.html&quot; target=&quot;_top&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Nested Classes And Interfaces&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa1q1a1&quot; target=&quot;_top&quot;&gt;7.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following code?&lt;br&gt;public class MyClass { public static void main(String[] args) { Outer objRef = new Outer(); System.out.println(objRef.createInner().getSecret()); }}class Outer {  private int secret; Outer() { secret = 123; } class Inner { int getSecret() { return secret; } } Inner createInner() { return new Inner(); }}   Select the one correct answer.&lt;br&gt;a.   The code will fail to compile because the class Inner cannot   be declared within the class Outer.&lt;br&gt;b.   The code will fail to compile because the method createInner()   cannot be allowed to pass objects of the class Inner to methods outside of the   class Outer.&lt;br&gt;c.   The code will fail to compile because the secret field   is not accessible from the method getSecret().&lt;br&gt;d.   The code will fail to compile because the method getSecret() is   not visible from the main()   method in the class MyClass.&lt;br&gt;e.   The code will compile without error and will print 123 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa1q2a1&quot; target=&quot;_top&quot;&gt;7.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statements are true about nested classes?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   An instance of a static member class has an inherent outer   instance.&lt;br&gt;b.   A static member class can contain non-static fields.&lt;br&gt;c.   A static member interface can contain non-static fields.&lt;br&gt;d.   A static member interface has an inherent outer instance.&lt;br&gt;e.   For each instance of the outer class, there can exist many   instances of a non-static member class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa1q3a1&quot; target=&quot;_top&quot;&gt;7.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following code?&lt;br&gt;public class MyClass { public static void main(String[] args) { State st = new State(); System.out.println(st.getValue()); State.Memento mem = st.memento(); st.alterValue(); System.out.println(st.getValue()); mem.restore(); System.out.println(st.getValue()); } public static class State { protected int val = 11; int getValue() { return val; } void alterValue() { val = (val + 7) % 31; } Memento memento() { return new Memento(); } class Memento { int val; Memento() { this.val = State.this.val; } void restore() { ((State) this).val = this.val; } } }}   Select the one correct answer.&lt;br&gt;a.   The code will fail to compile since the static main() method   tries to create a new instance of the static member class State.&lt;br&gt;b.   The code will fail to compile since the declaration of class   State.Memento   is not accessible from the main() method.&lt;br&gt;c.   The code will fail to compile since the non-static member   class Memento   declares a field with the same name as a field in the outer class State.&lt;br&gt;d.   The code will fail to compile since the State.this.val   expression in the Memento   constructor is invalid.&lt;br&gt;e.   The code will fail to compile since the ((State) this).val   expression in the method restore()   of the class Memento   is invalid.&lt;br&gt;f.   The program compiles without error and prints 11, 18, and 11 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa1q4a1&quot; target=&quot;_top&quot;&gt;7.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class Nesting { public static void main(String[] args) { B.C obj = new B().new C(); }}class A { int val; A(int v) { val = v; }}class B extends A { int val = 1; B() { super(2); } class C extends A { int val = 3; C() { super(4); System.out.println(B.this.val); System.out.println(C.this.val); System.out.println(super.val); } }}   Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will compile without error and print 2, 3, and 4, in that   order, when run.&lt;br&gt;c.   The program will compile without error and print 1, 4, and 2, in that   order, when run.&lt;br&gt;d.   The program will compile without error and print 1, 3, and 4, in that   order, when run.&lt;br&gt;e.   The program will compile without error and print 3, 2, and 1, in that   order, when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa1q5a1&quot; target=&quot;_top&quot;&gt;7.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statements are true about the following program?&lt;br&gt;public class Outer { public void doIt() { } public class Inner { public void doIt() { } } public static void main(String[] args) { new Outer().new Inner().doIt(); }}   Select the two correct answers.&lt;br&gt;a.   The doIt()   method in the Inner   class overrides the doIt()   method in the Outer   class.&lt;br&gt;b.   The doIt()   method in the Inner   class overloads the doIt()   method in the Outer   class.&lt;br&gt;c.   The doIt()   method in the Inner   class hides the doIt()   method in the Outer   class.&lt;br&gt;d.   The full name of the Inner class is Outer.Inner.&lt;br&gt;e.   The program will fail to compile.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa2q1a1&quot; target=&quot;_top&quot;&gt;7.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statement is true?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Non-static member classes must have either default or public accessibility.&lt;br&gt;b.   All nested classes can declare static member classes.&lt;br&gt;c.   Methods in all nested classes can be declared static.&lt;br&gt;d.   All nested classes can be declared static.&lt;br&gt;e.   Static member classes can contain non-static methods.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa2q2a1&quot; target=&quot;_top&quot;&gt;7.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given   the declaration&lt;br&gt;interface   IntHolder { int getInt(); }&lt;br&gt;which   of the following methods are valid?&lt;br&gt;//----(1)----&lt;br&gt; IntHolder makeIntHolder(int i) {&lt;br&gt; return new IntHolder() {&lt;br&gt; public int getInt() { return i; }&lt;br&gt; };&lt;br&gt; }&lt;br&gt;//----(2)----&lt;br&gt; IntHolder makeIntHolder(final int i) {&lt;br&gt; return new IntHolder {&lt;br&gt; public int getInt() { return i;   }&lt;br&gt; };&lt;br&gt; }&lt;br&gt;//----(3)----&lt;br&gt; IntHolder makeIntHolder(int i) {&lt;br&gt; class MyIH implements IntHolder {&lt;br&gt; public int getInt() { return i;   }&lt;br&gt; }&lt;br&gt; return new MyIH();&lt;br&gt; }&lt;br&gt;//----(4)----&lt;br&gt; IntHolder makeIntHolder(final int i) {&lt;br&gt; class MyIH implements IntHolder {&lt;br&gt; public int getInt() { return i;   }&lt;br&gt; }&lt;br&gt; return new MyIH();&lt;br&gt; }&lt;br&gt;//----(5)----&lt;br&gt; IntHolder makeIntHolder(int i) {&lt;br&gt; return new MyIH(i);&lt;br&gt; }&lt;br&gt; static class MyIH implements IntHolder {&lt;br&gt; final int j;&lt;br&gt; MyIH(int i) { j = i; }&lt;br&gt; public int getInt() { return j; }&lt;br&gt; }&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   The method labeled (1).&lt;br&gt;b.   The method labeled (2).&lt;br&gt;c.   The method labeled (3).&lt;br&gt;d.   The method labeled (4).&lt;br&gt;e.   The method labeled (5).   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa2q3a1&quot; target=&quot;_top&quot;&gt;7.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   No other static members, except final   static fields, can be declared within a non-static member class.&lt;br&gt;b.   If a non-static member class is nested within a class named Outer, then methods within the non-static   member class must use the prefix Outer.this   to access the members of the class Outer.&lt;br&gt;c.   All fields in any nested class must be declared final.&lt;br&gt;d.   Anonymous classes cannot have constructors.&lt;br&gt;e.   If objRef is an instance of   any nested class within the class Outer,   then the expression (objRef instanceof Outer)   will evaluate to true.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec7.html#ch07qa2q4a1&quot; target=&quot;_top&quot;&gt;7.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statement is true?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Top-level classes can be declared static.&lt;br&gt;b.   Classes declared as members of top-level classes can be   declared static.&lt;br&gt;c.   Local classes can be declared static.&lt;br&gt;d.   Anonymous classes can be declared static.&lt;br&gt;e.   No classes can be declared static.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Object Lifetime&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa1q1a1&quot; target=&quot;_top&quot;&gt;8.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   Objects can be explicitly destroyed using the keyword delete.&lt;br&gt;b.   An object will be garbage collected immediately after it   becomes unreachable.&lt;br&gt;c.   If object obj1 is accessible from object obj2, and   object obj2   is accessible from obj1,   then obj1   and obj2   are not eligible for garbage collection.&lt;br&gt;d.   Once an object has become eligible for garbage collection,   it will remain eligible until it is destroyed.&lt;br&gt;e.   If object obj1 can access object obj2 that is eligible for   garbage collection, then obj1   is also eligible for garbage collection.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa1q2a1&quot; target=&quot;_top&quot;&gt;8.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Identify the location in the following program where the   object, initially referenced with arg1, is eligible for garbage   collection.&lt;br&gt;public class MyClass { public static void main(String[] args) { String msg; String pre = &amp;quot;This program was called with &amp;quot;; String post = &amp;quot; as first argument.&amp;quot;; String arg1 = new String((args.length &amp;gt; 0) ? &amp;quot;&amp;#39;&amp;quot; + args[ 0 ] + &amp;quot;&amp;#39;&amp;quot; : &amp;quot;&amp;lt;no argument&amp;gt;&amp;quot;); msg = arg1; arg1 = null; // (1) msg = pre + msg + post; // (2) pre = null; // (3) System.out.println(msg); msg = null; // (4) post = null; // (5) args = null; // (6) }}   Select the one correct answer.&lt;br&gt;a.   After the line labeled (1).&lt;br&gt;b.   After the line labeled (2).&lt;br&gt;c.   After the line labeled (3).&lt;br&gt;d.   After the line labeled (4).&lt;br&gt;e.   After the line labeled (5).&lt;br&gt;f.   After the line labeled (6).   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa1q3a1&quot; target=&quot;_top&quot;&gt;8.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   If an exception is thrown during the execution of the finalize()   method of an eligible object, then the exception is ignored and the object is   destroyed.&lt;br&gt;b.   All objects have a finalize() method.&lt;br&gt;c.   Objects can be destroyed by explicitly calling the finalize()   method.&lt;br&gt;d.   The finalize()   method can be declared with any accessibility.&lt;br&gt;e.   The compiler will fail to compile code that defines an   overriding finalize()   method that does not explicitly call the overridden finalize()   method from the superclass.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa1q4a1&quot; target=&quot;_top&quot;&gt;8.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The compiler will fail to compile code that explicitly tries   to call the finalize()   method.&lt;br&gt;b.   The finalize()   method must be declared with protected accessibility.&lt;br&gt;c.   An overriding finalize() method in any class can always throw   checked exceptions.&lt;br&gt;d.   The finalize()   method can be overloaded.&lt;br&gt;e.   The body of the finalize() method can only access   other objects that are eligible for garbage collection.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa1q5a1&quot; target=&quot;_top&quot;&gt;8.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement describes guaranteed behavior of the garbage   collection and finalization mechanisms?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   Objects will not be destroyed until they have no references   to them.&lt;br&gt;b.   The finalize()   method will never be called more than once on an object.&lt;br&gt;c.   An object eligible for garbage collection will eventually be   destroyed by the garbage collector.&lt;br&gt;d.   If object A became eligible for garbage collection before   object B,   then object A   will be destroyed before object B.&lt;br&gt;e.   An object, once eligible for garbage collection, can never   become accessible by a live thread.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa2q1a1&quot; target=&quot;_top&quot;&gt;8.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following class, which of these static initializer   blocks can be inserted after the comment?&lt;br&gt;public class MyClass {&lt;br&gt; private static int   count = 5;&lt;br&gt; final static int   STEP = 10;&lt;br&gt; boolean alive;&lt;br&gt; // INSERT STATIC   INITIALIZER BLOCK HERE&lt;br&gt;}&lt;br&gt;Select the three correct answers.&lt;br&gt;a.   static   { alive = true; count = 0; }&lt;br&gt;b.   static   { STEP = count; }&lt;br&gt;c.   static   { count += STEP; }&lt;br&gt;d.   static   ;&lt;br&gt;e.   static   {;}&lt;br&gt;f.   static   { count = 1; }   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa2q2a1&quot; target=&quot;_top&quot;&gt;8.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following code?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; MyClass obj =   new MyClass(l);&lt;br&gt; }&lt;br&gt; static int i = 5;&lt;br&gt; static int l;&lt;br&gt; int j = 7;&lt;br&gt; int k;&lt;br&gt;&lt;br&gt; public MyClass(int   m) {&lt;br&gt;   System.out.println(i + &amp;quot;, &amp;quot; + j + &amp;quot;, &amp;quot; + k +   &amp;quot;, &amp;quot; + l + &amp;quot;, &amp;quot; + m);&lt;br&gt; }&lt;br&gt; { j = 70; l = 20;   } // Instance Initializer Block&lt;br&gt; static { i = 50;   } // Static Initializer Block&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile, since the instance   initializer block tries to assign a value to a static field.&lt;br&gt;b.   The code will fail to compile, since the field k will be   uninitialized when it is used.&lt;br&gt;c.   The code will compile without error and will print 50, 70, 0, 20, 0   when run.&lt;br&gt;d.   The code will compile without error and will print 50, 70, 0, 20, 20   when run.&lt;br&gt;e.   The code will compile without error and will print 5, 70, 0, 20, 0   when run.&lt;br&gt;f.   The code will compile without error and will print 5, 7, 0, 20, 0   when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa2q3a1&quot; target=&quot;_top&quot;&gt;8.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following class, which instance initializer block   inserted at the indicated location will allow the class to compile without   errors?&lt;br&gt;public class MyClass {&lt;br&gt; static int gap =   10;&lt;br&gt; double length;&lt;br&gt; final boolean   active;&lt;br&gt;&lt;br&gt; // INSERT CODE   HERE&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   instance   { active = true; }&lt;br&gt;b.   MyClass   { gap += 5; }&lt;br&gt;c.   {   gap = 5; length = (active ? 100 : 200) + gap; }&lt;br&gt;d.   {   ; }&lt;br&gt;e.   {   length = 4.2; }&lt;br&gt;f.   {   active = (gap &amp;gt; 5); length = 5.5 + gap;}   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa2q4a1&quot; target=&quot;_top&quot;&gt;8.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class Initialization {&lt;br&gt; private static   String msg(String msg) {&lt;br&gt;   System.out.println(msg); return msg;&lt;br&gt; }&lt;br&gt;&lt;br&gt; public   Initialization() { m = msg(&amp;quot;1&amp;quot;); }&lt;br&gt;&lt;br&gt; { m =   msg(&amp;quot;2&amp;quot;); }&lt;br&gt;&lt;br&gt; String m =   msg(&amp;quot;3&amp;quot;);&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; Object obj =   new Initialization();&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will compile without error and will print 1, 2, and 3 when run.&lt;br&gt;c.   The program will compile without error and will print 2, 3, and 1 when run.&lt;br&gt;d.   The program will compile without error and will print 3, 1, and 2 when run.&lt;br&gt;e.   The program will compile without error and will print 1, 3, and 2 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa2q5a1&quot; target=&quot;_top&quot;&gt;8.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class Initialization {&lt;br&gt; private static   String msg(String msg) {&lt;br&gt;   System.out.println(msg); return msg;&lt;br&gt; }&lt;br&gt; static String m =   msg(&amp;quot;1&amp;quot;);&lt;br&gt; { m =   msg(&amp;quot;2&amp;quot;); }&lt;br&gt; static { m =   msg(&amp;quot;3&amp;quot;); }&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; Object obj =   new Initialization();&lt;br&gt; }}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will compile without error and will print 1, 2, and 3 when run.&lt;br&gt;c.   The program will compile without error and will print 2, 3, and 1 when run.&lt;br&gt;d.   The program will compile without error and will print 3, 1, and 2 when run.&lt;br&gt;e.   The program will compile without error and will print 1, 3, and 2 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec8.html#ch08qa2q6a1&quot; target=&quot;_top&quot;&gt;8.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of the labeled lines in the following code can be uncommented by removing the // characters   and still allow the code to compile correctly?&lt;br&gt;class GeomInit {&lt;br&gt;// int width =   14; /* Line A */&lt;br&gt; {&lt;br&gt;// area = width   * height; /* Line B */&lt;br&gt; }&lt;br&gt; int width = 37;&lt;br&gt; {&lt;br&gt;// height =   11; /* Line C */&lt;br&gt; }&lt;br&gt; int height, area;&lt;br&gt;// area = width *   height; /* Line D */&lt;br&gt; {&lt;br&gt;// int width =   15; /* Line E */&lt;br&gt; area = 100;&lt;br&gt; }&lt;br&gt;};&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   Line A&lt;br&gt;b.   Line B&lt;br&gt;c.   Line C&lt;br&gt;d.   Line D&lt;br&gt;e.   Line E   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Threads&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;606&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa1q1a1&quot; target=&quot;_top&quot;&gt;9.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which is the correct way to start a new thread?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   Just create a new Thread object. The thread will start   automatically.&lt;br&gt;b.   Create a new Thread object and call the method begin().&lt;br&gt;c.   Create a new Thread object and call the method start().&lt;br&gt;d.   Create a new Thread object and call the method run().&lt;br&gt;e.   Create a new Thread object and call the method resume().   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa1q2a1&quot; target=&quot;_top&quot;&gt;9.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   When extending the Thread class to provide a thread&amp;#39;s   behavior, which method should be overridden?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   begin()&lt;br&gt;b.   start()&lt;br&gt;c.   run()&lt;br&gt;d.   resume()&lt;br&gt;e.   behavior()   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa1q3a1&quot; target=&quot;_top&quot;&gt;9.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statements are true?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   The class Thread is abstract.&lt;br&gt;b.   The class Thread implements Runnable.&lt;br&gt;c.   Classes implementing the Runnable interface must define a   method named start.&lt;br&gt;d.   Calling the method run() on an object implementing Runnable will   create a new thread.&lt;br&gt;e.   A program terminates when the last non-daemon thread ends.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa1q4a1&quot; target=&quot;_top&quot;&gt;9.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class MyClass extends Thread { public MyClass(String s) { msg = s; } String msg; public void run() { System.out.println(msg); } public static void main(String[] args) { new MyClass(&amp;quot;Hello&amp;quot;); new MyClass(&amp;quot;World&amp;quot;); }}   Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   The program will compile without errors and will print Hello and World, in that   order, every time the program is run.&lt;br&gt;c.   The program will compile without errors and will print a   never-ending stream of Hello   and World.&lt;br&gt;d.   The program will compile without errors and will print Hello and World when   run, but the order is unpredictable.&lt;br&gt;e.   The program will compile without errors and will simply   terminate without any output when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa2q1a1&quot; target=&quot;_top&quot;&gt;9.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following program, which statements are guaranteed   to be true?&lt;br&gt;public class ThreadedPrint {&lt;br&gt; static Thread   makeThread(final String id, boolean daemon) {&lt;br&gt; Thread t =   new Thread(id) {&lt;br&gt; public   void run() {&lt;br&gt;   System.out.println(id);&lt;br&gt; }&lt;br&gt; };&lt;br&gt;   t.setDaemon(daemon);&lt;br&gt; t.start();&lt;br&gt; return t;&lt;br&gt; }&lt;br&gt;&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; Thread a =   makeThread(&amp;quot;A&amp;quot;, false);&lt;br&gt; Thread b =   makeThread(&amp;quot;B&amp;quot;, true);&lt;br&gt;   System.out.print(&amp;quot;End\n&amp;quot;);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   The letter A is always printed.&lt;br&gt;b.   The letter B is always printed.&lt;br&gt;c.   The letter A is never printed after End.&lt;br&gt;d.   The letter B is never printed after End.&lt;br&gt;e.   The program might print B, End and A, in that order.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa2q2a1&quot; target=&quot;_top&quot;&gt;9.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   No two threads can concurrently execute synchronized methods   on the same object.&lt;br&gt;b.   Methods declared synchronized should not be recursive,   since the object lock will not allow new invocations of the method.&lt;br&gt;c.   Synchronized methods can only call other synchronized   methods directly.&lt;br&gt;d.   Inside a synchronized   method, one can assume that no other threads are currently executing any   other methods in the same class.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa2q3a1&quot; target=&quot;_top&quot;&gt;9.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following program, which statement is true?&lt;br&gt;public class MyClass extends Thread {&lt;br&gt; static Object   lock1 = new Object();&lt;br&gt; static Object   lock2 = new Object();&lt;br&gt;&lt;br&gt; static volatile   int i1, i2, j1, j2, k1, k2;&lt;br&gt;&lt;br&gt; public void run()   { while (true) { doit(); check(); } }&lt;br&gt;&lt;br&gt; void doit() {&lt;br&gt;   synchronized(lock1) { i1++; }&lt;br&gt; j1++;&lt;br&gt;   synchronized(lock2) { k1++; k2++; }&lt;br&gt; j2++;&lt;br&gt;   synchronized(lock1) { i2++; }&lt;br&gt; }&lt;br&gt;&lt;br&gt; void check() {&lt;br&gt; if (i1 != i2)   System.out.println(&amp;quot;i&amp;quot;);&lt;br&gt; if (j1 != j2)   System.out.println(&amp;quot;j&amp;quot;);&lt;br&gt; if (k1 != k2)   System.out.println(&amp;quot;k&amp;quot;);&lt;br&gt; }&lt;br&gt;&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; new   MyClass().start();&lt;br&gt; new   MyClass().start();&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The program will fail to compile.&lt;br&gt;b.   One cannot be certain whether any of the letters i, j, and k will be   printed during execution.&lt;br&gt;c.   One can be certain that none of the letters i, j, and k will ever be   printed during execution.&lt;br&gt;d.   One can be certain that the letters i and k will never   be printed during execution.&lt;br&gt;e.   One can be certain that the letter k will never   be printed during execution.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa3q1a1&quot; target=&quot;_top&quot;&gt;9.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   one of these events will cause a thread to die?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   The method sleep()   is called.&lt;br&gt;b.   The method wait()   is called.&lt;br&gt;c.   Execution of the start()   method ends.&lt;br&gt;d.   Execution of the run()   method ends.&lt;br&gt;e.   Execution of the thread&amp;#39;s constructor ends.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa3q2a1&quot; target=&quot;_top&quot;&gt;9.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true about the following code?&lt;br&gt;public   class Joining {&lt;br&gt; static Thread createThread(final int i,   final Thread t1) {&lt;br&gt; Thread t2 = new Thread() {&lt;br&gt; public void run() {&lt;br&gt; System.out.println(i+1);&lt;br&gt; try {&lt;br&gt; t1.join();&lt;br&gt; } catch   (InterruptedException e) {&lt;br&gt; }&lt;br&gt; System.out.println(i+2);&lt;br&gt; }&lt;br&gt; };&lt;br&gt;   System.out.println(i+3);&lt;br&gt; t2.start();&lt;br&gt; System.out.println(i+4);&lt;br&gt; return t2;&lt;br&gt; }&lt;br&gt;&lt;br&gt; public static void main(String[] args) {&lt;br&gt; createThread(10, createThread(20,   Thread.currentThread()));&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   The first number printed is 13.&lt;br&gt;b.   The number 14 is   printed before the number 22.&lt;br&gt;c.   The number 24 is   printed before the number 21.&lt;br&gt;d.   The last number printed is 12.&lt;br&gt;e.   The number 11 is   printed before the number 23.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa3q3a1&quot; target=&quot;_top&quot;&gt;9.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   can be guaranteed by calling the method yield()?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   All lower priority threads will be granted CPU time.&lt;br&gt;b.   The current thread will sleep for some time while some other   threads run.&lt;br&gt;c.   The current thread will not continue until other threads   have terminated.&lt;br&gt;d.   The thread will wait until it is notified.&lt;br&gt;e.   None of the above.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa3q4a1&quot; target=&quot;_top&quot;&gt;9.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Where   is the notify()   method defined?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   Thread&lt;br&gt;b.   Object&lt;br&gt;c.   Applet&lt;br&gt;d.   Runnable   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa3q5a1&quot; target=&quot;_top&quot;&gt;9.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   How   can the priority of a thread be set?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   By using the setPriority()   method in the class Thread.&lt;br&gt;b.   By passing the priority as a parameter to the constructor of   the thread.&lt;br&gt;c.   Both of the above.&lt;br&gt;d.   None of the above.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa3q6a1&quot; target=&quot;_top&quot;&gt;9.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true about locks?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   A thread can hold more than one lock at a time.&lt;br&gt;b.   Invoking wait()   on a Thread object will   relinquish all locks held by the thread.&lt;br&gt;c.   Invoking wait()   on an object whose lock is held by the current thread will relinquish the   lock.&lt;br&gt;d.   Invoking notify()   on a object whose lock is held by the current thread will relinquish the   lock.&lt;br&gt;e.   Multiple threads can hold the same lock at the same time.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa3q7a1&quot; target=&quot;_top&quot;&gt;9.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   will be the result of invoking the wait() method on an object without   ensuring that the current thread holds the lock of the object?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   The code will fail to compile.&lt;br&gt;b.   Nothing special will happen.&lt;br&gt;c.   An IllegalMonitorStateException   will be thrown if the wait() method is called   while the current thread does not hold the lock of the object.&lt;br&gt;d.   The thread will be blocked until it gains the lock of the   object.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec9.html#ch09qa3q8a1&quot; target=&quot;_top&quot;&gt;9.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of these are plausible reasons why a thread might be alive, but still not be   running?&lt;br&gt;Select   the four correct answers.&lt;br&gt;a.   The thread is waiting for some condition as a result of a wait() call.&lt;br&gt;b.   The execution has reached the end of the run() method.&lt;br&gt;c.   The thread is waiting to acquire the lock of an object in   order to execute a certain method on that object.&lt;br&gt;d.   The thread does not have the highest priority and is   currently not executing.&lt;br&gt;e.   The thread is sleeping as a result of a call to the sleep() method.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Fundamental Classes&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa1q1a1&quot; target=&quot;_top&quot;&gt;10.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What is the return type of the hashCode() method in the Object class?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   String&lt;br&gt;b.   int&lt;br&gt;c.   long&lt;br&gt;d.   Object&lt;br&gt;e.   Class   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa1q2a1&quot; target=&quot;_top&quot;&gt;10.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement is true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   If the references x and y denote two different objects, then the   expression x.equals(y)   is always false.&lt;br&gt;b.   If the references x and y denote two different objects, then   the expression (x.hashCode()   == y.hashCode()) is always false.&lt;br&gt;c.   The hashCode()   method in the Object   class is declared final.&lt;br&gt;d.   The equals()   method in the Object   class is declared final.&lt;br&gt;e.   All arrays have a method named clone.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa1q3a1&quot; target=&quot;_top&quot;&gt;10.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which exception can the clone() method of the Object class   throw?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   CloneNotSupportedException&lt;br&gt;b.   NotCloneableException&lt;br&gt;c.   IllegalCloneException&lt;br&gt;d.   NoClonesAllowedException   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa2q1a1&quot; target=&quot;_top&quot;&gt;10.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of the following are wrapper classes?&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   java.lang.Void&lt;br&gt;b.   java.lang.Int&lt;br&gt;c.   java.lang.Boolean&lt;br&gt;d.   java.lang.Long&lt;br&gt;e.   java.lang.String   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa2q2a1&quot; target=&quot;_top&quot;&gt;10.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of the following classes do not extend the java.lang.Number class?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   java.lang.Float&lt;br&gt;b.   java.lang.Byte&lt;br&gt;c.   java.lang.Character&lt;br&gt;d.   java.lang.Boolean&lt;br&gt;e.   java.lang.Short   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa2q3a1&quot; target=&quot;_top&quot;&gt;10.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of these classes define immutable objects?&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   Character&lt;br&gt;b.   Byte&lt;br&gt;c.   Thread&lt;br&gt;d.   Short&lt;br&gt;e.   Object   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa2q4a1&quot; target=&quot;_top&quot;&gt;10.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of these classes have a one-parameter constructor taking a string?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   Void&lt;br&gt;b.   Integer&lt;br&gt;c.   Boolean&lt;br&gt;d.   Character&lt;br&gt;e.   Object   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa2q5a1&quot; target=&quot;_top&quot;&gt;10.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of the wrapper classes have a booleanValue() method?&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   All wrapper classes.&lt;br&gt;b.   All wrapper classes except Void.&lt;br&gt;c.   All wrapper classes that also implement the compareTo() method.&lt;br&gt;d.   All wrapper classes extending Number.&lt;br&gt;e.   Only the class Boolean.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa2q6a1&quot; target=&quot;_top&quot;&gt;10.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true about wrapper classes?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   String is a wrapper   class.&lt;br&gt;b.   Double has a compareTo() method.&lt;br&gt;c.   Character has a intValue() method.&lt;br&gt;d.   Byte extends Number.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa3q1a1&quot; target=&quot;_top&quot;&gt;10.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Given the following program, which lines will print 11 exactly?&lt;br&gt;class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; double v =   10.5;&lt;br&gt;&lt;br&gt;   System.out.println(Math.ceil(v)); // (1)&lt;br&gt;   System.out.println(Math.round(v)); // (2)&lt;br&gt;   System.out.println(Math.floor(v)); // (3)&lt;br&gt;   System.out.println((int) Math.ceil(v)); // (4)&lt;br&gt;   System.out.println((int) Math.floor(v)); // (5)&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   The line labeled (1).&lt;br&gt;b.   The line labeled (2).&lt;br&gt;c.   The line labeled (3).&lt;br&gt;d.   The line labeled (4).&lt;br&gt;e.   The line labeled (5).   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa3q2a1&quot; target=&quot;_top&quot;&gt;10.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which method is not defined in the Math class?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   double   tan2(double)&lt;br&gt;b.   double   cos(double)&lt;br&gt;c.   int   abs(int a)&lt;br&gt;d.   double   ceil(double)&lt;br&gt;e.   float   max(float, float)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa3q3a1&quot; target=&quot;_top&quot;&gt;10.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What is the return type of the method round(float)   from the Math   class?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   int&lt;br&gt;b.   float&lt;br&gt;c.   double&lt;br&gt;d.   Integer&lt;br&gt;e.   Float   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa3q4a1&quot; target=&quot;_top&quot;&gt;10.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What is the return type of the method ceil(double)   from the Math   class?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   int&lt;br&gt;b.   float&lt;br&gt;c.   double&lt;br&gt;d.   Integer&lt;br&gt;e.   Double   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa3q5a1&quot; target=&quot;_top&quot;&gt;10.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will the following program print when run?&lt;br&gt;public class Round {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt;   System.out.println(Math.round(-0.5) + &amp;quot; &amp;quot; +   Math.round(0.5));&lt;br&gt; }&lt;br&gt;};&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   0   0&lt;br&gt;b.   0   1&lt;br&gt;c.   -1   0&lt;br&gt;d.   -1   1&lt;br&gt;e.   None of the above.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa3q6a1&quot; target=&quot;_top&quot;&gt;10.15&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statements are true about the expression ((int)(Math.random()*4))?&lt;br&gt;Select the three correct answers.&lt;br&gt;a.   It may evaluate to a negative number.&lt;br&gt;b.   It may evaluate to the number 0.&lt;br&gt;c.   The probability of it evaluating to the number 1 or the   number 2 is the same.&lt;br&gt;d.   It may evaluate to the number 3.&lt;br&gt;e.   It may evaluate to the number 4.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q1a1&quot; target=&quot;_top&quot;&gt;10.16&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of the following operators cannot be used in   conjunction with a String   object?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   +&lt;br&gt;b.   -&lt;br&gt;c.   +=&lt;br&gt;d.   .&lt;br&gt;e.   &amp;amp;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q2a1&quot; target=&quot;_top&quot;&gt;10.17&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which expression will extract the substring &amp;quot;kap&amp;quot;   from a string defined by String   str = &amp;quot;kakapo&amp;quot;?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   str.substring(2,   2)&lt;br&gt;b.   str.substring(2,   3)&lt;br&gt;c.   str.substring(2,   4)&lt;br&gt;d.   str.substring(2,   5)&lt;br&gt;e.   str.substring(3,   3)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q3a1&quot; target=&quot;_top&quot;&gt;10.18&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following code?&lt;br&gt;class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; String str1 =   &amp;quot;str1&amp;quot;;&lt;br&gt; String str2 =   &amp;quot;str2&amp;quot;;&lt;br&gt; String str3 =   &amp;quot;str3&amp;quot;;&lt;br&gt;&lt;br&gt;   str1.concat(str2);&lt;br&gt;   System.out.println(str3.concat(str1));&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile since the expression str3.concat(str1)   will not result in a valid argument for the println() method.&lt;br&gt;b.   The program will print str3str1str2 when run.&lt;br&gt;c.   The program will print str3 when run.&lt;br&gt;d.   The program will print str3str1 when run.&lt;br&gt;e.   The program will print str3str2 when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q4a1&quot; target=&quot;_top&quot;&gt;10.19&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What function does the trim() method of the String class   perform?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   It returns a string where the leading white space of the original   string has been removed.&lt;br&gt;b.   It returns a string where the trailing white space of the   original string has been removed.&lt;br&gt;c.   It returns a string where both the leading and trailing   white space of the original string has been removed.&lt;br&gt;d.   It returns a string where all the white space of the   original string has been removed.&lt;br&gt;e.   None of the above.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q5a1&quot; target=&quot;_top&quot;&gt;10.20&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statements are true?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   String   objects are immutable.&lt;br&gt;b.   Subclasses of the String class can be mutable.&lt;br&gt;c.   All wrapper classes are declared final.&lt;br&gt;d.   All objects have a public method named clone().&lt;br&gt;e.   The expression ((new StringBuffer()) instanceof String) is always   true.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q6a1&quot; target=&quot;_top&quot;&gt;10.21&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of these expressions are legal?&lt;br&gt;Select the four correct answers.&lt;br&gt;a.   &amp;quot;co&amp;quot;.concat(&amp;quot;ol&amp;quot;)&lt;br&gt;b.   (&amp;quot;co&amp;quot;   + &amp;quot;ol&amp;quot;)&lt;br&gt;c.   (&amp;#39;c&amp;#39;   + &amp;#39;o&amp;#39; + &amp;#39;o&amp;#39; + &amp;#39;l&amp;#39;)&lt;br&gt;d.   (&amp;quot;co&amp;quot;   + new String(&amp;#39;o&amp;#39; + &amp;#39;l&amp;#39;))&lt;br&gt;e.   (&amp;quot;co&amp;quot;   + new String(&amp;quot;co&amp;quot;))   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q7a1&quot; target=&quot;_top&quot;&gt;10.22&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following code?&lt;br&gt;public class RefEq {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; String s =   &amp;quot;ab&amp;quot; + &amp;quot;12&amp;quot;;&lt;br&gt; String t =   &amp;quot;ab&amp;quot; + 12;&lt;br&gt; String u =   new String(&amp;quot;ab12&amp;quot;);&lt;br&gt;   System.out.println((s==t) + &amp;quot; &amp;quot; + (s==u));&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile.&lt;br&gt;b.   The program will print false false when run.&lt;br&gt;c.   The program will print false true when run.&lt;br&gt;d.   The program will print true false when run.&lt;br&gt;e.   The program will print true true when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q8a1&quot; target=&quot;_top&quot;&gt;10.23&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of these parameter lists have a corresponding   constructor in the String   class?&lt;br&gt;Select the three correct answers.&lt;br&gt;a.   ()&lt;br&gt;b.   (int   capacity)&lt;br&gt;c.   (char[]   data)&lt;br&gt;d.   (String   str)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q9a1&quot; target=&quot;_top&quot;&gt;10.24&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which method is not defined in the String class?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   trim()&lt;br&gt;b.   length()&lt;br&gt;c.   concat(String)&lt;br&gt;d.   hashCode()&lt;br&gt;e.   reverse()   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q10a1&quot; target=&quot;_top&quot;&gt;10.25&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which statement concerning the charAt() method of the String class   is true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The charAt()   method takes a char   value as an argument.&lt;br&gt;b.   The charAt()   method returns a Character   object.&lt;br&gt;c.   The expression (&amp;quot;abcdef&amp;quot;).charAt(3) is illegal.&lt;br&gt;d.   The expression &amp;quot;abcdef&amp;quot;.charAt(3) evaluates to the   character &amp;#39;d&amp;#39;.&lt;br&gt;e.   The index of the first character is 1.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q11a1&quot; target=&quot;_top&quot;&gt;10.26&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which expression will evaluate to true?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   &amp;quot;hello:   there!&amp;quot;.equals(&amp;quot;hello there&amp;quot;)&lt;br&gt;b.   &amp;quot;HELLO   THERE&amp;quot;.equals(&amp;quot;hello there&amp;quot;)&lt;br&gt;c.   (&amp;quot;hello&amp;quot;.concat(&amp;quot;there&amp;quot;)).equals(&amp;quot;hello   there&amp;quot;)&lt;br&gt;d.   &amp;quot;Hello   There&amp;quot;.compareTo(&amp;quot;hello there&amp;quot;) == 0&lt;br&gt;e.   &amp;quot;Hello   there&amp;quot;.toLowerCase().equals(&amp;quot;hello there&amp;quot;)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa4q12a1&quot; target=&quot;_top&quot;&gt;10.27&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will the following program print when run?&lt;br&gt;public class Search {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; String s =   &amp;quot;Contentment!&amp;quot;;&lt;br&gt; int middle =   s.length()/2;&lt;br&gt; String nt =   s.substring(middle-1, middle+1);&lt;br&gt;   System.out.println(s.lastIndexOf(nt, middle));&lt;br&gt; }&lt;br&gt;};&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   2&lt;br&gt;b.   4&lt;br&gt;c.   5&lt;br&gt;d.   7&lt;br&gt;e.   9&lt;br&gt;f.   11   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa5q1a1&quot; target=&quot;_top&quot;&gt;10.28&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; String s =   &amp;quot;hello&amp;quot;;&lt;br&gt; StringBuffer   sb = new StringBuffer(s);&lt;br&gt; sb.reverse();&lt;br&gt; if (s == sb)   System.out.println(&amp;quot;a&amp;quot;);&lt;br&gt; if   (s.equals(sb)) System.out.println(&amp;quot;b&amp;quot;);&lt;br&gt; if   (sb.equals(s)) System.out.println(&amp;quot;c&amp;quot;);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile since the constructor of the String class   is not called properly.&lt;br&gt;b.   The code will fail to compile since the expression (s == sb) is   illegal.&lt;br&gt;c.   The code will fail to compile since the expression (s.equals(sb))   is illegal.&lt;br&gt;d.   The program will print c when run.&lt;br&gt;e.   The program will throw a ClassCastException when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa5q2a1&quot; target=&quot;_top&quot;&gt;10.29&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following program?&lt;br&gt;public class MyClass {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; StringBuffer   sb = new StringBuffer(&amp;quot;have a nice day&amp;quot;);&lt;br&gt;   sb.setLength(6);&lt;br&gt;   System.out.println(sb);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile since there is no method named   setLength   in the StringBuffer   class.&lt;br&gt;b.   The code will fail to compile since the StringBuffer   reference sb   is not a legal argument to the println() method.&lt;br&gt;c.   The program will throw a StringIndexOutOfBoundsException when   run.&lt;br&gt;d.   The program will print have a nice day when run.&lt;br&gt;e.   The program will print have a when run.&lt;br&gt;f.   The program will print ce day when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa5q3a1&quot; target=&quot;_top&quot;&gt;10.30&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of these parameter lists have a corresponding   constructor in the StringBuffer   class?&lt;br&gt;Select the three correct answers.&lt;br&gt;a.   ()&lt;br&gt;b.   (int   capacity)&lt;br&gt;c.   (char[]   data)&lt;br&gt;d.   (String   str)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa5q4a1&quot; target=&quot;_top&quot;&gt;10.31&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which method is not defined in the StringBuffer   class?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   trim()&lt;br&gt;b.   length()&lt;br&gt;c.   append(String)&lt;br&gt;d.   reverse()&lt;br&gt;e.   setLength(int)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec10.html#ch10qa5q5a1&quot; target=&quot;_top&quot;&gt;10.32&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What will be the result of attempting to compile and run the   following code?&lt;br&gt;public class StringMethods {&lt;br&gt; public static   void main(String[] args) {&lt;br&gt; String str =   new String(&amp;quot;eenny&amp;quot;);&lt;br&gt;   str.concat(&amp;quot; meeny&amp;quot;);&lt;br&gt; StringBuffer   strBuf = new StringBuffer(&amp;quot; miny&amp;quot;);&lt;br&gt; strBuf.append(&amp;quot;   mo&amp;quot;);&lt;br&gt;   System.out.println(str + strBuf);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   The code will fail to compile.&lt;br&gt;b.   The program will print eenny meeny miny mo when run.&lt;br&gt;c.   The program will print meeny miny mo when run.&lt;br&gt;d.   The program will print eenny miny mo when run.&lt;br&gt;e.   The program will print eenny meeny miny when run.   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Collections and Maps&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa1q1a1&quot; target=&quot;_top&quot;&gt;11.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of these are core interfaces in the collections   framework?&lt;br&gt;Select the three correct answers.&lt;br&gt;a.   Set&lt;br&gt;b.   Bag&lt;br&gt;c.   LinkedList&lt;br&gt;d.   Collection&lt;br&gt;e.   Map   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa1q2a1&quot; target=&quot;_top&quot;&gt;11.2&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which of these implementations are provided by the java.util   package?&lt;br&gt;Select the two correct answers.&lt;br&gt;a.   HashList&lt;br&gt;b.   HashMap&lt;br&gt;c.   ArraySet&lt;br&gt;d.   ArrayMap&lt;br&gt;e.   TreeMap   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa1q3a1&quot; target=&quot;_top&quot;&gt;11.3&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What is the name of the interface used to represent   collections that maintain non-unique elements in order?&lt;br&gt;Select the one correct answer.&lt;br&gt;a.   Collection&lt;br&gt;b.   Set&lt;br&gt;c.   SortedSet&lt;br&gt;d.   List&lt;br&gt;e.   Sequence   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa2q1a1&quot; target=&quot;_top&quot;&gt;11.4&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   statements are true about collections?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   Some operations on a collection may throw an UnsupportedOperationException.&lt;br&gt;b.   Methods calling optional operations in a collection must   either catch an UnsupportedOperationException   or declare it in their throws clause.&lt;br&gt;c.   A List can have duplicate   elements.&lt;br&gt;d.   An ArrayList can only   accommodate a fixed number of elements.&lt;br&gt;e.   The Collection interface   contains a method named get.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa2q2a1&quot; target=&quot;_top&quot;&gt;11.5&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   will be the result of attempting to compile and run the following program?&lt;br&gt;import   java.util.*;&lt;br&gt;&lt;br&gt;public   class Sets {&lt;br&gt; public static void main(String[] args) {&lt;br&gt; HashSet set1 = new HashSet();&lt;br&gt; addRange(set1, 1);&lt;br&gt; ArrayList list1 = new ArrayList();&lt;br&gt; addRange(list1, 2);&lt;br&gt; TreeSet set2 = new TreeSet();&lt;br&gt; addRange(set2, 3);&lt;br&gt; LinkedList list2 = new LinkedList();&lt;br&gt; addRange(list2, 5);&lt;br&gt;&lt;br&gt; set1.removeAll(list1);&lt;br&gt; list1.addAll(set2);&lt;br&gt; list2.addAll(list1);&lt;br&gt; set1.removeAll(list2);&lt;br&gt;&lt;br&gt; System.out.println(set1);&lt;br&gt; }&lt;br&gt; static void addRange(Collection col, int   step) {&lt;br&gt; for (int i = step*2; i&amp;lt;=25; i+=step)&lt;br&gt; col.add(new Integer(i));&lt;br&gt; }&lt;br&gt;}&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   The program will fail to compile since operations are   performed on incompatible collection implementations.&lt;br&gt;b.   The program will fail to compile since the TreeSet denoted by set2   has not been given a Comparator to use when   sorting its elements.&lt;br&gt;c.   The program will compile without error, but will throw an UnsupportedOperationException when run.&lt;br&gt;d.   The program will compile without error and will print all   primes below 25 when run.&lt;br&gt;e.   The program will compile without error and will print some   other sequence of numbers when run.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa2q3a1&quot; target=&quot;_top&quot;&gt;11.6&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of these methods are defined in the Collection interface?&lt;br&gt;Select   the three correct answers.&lt;br&gt;a.   add(Object o)&lt;br&gt;b.   retainAll(Collection c)&lt;br&gt;c.   get(int index)&lt;br&gt;d.   iterator()&lt;br&gt;e.   indexOf(Object o)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa2q4a1&quot; target=&quot;_top&quot;&gt;11.7&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   What   will be the output from the following program?&lt;br&gt;import   java.util.*;&lt;br&gt;public   class Iterate {&lt;br&gt; public static void main(String[] args) {&lt;br&gt; List l = new ArrayList();&lt;br&gt; l.add(&amp;quot;A&amp;quot;);   l.add(&amp;quot;B&amp;quot;); l.add(&amp;quot;C&amp;quot;); l.add(&amp;quot;D&amp;quot;);   l.add(&amp;quot;E&amp;quot;);&lt;br&gt; ListIterator i = l.listIterator();&lt;br&gt; i.next(); i.next(); i.next();   i.next();&lt;br&gt; i.remove();&lt;br&gt; i.previous(); i.previous();&lt;br&gt; i.remove();&lt;br&gt; System.out.println(l);&lt;br&gt; };&lt;br&gt;};&lt;br&gt;Select   the one correct answer.&lt;br&gt;a.   It will print [A, B, C, D, E].&lt;br&gt;b.   It will print [A, C, E].&lt;br&gt;c.   It will print [B, D, E].&lt;br&gt;d.   It will print [A, B, D].&lt;br&gt;e.   It will print [B, C, E].&lt;br&gt;f.   It will print throw a NoSuchElementException.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa2q5a1&quot; target=&quot;_top&quot;&gt;11.8&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;   Which   of these methods from the Collection   interface will return the value true if the collection was modified during the   operation?&lt;br&gt;Select   the two correct answers.&lt;br&gt;a.   contains()&lt;br&gt;b.   add()&lt;br&gt;c.   containsAll()&lt;br&gt;d.   retainAll()&lt;br&gt;e.   clear()   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa3q1a1&quot; target=&quot;_top&quot;&gt;11.9&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which of these methods can be called on objects implementing the Map interface?Select the two correct answers.   a.   contains(Object   o)&lt;br&gt;b.   addAll(Collection   c)&lt;br&gt;c.   remove(Object   o)&lt;br&gt;d.   values()&lt;br&gt;e.   toArray()   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa3q2a1&quot; target=&quot;_top&quot;&gt;11.10&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which statements are true about maps?Select the two correct answers.   a.   The return type of the values() method is Set.&lt;br&gt;b.   Changes made in the set view returned by keySet() will   be reflected in the original map.&lt;br&gt;c.   The Map   interface extends the Collection   interface.&lt;br&gt;d.   All keys in a map are unique.&lt;br&gt;e.   All Map   implementations keep the keys sorted.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa3q3a1&quot; target=&quot;_top&quot;&gt;11.11&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which sequence of digits will the following program print?import java.util.*;public class Lists { public static void main(String[] args) { List list = new ArrayList(); list.add(&amp;quot;1&amp;quot;); list.add(&amp;quot;2&amp;quot;); list.add(1, &amp;quot;3&amp;quot;); List list2 = new LinkedList(list); list.addAll(list2); list2 = list.subList(2, 5); list2.clear(); System.out.println(list); }}Select the one correct answer.   a.   [1,   3, 2]&lt;br&gt;b.   [1,   3, 3, 2]&lt;br&gt;c.   [1,   3, 2, 1, 3, 2]&lt;br&gt;d.   [3,   1, 2]&lt;br&gt;e.   [3,   1, 1, 2]&lt;br&gt;f.   None of the above.   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa3q4a1&quot; target=&quot;_top&quot;&gt;11.12&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which of these classes have a comparator() method?Select the two correct answers.   a.   ArrayList&lt;br&gt;b.   HashMap&lt;br&gt;c.   TreeSet&lt;br&gt;d.   HashSet&lt;br&gt;e.   TreeMap   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa3q5a1&quot; target=&quot;_top&quot;&gt;11.13&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which method prototypes are defined in the interface java.util.Map.Entry?Select the two correct answers.   a.   Object   getKey()&lt;br&gt;b.   Object   setKey(Object value)&lt;br&gt;c.   void   remove()&lt;br&gt;d.   Object   getValue()&lt;br&gt;e.   void   setValue(Object value)   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;&lt;a href=&quot;http://faqworldofrastogi.wetpaint.commk:@MSITStore:Z:%5CrahulEbooks%5Cchm+books%5Cjava%5Caddison+wesley++-+a+programmer%27s+guide+to+java+certification.+second+edition.chm::/0201728281_app04lev1sec11.html#ch11qa4q1a1&quot; target=&quot;_top&quot;&gt;11.14&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Given that the objects denoted by the parameters override the equals() and the hashCode() methods appropriately, which return values are possible from the following method?String func(Object x, Object y) { return (x == y) + &amp;quot; &amp;quot; + x.equals(y) + &amp;quot; &amp;quot; + (x.hashCode() == y.hashCode());}Select the two correct answers.   a.   &amp;quot;false   false true&amp;quot;&lt;br&gt;b.   &amp;quot;false   true false&amp;quot;&lt;br&gt;c.   &amp;quot;false   true true&amp;quot;&lt;br&gt;d.   &amp;quot;true   false false&amp;quot;&lt;br&gt;e.   &amp;quot;true   false true&amp;quot;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;11.15&lt;a name=&quot;ch11qa4q2&quot;&gt;&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Insert code into the equalsImpl() method in order to provide a correct implementation of the equals() method.public class Pair { int a, b; public Pair(int a, int b) { this.a = a; this.b = b; } public boolean equals(Object o) { return (this == o) || (o instanceof Pair) &amp;amp;&amp;amp; equalsImpl((Pair) o); } private boolean equalsImpl(Pair o) { // ... PROVIDE IMPLEMENTATION HERE ... }}Select the three correct answers.   a.   return   a == o.a || b == o.b;&lt;br&gt;b.   return   false;&lt;br&gt;c.   return   a &amp;gt;= o.a;&lt;br&gt;d.   return   a == o.a;&lt;br&gt;e.   return   a == o.a &amp;amp;&amp;amp; b == o.b;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;11.16&lt;a name=&quot;ch11qa4q3&quot;&gt;&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which collection implementation is thread-safe?Select the one correct answer.   a.   ArrayList&lt;br&gt;b.   HashSet&lt;br&gt;c.   Vector&lt;br&gt;d.   TreeSet&lt;br&gt;e.   LinkedList   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt;   &lt;b&gt;11.17&lt;a name=&quot;ch11qa4q4&quot;&gt;&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;   &lt;td&gt;Which code provides a correct implementation of the hashCode() method in the following program?import java.util.*;public class Measurement { int count; int accumulated; public Measurement() {} public void record(int v) { count++; accumulated += v; } public int average() { return accumulated/count; } public boolean equals(Object other) { if (this == other) return true; if (!(other instanceof Measurement)) return false; Measurement o = (Measurement) other; if (count != 0 &amp;amp;&amp;amp; o.count != 0) return average() == o.average(); return count == o.count; } public int hashCode() { // ... PROVIDE IMPLEMENTATION HERE ... }}Select the two correct answers.   a.   return   31337;&lt;br&gt;b.   return   accumulated / count;&lt;br&gt;c.   return   (count &amp;lt;&amp;lt; 16) ^ accumulated;&lt;br&gt;d.   return   ~accumulated;&lt;br&gt;e.   return   count == 0 ? 0 : average();   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;  &lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>Java Class File Format</title><link>http://faqworldofrastogi.wetpaint.com/page/Java+Class+File+Format</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/Java+Class+File+Format</guid><pubDate>Thu, 22 Mar 2007 01:26:28 CDT</pubDate><description>&lt;table align=&quot;bottom&quot; cellpadding=&quot;5&quot; class=&quot;wp-border-all&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  &lt;h2 align=&quot;center&quot;&gt;  The class File Format&lt;/h2&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;This chapter describes the Java virtual machine &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format. Each &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file contains the definition of a single class or interface. Although a class or interface need not have an external representation literally contained in a file (for instance, because the class is generated by a class loader), we will colloquially refer to any valid representation of a class or interface as being in the &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;A &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file consists of a stream of 8-bit bytes. All 16-bit, 32-bit, and 64-bit quantities are constructed by reading in two, four, and eight consecutive 8-bit bytes, respectively. Multibyte data items are always stored in big-endian order, where the high bytes come first. In the Java and Java 2 platforms, this format is supported by interfaces &lt;/font&gt;java.io.DataInput&lt;font face=&quot;Times New Roman&quot;&gt; and &lt;/font&gt;java.io.DataOutput&lt;font face=&quot;Times New Roman&quot;&gt; and classes such as &lt;/font&gt;java.io.DataInputStream&lt;font face=&quot;Times New Roman&quot;&gt; and &lt;/font&gt;java.io.DataOutputStream&lt;font face=&quot;Times New Roman&quot;&gt;. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;This chapter defines its own set of data types representing &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file data: The types &lt;/font&gt;u1&lt;font face=&quot;Times New Roman&quot;&gt;, &lt;/font&gt;u2&lt;font face=&quot;Times New Roman&quot;&gt;, and &lt;/font&gt;u4&lt;font face=&quot;Times New Roman&quot;&gt; represent an unsigned one-, two-, or four-byte quantity, respectively. In the Java and Java 2 platforms, these types may be read by methods such as &lt;/font&gt;readUnsignedByte&lt;font face=&quot;Times New Roman&quot;&gt;, &lt;/font&gt;readUnsignedShort&lt;font face=&quot;Times New Roman&quot;&gt;, and &lt;/font&gt;readInt&lt;font face=&quot;Times New Roman&quot;&gt; of the interface &lt;/font&gt;java.io.DataInput&lt;font face=&quot;Times New Roman&quot;&gt;. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;This chapter presents the &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format using pseudostructures written in a C-like structure notation. To avoid confusion with the fields of classes and class instances, etc., the contents of the structures describing the &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format are referred to as &lt;i&gt;items&lt;/i&gt;. Successive items are stored in the &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file sequentially, without padding or alignment. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;&lt;i&gt;Tables&lt;/i&gt;, consisting of zero or more variable-sized items, are used in several &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file structures. Although we use C-like array syntax to refer to table items, the fact that tables are streams of varying-sized structures means that it is not possible to translate a table index directly to a byte offset into the table. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;Where we refer to a data structure as an array, it consists of zero or more contiguous fixed-sized items and can be indexed like an array. &lt;/font&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  &lt;b&gt;&lt;u&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The &lt;/font&gt;&lt;/u&gt;&lt;/b&gt;&lt;b&gt;&lt;u&gt;ClassFile&lt;/u&gt;&lt;/b&gt;&lt;b&gt;&lt;u&gt;&lt;font face=&quot;Times New Roman&quot;&gt; Structure&lt;/font&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  &lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;A &lt;/font&gt;&lt;/b&gt;&lt;b&gt;class&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; file consists of a single &lt;/font&gt;&lt;/b&gt;&lt;b&gt;ClassFile&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; structure: &lt;/font&gt;&lt;/b&gt;&lt;br&gt;ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; } &lt;font face=&quot;Times New Roman&quot;&gt;The items in the &lt;/font&gt;ClassFile&lt;font face=&quot;Times New Roman&quot;&gt; structure are as follows: &lt;/font&gt;&lt;b&gt;magic&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The &lt;/font&gt;magic&lt;font face=&quot;Times New Roman&quot;&gt; item supplies the magic number identifying the &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format; it has the value &lt;/font&gt;&lt;b&gt;0xCAFEBABE&lt;/b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;&lt;b&gt;.&lt;/b&gt; &lt;/font&gt;&lt;b&gt;minor_version&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;, &lt;/font&gt;&lt;/b&gt;&lt;b&gt;major_version&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The values of the &lt;/font&gt;minor_version&lt;font face=&quot;Times New Roman&quot;&gt; and &lt;/font&gt;major_version&lt;font face=&quot;Times New Roman&quot;&gt; items are the minor and major version numbers of this &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file.Together, a major and a minor version number determine the version of the &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format. If a &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file has major version number M and minor version number m, we denote the version of its &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format as M.m. Thus, &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format versions may be ordered lexicographically, for example, 1.5 &amp;lt; 2.0 &amp;lt; 2.1. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;A Java virtual machine implementation can support a &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file format of version v if and only if v lies in some contiguous range Mi.0 &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;v &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;Mj.m. Only Sun can specify what range of versions a Java virtual machine implementation conforming to a certain release level of the Java platform may support. &lt;/font&gt;&lt;b&gt;constant_pool_count&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The value of the &lt;/font&gt;constant_pool_count&lt;font face=&quot;Times New Roman&quot;&gt; item is equal to the number of entries in the &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; table plus one. A &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; index is considered valid if it is greater than zero and less than &lt;/font&gt;constant_pool_count&lt;font face=&quot;Times New Roman&quot;&gt;, with the exception for constants of type &lt;/font&gt;long&lt;font face=&quot;Times New Roman&quot;&gt; and &lt;/font&gt;double&lt;font face=&quot;Times New Roman&quot;&gt; noted in &lt;u&gt;&amp;sect;4.4.5&lt;/u&gt;. &lt;/font&gt;&lt;b&gt;constant_pool[]&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; is a table of structures &lt;u&gt;(&amp;sect;4.4)&lt;/u&gt; representing various string constants, class and interface names, field names, and other constants that are referred to within the &lt;/font&gt;ClassFile&lt;font face=&quot;Times New Roman&quot;&gt; structure and its substructures. The format of each &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; table entry is indicated by its first &amp;quot;tag&amp;quot; byte. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; table is indexed from &lt;/font&gt;1&lt;font face=&quot;Times New Roman&quot;&gt; to &lt;/font&gt;constant_pool_count&lt;font face=&quot;Times New Roman&quot;&gt;-&lt;/font&gt;1&lt;font face=&quot;Times New Roman&quot;&gt;. &lt;/font&gt;&lt;br&gt;&lt;b&gt;access_flags&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The value of the &lt;/font&gt;access_flags&lt;font face=&quot;Times New Roman&quot;&gt; item is a mask of flags used to denote access permissions to and properties of this class or interface. The interpretation of each flag, when set, is as shown in &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;&lt;u&gt;Table 4.1&lt;/u&gt;.&lt;/font&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;&lt;/font&gt; &lt;br&gt;&lt;table cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;&lt;b&gt;Flag Name&lt;/b&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;&lt;b&gt;Value&lt;/b&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;&lt;b&gt;Interpretation&lt;/b&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  ACC_PUBLIC&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  0x0001&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;Declared &lt;/font&gt;public&lt;font face=&quot;Times New Roman&quot;&gt;; may be accessed from outside its package. &lt;/font&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  ACC_FINAL&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  0x0010&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;Declared &lt;/font&gt;final&lt;font face=&quot;Times New Roman&quot;&gt;; no subclasses allowed. &lt;/font&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  ACC_SUPER&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  0x0020&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;Treat superclass methods specially when invoked by the &lt;i&gt;invokespecial&lt;/i&gt; instruction. &lt;/font&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  ACC_INTERFACE&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  0x0200&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;Is an interface, not a class. &lt;/font&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  ACC_ABSTRACT&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  0x0400&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;Declared &lt;/font&gt;abstract&lt;font face=&quot;Times New Roman&quot;&gt;; may not be instantiated. &lt;/font&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  &lt;font face=&quot;Times New Roman&quot;&gt;An interface is distinguished by its &lt;/font&gt;ACC_INTERFACE&lt;font face=&quot;Times New Roman&quot;&gt; flag being set. If its &lt;/font&gt;ACC_INTERFACE&lt;font face=&quot;Times New Roman&quot;&gt; flag is not set, this &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file defines a class, not an interface. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;If the &lt;/font&gt;ACC_INTERFACE&lt;font face=&quot;Times New Roman&quot;&gt; flag of this &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file is set, its &lt;/font&gt;ACC_ABSTRACT&lt;font face=&quot;Times New Roman&quot;&gt; flag must also be set &lt;u&gt;(&amp;sect;2.13.1)&lt;/u&gt; and its &lt;/font&gt;ACC_PUBLIC&lt;font face=&quot;Times New Roman&quot;&gt; flag may be set. Such a &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file may not have any of the other flags in &lt;u&gt;Table 4.1&lt;/u&gt; set. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;If the &lt;/font&gt;ACC_INTERFACE&lt;font face=&quot;Times New Roman&quot;&gt; flag of this &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file is not set, it may have any of the other flags in &lt;/font&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#75734&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;font face=&quot;Times New Roman&quot;&gt;Table 4.1&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Times New Roman&quot;&gt; set. However, such a &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file cannot have both its &lt;/font&gt;ACC_FINAL&lt;font face=&quot;Times New Roman&quot;&gt; and &lt;/font&gt;ACC_ABSTRACT&lt;font face=&quot;Times New Roman&quot;&gt; flags set &lt;u&gt;(&amp;sect;2.8.2)&lt;/u&gt;. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The setting of the &lt;/font&gt;ACC_SUPER&lt;font face=&quot;Times New Roman&quot;&gt; flag indicates which of two alternative semantics for its &lt;i&gt;invoke special&lt;/i&gt; instruction the Java virtual machine is to express; the &lt;/font&gt;ACC_SUPER&lt;font face=&quot;Times New Roman&quot;&gt; flag exists for backward compatibility for code compiled by Sun&amp;#39;s older compilers for the Java programming language. All new implementations of the Java virtual machine should implement the semantics for &lt;i&gt;invoke special&lt;/i&gt; documented in this specification. All new compilers to the instruction set of the Java virtual machine should set the &lt;/font&gt;ACC_SUPER&lt;font face=&quot;Times New Roman&quot;&gt; flag. Sun&amp;#39;s older compilers generated &lt;/font&gt;ClassFile&lt;font face=&quot;Times New Roman&quot;&gt; flags with &lt;/font&gt;ACC_SUPER&lt;font face=&quot;Times New Roman&quot;&gt; unset. Sun&amp;#39;s older Java virtual machine implementations ignore the flag if it is set. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;All bits of the &lt;/font&gt;access_flags&lt;font face=&quot;Times New Roman&quot;&gt; item not assigned in &lt;/font&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#75734&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;font face=&quot;Times New Roman&quot;&gt;Table 4.1&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Times New Roman&quot;&gt; are reserved for future use. They should be set to zero in generated &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; files and should be ignored by Java virtual machine implementations. &lt;/font&gt;&lt;br&gt;&lt;b&gt;this_class&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The value of the &lt;/font&gt;this_class&lt;font face=&quot;Times New Roman&quot;&gt; item must be a valid index into the &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; table. The &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; entry at that index must be a &lt;/font&gt;CONSTANT_Class_info&lt;font face=&quot;Times New Roman&quot;&gt; &lt;u&gt;(&amp;sect;4.4.1)&lt;/u&gt; structure representing the class or interface defined by this &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file.&lt;/font&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;b&gt;super_class&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;For a class, the value of the &lt;/font&gt;super_class&lt;font face=&quot;Times New Roman&quot;&gt; item either must be zero or must be a valid index into the &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; table. If the value of the &lt;/font&gt;super_class&lt;font face=&quot;Times New Roman&quot;&gt; item is nonzero, the &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; entry at that index must be a &lt;/font&gt;CONSTANT_Class_info&lt;font face=&quot;Times New Roman&quot;&gt; &lt;u&gt;(&amp;sect;4.4.1)&lt;/u&gt; structure representing the direct superclass of the class defined by this &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file. Neither the direct superclass nor any of its superclasses may be a &lt;/font&gt;final&lt;font face=&quot;Times New Roman&quot;&gt; class. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;If the value of the &lt;/font&gt;super_class&lt;font face=&quot;Times New Roman&quot;&gt; item is zero, then this &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file must represent the class &lt;/font&gt;Object&lt;font face=&quot;Times New Roman&quot;&gt;, the only class or interface without a direct superclass. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;For an interface, the value of the &lt;/font&gt;super_class&lt;font face=&quot;Times New Roman&quot;&gt; item must always be a valid index into the &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; table. The &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; entry at that index must be a &lt;/font&gt;CONSTANT_Class_info&lt;font face=&quot;Times New Roman&quot;&gt; structure representing the class &lt;/font&gt;Object&lt;font face=&quot;Times New Roman&quot;&gt;.&lt;/font&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;b&gt;interfaces_count&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The value of the &lt;/font&gt;interfaces_count&lt;font face=&quot;Times New Roman&quot;&gt; item gives the number of direct superinterfaces of this class or interface type.&lt;/font&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;b&gt;interfaces[]&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;Each value in the &lt;/font&gt;interfaces&lt;font face=&quot;Times New Roman&quot;&gt; array must be a valid index into the &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; table. The &lt;/font&gt;constant_pool&lt;font face=&quot;Times New Roman&quot;&gt; entry at each value of &lt;/font&gt;interfaces[&lt;i&gt;&lt;font face=&quot;Times New Roman&quot;&gt;i&lt;/font&gt;&lt;/i&gt;]&lt;font face=&quot;Times New Roman&quot;&gt;, where &lt;/font&gt;0&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;i &amp;lt; &lt;/font&gt;interfaces_count&lt;font face=&quot;Times New Roman&quot;&gt;, must be a &lt;/font&gt;CONSTANT_Class_info&lt;font face=&quot;Times New Roman&quot;&gt; &lt;u&gt;(&amp;sect;4.4.1)&lt;/u&gt; structure representing an interface that is a direct superinterface of this class or interface type, in the left-to-right order given in the source for the type. &lt;/font&gt;&lt;br&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;fields_count&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The value of the &lt;/font&gt;fields_count&lt;font face=&quot;Times New Roman&quot;&gt; item gives the number of &lt;/font&gt;field_info&lt;font face=&quot;Times New Roman&quot;&gt; structures in the &lt;/font&gt;fields&lt;font face=&quot;Times New Roman&quot;&gt; table. The &lt;/font&gt;field_info &lt;font face=&quot;Times New Roman&quot;&gt;&lt;u&gt;(&amp;sect;4.5)&lt;/u&gt; structures represent all fields, both class variables and instance variables, declared by this lass or interface type. &lt;/font&gt;&lt;br&gt;&lt;b&gt;fields[]&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;Each value in the &lt;/font&gt;fields&lt;font face=&quot;Times New Roman&quot;&gt; table must be a &lt;/font&gt;field_info&lt;font face=&quot;Times New Roman&quot;&gt; &lt;u&gt;(&amp;sect;4.5)&lt;/u&gt; structure giving a complete description of a field in this class or interface. The &lt;/font&gt;fields&lt;font face=&quot;Times New Roman&quot;&gt; table includes only those fields that are declared by this class or interface. It does not include items representing fields that are inherited from superclasses or superinterfaces. &lt;/font&gt;&lt;b&gt;methods_count&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The value of the &lt;/font&gt;methods_count&lt;font face=&quot;Times New Roman&quot;&gt; item gives the number of &lt;/font&gt;method_info&lt;font face=&quot;Times New Roman&quot;&gt; structures in the &lt;/font&gt;methods&lt;font face=&quot;Times New Roman&quot;&gt; table.&lt;/font&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;b&gt;methods[]&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;Times New Roman&quot;&gt;Each value in the &lt;/font&gt;methods&lt;font face=&quot;Times New Roman&quot;&gt; table must be a &lt;/font&gt;method_info&lt;font face=&quot;Times New Roman&quot;&gt; &lt;u&gt;(&amp;sect;4.6)&lt;/u&gt; structure giving a complete description of a method in this class or interface. If the method is not &lt;/font&gt;native&lt;font face=&quot;Times New Roman&quot;&gt; or &lt;/font&gt;abstract&lt;font face=&quot;Times New Roman&quot;&gt;, the Java virtual machine instructions implementing the method are also supplied. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The &lt;/font&gt;method_info&lt;font face=&quot;Times New Roman&quot;&gt; structures represent all methods declared by this class or interface type, including instance methods, class (&lt;/font&gt;static&lt;font face=&quot;Times New Roman&quot;&gt;) methods, instance initialization methods &lt;u&gt;(&amp;sect;3.9)&lt;/u&gt;, and any class or interface initialization method &lt;u&gt;(&amp;sect;3.9)&lt;/u&gt;. The &lt;/font&gt;methods&lt;font face=&quot;Times New Roman&quot;&gt; table does not include items representing methods that are inherited from superclasses or superinterfaces. &lt;/font&gt;&lt;br&gt;&lt;b&gt;attributes_count&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The value of the &lt;/font&gt;attributes_count&lt;font face=&quot;Times New Roman&quot;&gt; item gives the number of attributes &lt;/font&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#43817&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;font face=&quot;Times New Roman&quot;&gt;(&amp;sect;4.7)&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Times New Roman&quot;&gt; in the &lt;/font&gt;attributes&lt;font face=&quot;Times New Roman&quot;&gt; table of this class. &lt;/font&gt;&lt;br&gt;&lt;b&gt;attributes[]&lt;/b&gt;&lt;b&gt;&lt;font face=&quot;Times New Roman&quot;&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font face=&quot;Times New Roman&quot;&gt;Each value of the &lt;/font&gt;attributes&lt;font face=&quot;Times New Roman&quot;&gt; table must be an attribute structure &lt;/font&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#43817&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;font face=&quot;Times New Roman&quot;&gt;(&amp;sect;4.7)&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Times New Roman&quot;&gt;. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;The only attributes defined by this specification as appearing in the &lt;/font&gt;attributes&lt;font face=&quot;Times New Roman&quot;&gt; table of a &lt;/font&gt;ClassFile&lt;font face=&quot;Times New Roman&quot;&gt; structure are the &lt;/font&gt;SourceFile&lt;font face=&quot;Times New Roman&quot;&gt; attribute &lt;/font&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#79868&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;font face=&quot;Times New Roman&quot;&gt;(&amp;sect;4.7.7)&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Times New Roman&quot;&gt; and the &lt;/font&gt;Deprecated&lt;font face=&quot;Times New Roman&quot;&gt; &lt;u&gt;(&amp;sect;4.7.10)&lt;/u&gt; attribute. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;A Java virtual machine implementation is required to silently ignore any or all attributes in the &lt;/font&gt;attributes&lt;font face=&quot;Times New Roman&quot;&gt; table of a &lt;/font&gt;ClassFile&lt;font face=&quot;Times New Roman&quot;&gt; structure that it does not recognize. Attributes not defined in this specification are not allowed to affect the semantics of the &lt;/font&gt;class&lt;font face=&quot;Times New Roman&quot;&gt; file, but only to provide additional descriptive information &lt;u&gt;(&amp;sect;4.7.1)&lt;/u&gt;. &lt;/font&gt;&lt;font face=&quot;Times New Roman&quot;&gt;&lt;/font&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>java World</title><link>http://faqworldofrastogi.wetpaint.com/page/java+World</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/java+World</guid><comments>rahul</comments><pubDate>Sat, 10 Mar 2007 23:36:12 CST</pubDate><description>&lt;b&gt;1)What is OOPs?&lt;/b&gt; &lt;br&gt;Ans: Object oriented programming organizes a program around its data,i.e.,objects and a set of well defined interfaces to that data.An object-oriented program can be characterized as data controlling access to code.&lt;br&gt;&lt;b&gt;2)what is the difference between Procedural and OOPs?&lt;/b&gt;&lt;br&gt;Ans: a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOPs program, unit of program is object, which is nothing but combination of data and code. b) In procedural program,data is exposed to the whole program whereas in OOPs program,it is accessible with in the object and which in turn assures the security of the code. &lt;br&gt;&lt;b&gt;3)What are Encapsulation, Inheritance and Polymorphism?&lt;/b&gt; &lt;br&gt;Ans: Encapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse. Inheritance is the process by which one object acquires the properties of another object. Polymorphism is the feature that allows one interface to be used for general class actions. &lt;br&gt;&lt;b&gt;4)What is the difference between Assignment and Initialization?&lt;/b&gt;&lt;br&gt;Ans: Assignment can be done as many times as desired whereas initialization can be done only once. &lt;br&gt;&lt;b&gt;5)What are Class, Constructor and Primitive data types?&lt;/b&gt;&lt;br&gt;Ans: Class is a template for multiple objects with similar features and it is a blue print for objects. It defines a type of object according to the data the object can hold and the operations the object can perform. Constructor is a special kind of method that determines how an object is initialized when created. Primitive data types are 8 types and they are: byte, short, int, long float, double boolean char &lt;b&gt;6)What is an Object and how do you allocate memory to it?&lt;/b&gt;&lt;br&gt;Ans: Object is an instance of a class and it is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data. When an object is created using new operator, memory is allocated to it.&lt;br&gt;&lt;b&gt;7)What is the difference between constructor and method?&lt;/b&gt;&lt;br&gt;Ans: Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.&lt;br&gt;&lt;b&gt;8)What are methods and how are they defined? &lt;/b&gt;Ans: Methods are functions that operate on instances of classes in which they are defined. Objects can communicate with each other using methods and can call methods in other classes. Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method&amp;#39;s signature is a combination of the first three parts mentioned above. &lt;br&gt;&lt;b&gt;9)What is the use of bin and lib in JDK? &lt;/b&gt;&lt;br&gt;Ans: Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages. &lt;br&gt;&lt;b&gt;10)What is casting?&lt;/b&gt;&lt;br&gt;Ans: Casting is used to convert the value of one type to another.&lt;br&gt;&lt;b&gt;11)How many ways can an argument be passed to a subroutine and explain them?&lt;/b&gt; &lt;br&gt;Ans: An argument can be passed in two ways. They are passing by value and passing by reference. Passing by value: This method copies the value of an argument into the formal parameter of the subroutine. Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter. &lt;br&gt;&lt;b&gt;12)What is the difference between an argument and a parameter? &lt;/b&gt;&lt;br&gt;Ans: While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments. &lt;br&gt;&lt;b&gt;13)What are different types of access modifiers? &lt;/b&gt;&lt;br&gt;Ans: public: Any thing declared as public can be accessed from anywhere. private: Any thing declared as private can&amp;#39;t be seen outside of its class. protected: Any thing declared as protected can be accessed by classes in the same package and subclasses in the other packages. default modifier : Can be accessed only to classes in the same package. &lt;br&gt;&lt;b&gt;14)What is final, finalize() and finally?&lt;/b&gt;&lt;br&gt;Ans: &lt;b&gt;final :&lt;/b&gt; final keyword can be used for class, method and variables. A final class cannot be subclassed and it prevents other programmers from subclassing a secure class to invoke insecure methods. A final method can&amp;#39; t be overridden A final variable can&amp;#39;t change from its initialized value. &lt;br&gt;&lt;b&gt;finalize( ) :&lt;/b&gt; finalize( ) method is used just before an object is destroyed and can be called just prior to garbage collection. &lt;br&gt;&lt;b&gt;finally : &lt;/b&gt;finally, a key word used in exception handling, creates a block of code that will be executed after a try/catch block has completed and before the code following the try/catch block. The finally block will execute whether or not an exception is thrown. For example, if a method opens a file upon exit, then you will not want the code that closes the file to be bypassed by the exception-handling mechanism. This finally keyword is designed to address this contingency. &lt;br&gt;&lt;b&gt;15)What is UNICODE?&lt;/b&gt; &lt;br&gt;Ans: Unicode is used for internal representation of characters and strings and it uses 16 bits to represent each other.&lt;br&gt;&lt;b&gt;16)What is Garbage Collection and how to call it explicitly?&lt;/b&gt;&lt;br&gt;Ans: When an object is no longer referred to by any variable, java automatically reclaims memory used by that object. This is known as garbage collection. System.gc() method may be used to call it explicitly. &lt;br&gt;&lt;b&gt;17)What is finalize() method ?&lt;/b&gt;&lt;br&gt;Ans: finalize () method is used just before an object is destroyed and can be called just prior to garbage collection. &lt;br&gt;&lt;b&gt;18)What are Transient and Volatile Modifiers?&lt;/b&gt;&lt;br&gt;Ans: Transient: The transient modifier applies to variables only and it is not stored as part of its object&amp;#39;s Persistent state. Transient variables are not serialized. Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program. &lt;br&gt;&lt;b&gt;19)What is method overloading and method overriding?&lt;/b&gt;&lt;br&gt;Ans: Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding. &lt;br&gt;&lt;b&gt;20)What is difference between overloading and overriding?&lt;/b&gt;&lt;br&gt;Ans: a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method. &lt;br&gt;b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass. &lt;br&gt;c) In overloading, separate methods share the same name whereas in overriding,subclass method replaces the superclass. &lt;br&gt;d) Overloading must have different method signatures whereas overriding must have same signature. &lt;br&gt;&lt;b&gt;21) What is meant by Inheritance and what are its advantages?&lt;/b&gt;&lt;br&gt;Ans: Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by subclasses. &lt;br&gt;&lt;b&gt;22)What is the difference between this() and super()?&lt;/b&gt;&lt;br&gt;Ans: this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor. &lt;br&gt;&lt;b&gt;23)What is the difference between superclass and subclass?&lt;/b&gt;&lt;br&gt;Ans: A super class is a class that is inherited whereas sub class is a class that does the inheriting. &lt;br&gt;&lt;b&gt;24) What modifiers may be used with top-level class?&lt;/b&gt;&lt;br&gt;Ans: public, abstract and final can be used for top-level class. &lt;br&gt;&lt;b&gt;25)What are inner class and anonymous class?&lt;/b&gt;&lt;br&gt;Ans: &lt;b&gt;Inner class :&lt;/b&gt; classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. &lt;br&gt;&lt;b&gt;Anonymous class : &lt;/b&gt;Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors. &lt;br&gt;&lt;b&gt;26)What is a package? &lt;/b&gt;&lt;br&gt;Ans: A package is a collection of classes and interfaces that provides a high-level layer of access protection and name space management. &lt;br&gt;&lt;b&gt;27) What is a reflection package? &lt;/b&gt;&lt;br&gt;Ans: java.lang.reflect package has the ability to analyze itself in runtime.&lt;br&gt;&lt;b&gt;28) What is interface and its use? &lt;/b&gt;&lt;br&gt;Ans: Interface is similar to a class which may contain method&amp;#39;s signature only but not bodies and it is a formal set of method and constant declarations that must be defined by the class that implements it. Interfaces are useful for: a)Declaring methods that one or more classes are expected to implement b)Capturing similarities between unrelated classes without forcing a class relationship. c)Determining an object&amp;#39;s programming interface without revealing the actual body of the class.&lt;br&gt;29) What is an abstract class? Ans: An abstract class is a class designed with implementation gaps for subclasses to fill in and is deliberately incomplete.&lt;br&gt;30) What is the difference between Integer and int?&lt;br&gt;Ans: a) Integer is a class defined in the java.lang package, whereas int is a primitive data type defined in the Java language itself. Java does not automatically convert from one to the other. b) Integer can be used as an argument for a method that requires an object, whereas int can be used for calculations. &lt;br&gt;31) What is a cloneable interface and how many methods does it contain? Ans- It is not having any method because it is a TAGGED or MARKER interface. &lt;br&gt;32) What is the difference between abstract class and interface? Ans: a) All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract method and others may be concrete or abstract. b) In abstract class, key word abstract must be used for the methods whereas interface we need not use that keyword for the methods. c) Abstract class must have subclasses whereas interface can&amp;#39;t have subclasses. &lt;br&gt;33) Can you have an inner class inside a method and what variables can you access?&lt;br&gt;Ans: Yes, we can have an inner class inside a method and final variables can be accessed. &lt;br&gt;34) What is the difference between String and String Buffer?&lt;br&gt;Ans: a) String objects are constants and immutable whereas StringBuffer objects are not. b) String class supports constant strings whereas StringBuffer class supports growable and modifiable strings.&lt;br&gt;35) What is the difference between Array and vector?&lt;br&gt;Ans: Array is a set of related data type and static whereas vector is a growable array of objects and dynamic. &lt;br&gt;36) What is the difference between exception and error? &lt;br&gt;Ans: The exception class defines mild error conditions that your program encounters. Ex: Arithmetic Exception, FilenotFound exception Exceptions can occur when -- try to open the file, which does not exist -- the network connection is disrupted -- operands being manipulated are out of prescribed ranges -- the class file you are interested in loading is missing The error class defines serious error conditions that you should not attempt to recover from. In most cases it is advisable to let the program terminate when such an error is encountered. Ex: Running out of memory error, Stack overflow error. &lt;br&gt;37) What is the difference between process and thread? &lt;br&gt;Ans: Process is a program in execution whereas thread is a separate path of execution in a program.&lt;br&gt;38) What is multithreading and what are the methods for inter-thread communication and what is the class in which these methods are defined? &lt;br&gt;Ans: Multithreading is the mechanism in which more than one thread run independent of each other within the process. wait (), notify () and notifyAll() methods can be used for inter-thread communication and these methods are in Object class. wait( ) : When a thread executes a call to wait( ) method, it surrenders the object lock and enters into a waiting state. notify( ) or notifyAll( ) : To remove a thread from the waiting state, some other thread must make a call to notify( ) or notifyAll( ) method on the same object. &lt;br&gt;39) What is the class and interface in java to create thread and which is the most advantageous method? &lt;br&gt;Ans: Thread class and Runnable interface can be used to create threads and using Runnable interface is the most advantageous method to create threads because we need not extend thread class here.&lt;br&gt;40) What are the states associated in the thread?&lt;br&gt;Ans: Thread contains ready, running, waiting and dead states. &lt;br&gt;41) What is synchronization? &lt;br&gt;Ans: Synchronization is the mechanism that ensures that only one thread is accessed the resources at a time.&lt;br&gt;42) When you will synchronize a piece of your code? &lt;br&gt;Ans: When you expect your code will be accessed by different threads and these threads may change a particular data causing data corruption. &lt;br&gt;43) What is deadlock?&lt;br&gt;Ans: When two threads are waiting each other and can&amp;#39;t precede the program is said to be deadlock.&lt;br&gt;44) What is daemon thread and which method is used to create the daemon thread?&lt;br&gt;Ans: Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system. setDaemon method is used to create a daemon thread. &lt;br&gt;45) Are there any global variables in Java, which can be accessed by other part of your program? &lt;br&gt;Ans: No, it is not the main method in which you define variables. Global variables is not possible because concept of encapsulation is eliminated here. &lt;br&gt;46)What is an applet? &lt;br&gt;Ans: Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser. &lt;br&gt;47)What is the difference between applications and applets? &lt;br&gt;Ans: a)Application must be run on local machine whereas applet needs no explicit installation on local machine. b)Application must be run explicitly within a java-compatible virtual machine whereas applet loads and runs itself automatically in a java-enabled browser. d)Application starts execution with its main method whereas applet starts execution with its init method. e)Application can run with or without graphical user interface whereas applet must run within a graphical user interface. &lt;br&gt;48)How does applet recognize the height and width? &lt;br&gt;Ans:Using getParameters() method. &lt;br&gt;49)When do you use codebase in applet?&lt;br&gt;Ans:When the applet class file is not in the same directory, codebase is used. &lt;br&gt;50)What is the lifecycle of an applet? &lt;br&gt;Ans:init( ) method - Can be called when an applet is first loaded start( ) method - Can be called each time an applet is started paint( ) method - Can be called when the applet is minimized or maximized stop( ) method - Can be used when the browser moves off the applet&amp;#39;s page destroy( ) method - Can be called when the browser is finished with the applet &lt;br&gt;51)How do you set security in applets?&lt;br&gt;Ans: using setSecurityManager() method &lt;br&gt;52) What is an event and what are the models available for event handling?&lt;br&gt;Ans: An event is an event object that describes a state of change in a source. In other words, event occurs when an action is generated, like pressing button, clicking mouse, selecting a list, etc. There are two types of models for handling events and they are: a) event-inheritance model and b) event-delegation model &lt;br&gt;53) What are the advantages of the model over the event-inheritance model? &lt;br&gt;Ans: The event-delegation model has two advantages over the event-inheritance model. They are: a)It enables event handling by objects other than the ones that generate the events. This allows a clean separation between a component&amp;#39;s design and its use. b)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 be repeatedly process unhandled events as is the case of the event-inheritance.&lt;br&gt;54)What is source and listener ? &lt;br&gt;Ans: source : A source is an object that generates an event. This occurs when the internal state of that object changes in some way. listener : A listener is an object that is notified when an event occurs. It has two major requirements. First, it must have been registered with one or more sources to receive notifications about specific types of events. Second, it must implement methods to receive and process these notifications.&lt;br&gt;55) What is adapter class? &lt;br&gt;Ans: An adapter class provides an empty implementation of all methods in an event listener interface. Adapter classes are useful when you want to receive and process only some of the events that are handled by a particular event listener interface. You can define a new class to act listener by extending one of the adapter classes and implementing only those events in which you are interested. For example, the MouseMotionAdapter class has two methods, mouseDragged( )and mouseMoved(). The signatures of these empty are exactly as defined in the MouseMotionListener interface. If you are interested in only mouse drag events, then you could simply extend MouseMotionAdapter and implement mouseDragged( ) . &lt;br&gt;56)What is meant by controls and what are different types of controls in AWT?&lt;br&gt;Ans: Controls are components that allow a user to interact with your application and the AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components. These controls are subclasses of Component. &lt;br&gt;57) What is the difference between choice and list? &lt;br&gt;Ans: A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.&lt;br&gt;58) What is the difference between scrollbar and scrollpane?&lt;br&gt;Ans: A Scrollbar is a Component, but not a Container whereas Scrollpane is a Conatiner and handles its own events and perform its own scrolling.&lt;br&gt;59) What is a layout manager and what are different types of layout managers available in java.awt? &lt;br&gt;Ans: A layout manager is an object that is used to organize components in a container. The different layouts are available are FlowLayout, BorderLayout, CardLayout, GridLayout and GridBagLayout. &lt;br&gt;60) How are the elements of different layouts organized? &lt;br&gt;Ans: FlowLayout: The elements of a FlowLayout are organized in a top to bottom, left to right fashion. BorderLayout: The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container. CardLayout: The elements of a CardLayout are stacked, on top of the other, like a deck of cards. GridLayout: The elements of a GridLayout are of equal size and are laid out using the square of a grid. GridBagLayout: The elements of a GridBagLayout are organized according to a grid. However, the elements are of different size and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes. &lt;br&gt;61) Which containers use a Border layout as their default layout?&lt;br&gt;Ans: Window, Frame and Dialog classes use a BorderLayout as their layout. &lt;br&gt;62) Which containers use a Flow layout as their default layout?&lt;br&gt;Ans: Panel and Applet classes use the FlowLayout as their default layout.&lt;br&gt;63) What are wrapper classes?&lt;br&gt;Ans: Wrapper classes are classes that allow primitive types to be accessed as objects.&lt;br&gt;64) What are Vector, Hashtable, LinkedList and Enumeration?&lt;br&gt;Ans: Vector : The Vector class provides the capability to implement a growable array of objects. Hashtable : The Hashtable class implements a Hashtable data structure. A Hashtable indexes and stores objects in a dictionary using hash codes as the object&amp;#39;s keys. Hash codes are integer values that identify objects. LinkedList: Removing or inserting elements in the middle of an array can be done using LinkedList. A LinkedList stores each object in a separate link whereas an array stores object references in consecutive locations. Enumeration: An object that implements the Enumeration interface generates a series of elements, one at a time. It has two methods, namely hasMoreElements( ) and nextElement( ). HasMoreElemnts( ) tests if this enumeration has more elements and nextElement method returns successive elements of the series. &lt;br&gt;65) What is the difference between set and list? &lt;br&gt;Ans: Set stores elements in an unordered way but does not contain duplicate elements, whereas list stores elements in an ordered way but may contain duplicate elements. &lt;br&gt;66) What is a stream and what are the types of Streams and classes of the Streams? &lt;br&gt;Ans: A Stream is an abstraction that either produces or consumes information. There are two types of Streams and they are: Byte Streams: Provide a convenient means for handling input and output of bytes. Character Streams: Provide a convenient means for handling input &amp;amp; output of characters. Byte Streams classes: Are defined by using two abstract classes, namely InputStream and OutputStream. Character Streams classes: Are defined by using two abstract classes, namely Reader and Writer. &lt;br&gt;67) What is the difference between Reader/Writer and InputStream/Output Stream? &lt;br&gt;Ans: The Reader/Writer class is character-oriented and the InputStream/OutputStream class is byte-oriented. &lt;br&gt;68) What is an I/O filter? &lt;br&gt;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.&lt;br&gt;69) What is serialization and deserialization? &lt;br&gt;Ans: Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects. &lt;br&gt;70) What is JDBC? &lt;br&gt;Ans: JDBC is a set of Java API for executing SQL statements. This API consists of a set of classes and interfaces to enable programs to write pure Java Database applications. &lt;br&gt;71) What are drivers available?&lt;br&gt;Ans: a) JDBC-ODBC Bridge driver b) Native API Partly-Java driver c) JDBC-Net Pure Java driver d) Native-Protocol Pure Java driver&lt;br&gt;72) What is the difference between JDBC and ODBC? &lt;br&gt;Ans: a) OBDC is for Microsoft and JDBC is for Java applications. b) ODBC can&amp;#39;t be directly used with Java because it uses a C interface. c) ODBC makes use of pointers which have been removed totally from Java. d) ODBC mixes simple and advanced features together and has complex options for simple queries. But JDBC is designed to keep things simple while allowing advanced capabilities when required. e) ODBC requires manual installation of the ODBC driver manager and driver on all client machines. JDBC drivers are written in Java and JDBC code is automatically installable, secure, and portable on all platforms. f) JDBC API is a natural Java interface and is built on ODBC. JDBC retains some of the basic features of ODBC. &lt;br&gt;73) What are the types of JDBC Driver Models and explain them?&lt;br&gt;Ans: There are two types of JDBC Driver Models and they are: a) Two tier model and b) Three tier model Two tier model: In this model, Java applications interact directly with the database. A JDBC driver is required to communicate with the particular database management system that is being accessed. SQL statements are sent to the database and the results are given to user. This model is referred to as client/server configuration where user is the client and the machine that has the database is called as the server. Three tier model: A middle tier is introduced in this model. The functions of this model are: a) Collection of SQL statements from the client and handing it over to the database, b) Receiving results from database to the client and c) Maintaining control over accessing and updating of the above.&lt;br&gt;74) What are the steps involved for making a connection with a database or how do you connect to a database? &lt;br&gt;Ans: &lt;br&gt;a) Loading the driver : To load the driver, Class.forName( ) method is used. Class.forName(&amp;quot;sun.jdbc.odbc.JdbcOdbcDriver&amp;quot;); When the driver is loaded, it registers itself with the java.sql.DriverManager class as an available database driver.&lt;br&gt;b) Making a connection with database : To open a connection to a given database, DriverManager.getConnection( ) method is used. Connection con = DriverManager.getConnection (&amp;quot;jdbc:odbc:somedb&amp;quot;, &amp;quot;user&amp;quot;, &amp;quot;password&amp;quot;); &lt;br&gt;c) Executing SQL statements : To execute a SQL query, java.sql.statements class is used. createStatement( ) method of Connection to obtain a new Statement object. Statement stmt = con.createStatement( ); A query that returns data can be executed using the executeQuery( ) method of Statement. This method executes the statement and returns a java.sql.ResultSet that encapsulates the retrieved data: ResultSet rs = stmt.executeQuery(&amp;quot;SELECT * FROM some table&amp;quot;); &lt;br&gt;d) Process the results : ResultSet returns one row at a time. Next( ) method of ResultSet object can be called to move to the next row. The getString( ) and getObject( ) methods are used for retrieving column values: while(rs.next( ) ) { String event = rs.getString(&amp;quot;event&amp;quot;); Object count = (Integer) rs.getObject(&amp;quot;count&amp;quot;); &lt;br&gt;75) What type of driver did you use in project?&lt;br&gt;Ans: JDBC-ODBC Bridge driver (is a driver that uses native(C language) libraries and makes calls to an existing ODBC driver to access a database engine).&lt;br&gt;76) What are the types of statements in JDBC?&lt;br&gt;Ans: Statement -- To be used createStatement() method for executing single SQL statement PreparedStatement -- To be used preparedStatement() method for executing same SQL statement over and over CallableStatement -- To be used prepareCall( ) method for multiple SQL statements over and over &lt;br&gt;77) What is stored procedure? &lt;br&gt;Ans: Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task. Stored Procedures are used to encapsulate a set of operations or queries to execute on database. Stored procedures can be compiled and executed with different parameters and results and may have any combination of input/output parameters.&lt;br&gt;78) How to create and call stored procedures? &lt;br&gt;Ans: To create stored procedures: Create procedure procedurename (specify in, out and in out parameters) BEGIN Any multiple SQL statement; END; To call stored procedures: CallableStatement csmt = con.prepareCall(&amp;quot;{call procedure name(?,?)}&amp;quot;); csmt.registerOutParameter(column no., data type); csmt.setInt(column no., column name) csmt.execute( ); &lt;br&gt;79) What is servlet?&lt;br&gt;Ans: Servlets are modules that extend request/response-oriented servers, such as java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a company&amp;#39;s order database.&lt;br&gt;80) What are the classes and interfaces for servlets? &lt;br&gt;Ans: There are two packages in servlets and they are javax.servlet and javax.servlet.http. Javax.servlet contains: Interfaces Classes Servlet Generic Servlet ServletRequest ServletInputStream ServletResponse ServletOutputStream ServletConfig ServletException ServletContext UnavailableException SingleThreadModel Javax.servlet.http contains: Interfaces Classes HttpServletRequest Cookie HttpServletResponse HttpServlet HttpSession HttpSessionBindingEvent HttpSessionCintext HttpUtils HttpSeesionBindingListener &lt;br&gt;81) What is the difference between an applet and a servlet? &lt;br&gt;Ans: a) Servlets are to servers what applets are to browsers. b) Applets must have graphical user interfaces whereas servlets have no graphical user interfaces. &lt;br&gt;82) What is the difference between doPost and doGet methods?&lt;br&gt;Ans: a) doGet() method is used to get information, while doPost( ) method is used for posting information. b) doGet() requests can&amp;#39;t send large amount of information and is limited to 240-255 characters. However, doPost( )requests passes all of its data, of unlimited length. c) A doGet( ) request is appended to the request URL in a query string and this allows the exchange is visible to the client, whereas a doPost() request passes directly over the socket connection as part of its HTTP request body and the exchange are invisible to the client.&lt;br&gt;83) What is the life cycle of a servlet?&lt;br&gt;Ans: Each Servlet has the same life cycle: a) A server loads and initializes the servlet by init () method. b) The servlet handles zero or more client&amp;#39;s requests through service( ) method. c) The server removes the servlet through destroy() method. &lt;br&gt;84) Who is loading the init() method of servlet? &lt;br&gt;Ans: Web server &lt;br&gt;85) What are the different servers available for developing and deploying Servlets? &lt;br&gt;Ans: a) Java Web Server b) JRun g) Apache Server h) Netscape Information Server i) Web Logic&lt;br&gt;86) How many ways can we track client and what are they? &lt;br&gt;Ans: The servlet API provides two ways to track client state and they are: a) Using Session tracking and b) Using Cookies. &lt;br&gt;87) What is session tracking and how do you track a user session in servlets? &lt;br&gt;Ans: Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time. The methods used for session tracking are: a) User Authentication - occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password b) Hidden form fields - fields are added to an HTML form that are not displayed in the client&amp;#39;s browser. When the form containing the fields is submitted, the fields are sent back to the server c) URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include extra information. The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change. d) Cookies - a bit of information that is sent by a web server to a browser and which can later be read back from that browser. e) HttpSession- places a limit on the number of sessions that can exist in memory. This limit is set in the session.maxresidents property&lt;br&gt;88) What is Server-Side Includes (SSI)? &lt;br&gt;Ans: Server-Side Includes allows embedding servlets within HTML pages using a special servlet tag. In many servlets that support servlets, a page can be processed by the server to include output from servlets at certain points inside the HTML page. This is accomplished using a special internal SSINCLUDE, which processes the servlet tags. SSINCLUDE servlet will be invoked whenever a file with an. shtml extension is requested. So HTML files that include server-side includes must be stored with an .shtml extension.&lt;br&gt;89) What are cookies and how will you use them? &lt;br&gt;Ans: Cookies are a mechanism that a servlet uses to have a client hold a small amount of state-information associated with the user. a) Create a cookie with the Cookie constructor: public Cookie(String name, String value) b) A servlet can send a cookie to the client by passing a Cookie object to the addCookie() method of HttpServletResponse: public void HttpServletResponse.addCookie(Cookie cookie) c) A servlet retrieves cookies by calling the getCookies() method of HttpServletRequest: public Cookie[ ] HttpServletRequest.getCookie( ). &lt;br&gt;90) Is it possible to communicate from an applet to servlet and how many ways and how? &lt;br&gt;Ans: Yes, there are three ways to communicate from an applet to servlet and they are:&lt;br&gt;a) HTTP Communication(Text-based and object-based) &lt;br&gt;b) Socket Communication &lt;br&gt;c) RMI Communication (You can say, by using URL object open the connection to server and get the InputStream from URLConnection object). Steps involved for applet-servlet communication: &lt;br&gt;1) Get the server URL. URL url = new URL();&lt;br&gt;2) Connect to the host URLConnection Con = url.openConnection(); &lt;br&gt;3) Initialize the connection Con.setUseCatches(false): Con.setDoOutput(true); Con.setDoInput(true); &lt;br&gt;4) Data will be written to a byte array buffer so that we can tell the server the length of the data. ByteArrayOutputStream byteout = new ByteArrayOutputStream(); &lt;br&gt;5) Create the OutputStream to be used to write the data to the buffer. DataOutputStream out = new DataOutputStream(byteout); &lt;br&gt;91) What is connection pooling? &lt;br&gt;Ans: With servlets, opening a database connection is a major bottleneck because we are creating and tearing down a new connection for every page request and the time taken to create connection will be more. Creating a connection pool is an ideal approach for a complicated servlet. With a connection pool, we can duplicate only the resources we need to duplicate rather than the entire servlet. A connection pool can also intelligently manage the size of the pool and make sure each connection remains valid. A number of connection pool packages are currently available. Some like DbConnectionBroker are freely available from Java Exchange Works by creating an object that dispenses connections and connection Ids on request. The ConnectionPool class maintains a Hastable, using Connection objects as keys and Boolean values as stored values. The Boolean value indicates whether a connection is in use or not. A program calls getConnection( ) method of the ConnectionPool for getting Connection object it can use; it calls returnConnection( ) to give the connection back to the pool. &lt;br&gt;92) Why should we go for interservlet communication?&lt;br&gt;Ans: Servlets running together in the same server communicate with each other in several ways. The three major reasons to use interservlet communication are: a) Direct servlet manipulation - allows to gain access to the other currently loaded servlets and perform certain tasks (through the ServletContext object) b) Servlet reuse - allows the servlet to reuse the public methods of another servlet. c) Servlet collaboration - requires to communicate with each other by sharing specific information (through method invocation) &lt;br&gt;93) Is it possible to call servlet with parameters in the URL? &lt;br&gt;Ans: Yes. You can call a servlet with parameters in the syntax as (?Param1 = xxx || m2 = yyy). 94) What is Servlet chaining? Ans: Servlet chaining is a technique in which two or more servlets can cooperate in servicing a single request. In servlet chaining, one servlet&amp;#39;s output is piped to the next servlet&amp;#39;s input. This process continues until the last servlet is reached. Its output is then sent back to the client. &lt;br&gt;95) How do servlets handle multiple simultaneous requests? &lt;br&gt;Ans: The server has multiple threads that are available to handle requests. When a request comes in, it is assigned to a thread, which calls a service method (for example: doGet(), doPost( ) and service( ) ) of the servlet. For this reason, a single servlet object can have its service methods called by many threads at once. &lt;br&gt;96) What is the difference between TCP/IP and UDP? &lt;br&gt;Ans: TCP/IP is a two-way communication between the client and the server and it is a reliable and there is a confirmation regarding reaching the message to the destination. It is like a phone call. UDP is a one-way communication only between the client and the server and it is not a reliable and there is no confirmation regarding reaching the message to the destination. It is like a postal mail. &lt;br&gt;97) What is Inet address? &lt;br&gt;Ans: Every computer connected to a network has an IP address. An IP address is a number that uniquely identifies each computer on the Net. An IP address is a 32-bit number.&lt;br&gt;98) What is Domain Naming Service(DNS)? &lt;br&gt;Ans: It is very difficult to remember a set of numbers(IP address) to connect to the Internet. The Domain Naming Service(DNS) is used to overcome this problem. It maps one particular IP address to a string of characters. For example, www.mascom.com implies com is the domain name reserved for US commercial sites, moscom is the name of the company and www is the name of the specific computer, which is mascom&amp;#39;s server. &lt;br&gt;99) What is URL? &lt;br&gt;Ans: URL stands for Uniform Resource Locator and it points to resource files on the Internet. URL has four components: http://www.Pentafour.com:80/index.html http - protocol name, Pentafour - IP address or host name, 80 - port number and index.html - file path. &lt;br&gt;100) What is RMI and steps involved in developing an RMI object? &lt;br&gt;Ans: Remote Method Invocation (RMI) allows java object that executes on one machine and to invoke the method of a Java object to execute on another machine. The steps involved in developing an RMI object are: a) Define the interfaces b) Implementing these interfaces c) Compile the interfaces and their implementations with the java compiler d) Compile the server implementation with RMI compiler e) Run the RMI registry f) Run the application &lt;br&gt;101) What is RMI architecture? &lt;br&gt;Ans: - RMI architecture consists of four layers and each layer performs specific functions: a) Application layer ---- contains the actual object definition b) Proxy layer ---- consists of stub and skeleton c) Remote Reference layer ---- gets the stream of bytes from the transport layer and sends it to the proxy layer d) Transportation layer ---- responsible for handling the actual machine-to-machine communication &lt;br&gt;102) what is UnicastRemoteObject? &lt;br&gt;Ans: All remote objects must extend UnicastRemoteObject, which provides functionality that is needed to make objects available from remote machines. &lt;br&gt;103) Explain the methods, rebind( ) and lookup() in Naming class?&lt;br&gt;Ans: rebind( ) of the Naming class(found in java.rmi) is used to update the RMI registry on the server machine. Naming. rebind(&amp;quot;AddSever&amp;quot;, AddServerImpl); lookup( ) of the Naming class accepts one argument, the rmi URL and returns a reference to an object of type AddServerImpl. &lt;br&gt;104) What is a Java Bean? &lt;br&gt;Ans: A Java Bean is a software component that has been designed to be reusable in a variety of different environments. &lt;br&gt;105) What is a Jar file? &lt;br&gt;Ans: Jar file allows to efficiently deploying a set of classes and their associated resources. The elements in a jar file are compressed, which makes downloading a Jar file much faster than separately downloading several uncompressed files. The package java.util.zip contains classes that read and write jar files. &lt;br&gt;106) What is BDK? &lt;br&gt;Ans: BDK, Bean Development Kit is a tool that enables to create, configure and connect a set of set of Beans and it can be used to test Beans without writing a code. &lt;br&gt;107) What is JSP?&lt;br&gt;Ans: JSP is a dynamic scripting capability for web pages that allows Java as well as a few special tags to be embedded into a web file (HTML/XML, etc). The suffix traditionally ends with .jsp to indicate to the web server that the file is a JSP files. JSP is a server side technology - you can&amp;#39;t do any client side validation with it. The advantages are: a) The JSP assists in making the HTML more functional. Servlets on the other hand allow outputting of HTML but it is a tedious process. b) It is easy to make a change and then let the JSP capability of the web server you are using deal with compiling it into a servlet and running it. &lt;br&gt;108) What are JSP scripting elements? &lt;br&gt;Ans: JSP scripting elements lets to insert Java code into the servlet that will be generated from the current JSP page. &lt;br&gt;There are three forms: &lt;br&gt;a) Expressions of the form &amp;lt;%= expression %&amp;gt; that are evaluated and inserted into the output, &lt;br&gt;b) Scriptlets of the form &amp;lt;% code %&amp;gt; that are inserted into the servlet&amp;#39;s service method, and &lt;br&gt;c) Declarations of the form &amp;lt;%! Code %&amp;gt; that are inserted into the body of the servlet class, outside of any existing methods. &lt;br&gt;109) What are JSP Directives? &lt;br&gt;Ans: A JSP directive affects the overall structure of the servlet class. It usually has the following form: &amp;lt;%@ directive attribute=&amp;quot;value&amp;quot; %&amp;gt; However, you can also combine multiple attribute settings for a single directive, as follows: &amp;lt;%@ directive attribute1=&amp;quot;value1&amp;quot; attribute 2=&amp;quot;value2&amp;quot; ... attributeN =&amp;quot;valueN&amp;quot; %&amp;gt; There are two main types of directive: page, which lets to do things like import classes, customize the servlet superclass, and the like; and include, which lets to insert a file into the servlet class at the time the JSP file is translated into a servlet &lt;br&gt;110) What are Predefined variables or implicit objects? &lt;br&gt;Ans: To simplify code in JSP expressions and scriptlets, we can use eight automatically defined variables, sometimes called implicit objects. They are request, response, out, session, application, config, pageContext, and page. &lt;br&gt;111) What are JSP ACTIONS?&lt;br&gt;Ans: JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or generate HTML for the Java plugin. Available actions include: ? jsp:include - Include a file at the time the page is requested. ?&lt;br&gt;jsp:useBean - Find or instantiate a JavaBean. ?&lt;br&gt;jsp:setProperty - Set the property of a JavaBean. ? &lt;br&gt;jsp:getProperty - Insert the property of a JavaBean into the output. ? &lt;br&gt;jsp:forward - Forward the requester to a newpage. ?&lt;br&gt;Jsp: plugin - Generate browser-specific code that makes an OBJECT or EMBED &lt;br&gt;112) How do you pass data (including JavaBeans) to a JSP from a servlet? &lt;br&gt;Ans: (1) Request Lifetime: Using this technique to pass beans, a request dispatcher (using either &amp;quot;include&amp;quot; or forward&amp;quot;) can be called. This bean will disappear after processing this request has been completed. Servlet: request.setAttribute(&amp;quot;theBean&amp;quot;, myBean); RequestDispatcher rd = getServletContext().getRequestDispatcher(&amp;quot;thepage.jsp&amp;quot;); rd.forward(request, response); JSP PAGE: &amp;lt;jsp: useBean id=&amp;quot;theBean&amp;quot; scope=&amp;quot;request&amp;quot; class=&amp;quot;.....&amp;quot; /&amp;gt; &lt;br&gt;(2) Session Lifetime: Using this technique to pass beans that are relevant to a particular session (such as in individual user login) over a number of requests. This bean will disappear when the session is invalidated or it times out, or when you remove it. Servlet: HttpSession session = request.getSession(true); session.putValue(&amp;quot;theBean&amp;quot;, myBean); /* You can do a request dispatcher here, or just let the bean be visible on the next request */ JSP Page: &amp;lt;jsp:useBean id=&amp;quot;theBean&amp;quot; scope=&amp;quot;session&amp;quot; class=&amp;quot;...&amp;quot; /&amp;gt; &lt;br&gt;3) Application Lifetime: Using this technique to pass beans that are relevant to all servlets and JSP pages in a particular app, for all users. For example, I use this to make a JDBC connection pool object available to the various servlets and JSP pages in my apps. This bean will disappear when the servlet engine is shut down, or when you remove it. Servlet: GetServletContext(). setAttribute(&amp;quot;theBean&amp;quot;, myBean); JSP PAGE: &amp;lt;jsp:useBean id=&amp;quot;theBean&amp;quot; scope=&amp;quot;application&amp;quot; class=&amp;quot;...&amp;quot; /&amp;gt; &lt;br&gt;113) How can I set a cookie in JSP? &lt;br&gt;Ans: response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &amp;quot;cookie string&amp;quot;); To give the response-object to a bean, write a method setResponse (HttpServletResponse response) - to the bean, and in jsp-file: &amp;lt;% bean.setResponse (response); %&amp;gt; 114) How can I delete a cookie with JSP? Ans: Say that I have a cookie called &amp;quot;foo,&amp;quot; that I set a while ago &amp;amp; I want it to go away. I simply: &amp;lt;% Cookie killCookie = new Cookie(&amp;quot;foo&amp;quot;, null); KillCookie.setPath(&amp;quot;/&amp;quot;); killCookie.setMaxAge(0); response.addCookie(killCookie); %&amp;gt; &lt;br&gt;115) How are Servlets and JSP Pages related? &lt;br&gt;Ans: JSP pages are focused around HTML (or XML) with Java codes and JSP tags inside them. When a web server that has JSP support is asked for a JSP page, it checks to see if it has already compiled the page into a servlet. Thus, JSP pages become servlets and are transformed into pure Java and then compiled, loaded into the server and executed &lt;b&gt;CORE JAVA&lt;/b&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is the difference between an Interface and an Abstract class? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  An Abstract class declares have at least one instance method that is declared abstract which will be implemented by the subclasses. An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the purpose of garbage collection in Java, and when is it used?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Describe synchronization in respect to multithreading.&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Explain different way of using thread? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, &amp;#39;cause when you are going for multiple inheritance..the only interface can help.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are pass by reference and passby value? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Pass By Reference means the passing the address itself rather than passing the value. Pass by Value means passing a copy of the value to be passed. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is HashMap and Map?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Map is Interface and Hashmap is class that implements that.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Difference between HashMap and HashTable?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesn&amp;rsquo;t allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is non synchronized and Hashtable is synchronized. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Difference between Vector and ArrayList?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Vector is synchronized whereas arraylist is not.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Difference between Swing and Awt?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  AWT are heavy-weight components. Swings are light-weight components. Hence swing works faster than AWT.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between a constructor and a method? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.&lt;br&gt;A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is an Iterators?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;&lt;i&gt;public : &lt;/i&gt;&lt;/b&gt;Public class is visible in other packages, field is visible everywhere (class must be public too)&lt;br&gt;&lt;b&gt;&lt;i&gt;private :&lt;/i&gt;&lt;/b&gt; Private variables or methods may be used only by an instance of the same class that declares the variable or method, A private feature may only be accessed by the class that owns the feature.&lt;br&gt;&lt;b&gt;&lt;i&gt;protected :&lt;/i&gt;&lt;/b&gt; Is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature.This access is provided even to subclasses that reside in a different package from the class that owns the protected feature.&lt;br&gt;&lt;b&gt;&lt;i&gt;default :&lt;/i&gt;&lt;/b&gt;What you get by default ie, without any access modifier (ie, public private or protected).It means that it is visible to all within a particular package.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is an abstract class?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method is automatically abstract itself, and must be declared as such.&lt;br&gt;A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is static in java?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can&amp;#39;t override a static method with a nonstatic method. In other words, you can&amp;#39;t change a static method into an instance method in a subclass.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is final?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A final class can&amp;#39;t be extended ie., final class may not be subclassed. A final method can&amp;#39;t be overridden when its class is inherited. You can&amp;#39;t change value of a final variable (is a constant).&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What if the main method is declared as private?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The program compiles properly but at runtime it will give &amp;quot;Main method not public.&amp;quot; message.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What if the static modifier is removed from the signature of the main method?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Program compiles. But at runtime throws an error &amp;quot;NoSuchMethodError&amp;quot;. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What if I write static public void instead of public static void?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Program compiles and runs properly. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What if I do not provide the String array as the argument to the method?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Program compiles but throws a runtime error &amp;quot;NoSuchMethodError&amp;quot;. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the first argument of the String array in main method?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;If I do not provide any arguments on the command line, then the String array of Main method will be empty of null?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  It is empty. But not null.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What environment variables do I need to set on my machine in order to be able to run Java programs?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  CLASSPATH and PATH are the two variables.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Can an application have multiple classes having main method?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Can I have multiple main methods in the same class?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  No the program fails to compile. The compiler says that the main method is already defined in the class.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Do I need to import java.lang package any time? Why ?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  No. It is by default loaded internally by the JVM.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Can I import same package/class twice? Will the JVM load the package twice at runtime?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  One can import the same package or same class multiple times. Neither compiler nor JVM complains abt it. And the JVM will internally load the class only once no matter how many times you import the same class.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are Checked and UnChecked Exception?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A checked exception is some subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses.&lt;br&gt;Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. eg, IOException thrown by java.io.FileInputStream&amp;#39;s read() method&amp;middot;&lt;br&gt;Unchecked exceptions are RuntimeException and any of its subclasses. Class Error and its subclasses also are unchecked. With an unchecked exception, however, the compiler doesn&amp;#39;t force client programmers either to catch the&lt;br&gt;exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. eg, StringIndexOutOfBoundsException thrown by String&amp;#39;s charAt() method&amp;middot; Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is Overriding?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  When a class defines a method using the same name, return type, and arguments as a method in its superclass, the method in the class overrides the method in the superclass.&lt;br&gt;When the method is invoked for an object of the class, it is the new definition of the method that is called, and not the method definition from superclass. Methods may be overridden to be more public, not more private.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are different types of inner classes?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;i&gt;Nested top-level classes&lt;/i&gt;, &lt;i&gt;Member classes, Local classes, Anonymous classes&lt;/i&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Nested top-level classes&lt;/i&gt;&lt;/b&gt;- If you declare a class within a class and specify the static modifier, the compiler treats the class just like any other top-level class.&lt;br&gt;Any class outside the declaring class accesses the nested class with the declaring class name acting similarly to a package. eg, outer.inner. Top-level inner classes implicitly have access only to static variables.There can also be inner interfaces. All of these are of the nested top-level variety.&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Member classes&lt;/i&gt;&lt;/b&gt; - Member inner classes are just like other member methods and member variables and access to the member class is restricted, just like methods and variables. This means a public member class acts similarly to a nested top-level class. The primary difference between member classes and nested top-level classes is that member classes have access to the specific instance of the enclosing class.&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Local classes&lt;/i&gt;&lt;/b&gt; - Local classes are like local variables, specific to a block of code. Their visibility is only within the block of their declaration. In order for the class to be useful beyond the declaration block, it would need to implement a&lt;br&gt;more publicly available interface.Because local classes are not members, the modifiers public, protected, private, and static are not usable.&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Anonymous classes&lt;/i&gt;&lt;/b&gt; - Anonymous inner classes extend local inner classes one level further. As anonymous classes have no name, you cannot provide a constructor.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying,can not resolve symbol&lt;br&gt;symbol : class ABCD&lt;br&gt;location: package io&lt;br&gt;import java.io.ABCD; &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  No you will have to import the subpackages explicitly. Importing com.MyTest.* will import classes in the package MyTest only. It will not import any class in any of it&amp;#39;s subpackage.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between declaring a variable and defining a variable?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  In declaration we just mention the type of the variable and it&amp;#39;s name. We do not initialize it. But defining means declaration + initialization.&lt;br&gt;e.g String s; is just a declaration while String s = new String (&amp;quot;abcd&amp;quot;); Or String s = &amp;quot;abcd&amp;quot;; are both definitions.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the default value of an object reference declared as an instance variable?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  null unless we define it explicitly.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Can a top level class be private or protected?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  No. A top level class can not be private or protected. It can have either &amp;quot;public&amp;quot; or no modifier. If it does not have a modifier it is supposed to have a default access.If a top level class is declared as private the compiler will complain that the &amp;quot;modifier private is not allowed here&amp;quot;. This means that a top level class can not be private. Same is the case with protected.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What type of parameter passing does Java support?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  In Java the arguments are always passed by value .&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Primitive data types are passed by reference or pass by value?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Primitive data types are passed by value.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Objects are passed by value or by reference?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object .&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is serialization?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How do I serialize an object to a file?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The class whose instances are to be serialized should implement an interface Serializable. Then you pass the instance to the ObjectOutputStream which is connected to a fileoutputstream. This will save the object to a file.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Which methods of Serializable interface should I implement?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The serializable interface is an empty interface, it does not contain any methods. So we do not implement any methods.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How can I customize the seralization process? i.e. how can one have a control over the serialization process?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Yes it is possible to have control over serialization process. The class should implement Externalizable interface. This interface contains two methods namely readExternal and writeExternal. You should implement these methods and write the logic for customizing the serialization process.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the common usage of serialization?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Whenever an object is to be sent over the network, objects need to be serialized. Moreover if the state of an object is to be saved, objects need to be serilazed.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is Externalizable interface?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism. Thus if your class implements this interface, you can customize the serialization process by implementing these methods.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What happens to the object references included in the object?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The serialization mechanism generates an object graph for serialization. Thus it determines whether the included object references are serializable or not. This is a recursive process. Thus when an object is serialized, all the included objects are also serialized alongwith the original obect.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What one should take care of while serializing the object?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  One should make sure that all the included objects are also serializable. If any of the objects is not serializable then it throws a NotSerializableException.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What happens to the static fields of a class during serialization? Are these fields serialized as a part of each serialized object?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Yes the static fields do get serialized. If the static field is an object then it must have implemented Serializable interface. The static fields are serialized as a part of every object. But the commonness of the static fields across all the instances is maintained even after serialization.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How are Observer and Observable used?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is synchronization and why is it important?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  With respect to multithreading, synchronization is the capability to control&lt;br&gt;the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object&amp;#39;s value. This often leads to&lt;br&gt;significant errors.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How does Java handle integer overflows and underflows?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Does garbage collection guarantee that a program will not run out of memory?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Garbage collection does not guarantee that a program will not run out of&lt;br&gt;memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection&lt;br&gt;.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between preemptive scheduling and time slicing?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Under preemptive scheduling, the highest priority task executes until it enters&lt;br&gt;the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;When a thread is created and started, what is its initial state?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A thread is in the ready state after it has been created and started.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the purpose of finalization?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the Locale class?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The Locale class is used to tailor program output to the conventions of a&lt;br&gt;particular geographic, political, or cultural region.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between a while statement and a do statement?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A while statement checks at the beginning of a loop to see whether the next&lt;br&gt;loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will &lt;br&gt;always execute the body of a loop at least once.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between static and non-static variables?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How are this() and super() used with constructors?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Othis() is used to invoke a constructor of the same class. super() is used to&lt;br&gt;invoke a superclass constructor.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are synchronized methods and synchronized statements?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method&amp;#39;s object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Does Java provide any construct to find out the size of an object?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  No there is not sizeof operator in Java. So there is not direct way to determine the size of an object directly in Java.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Read the system time just before the method is invoked and immediately after method returns. Take the time difference, which will give you the time taken by a method for execution. &lt;br&gt;To put it in code...&lt;br&gt;long start = System.currentTimeMillis ();&lt;br&gt;method ();&lt;br&gt;long end = System.currentTimeMillis ();&lt;br&gt;System.out.println (&amp;quot;Time taken for execution is &amp;quot; + (end - start));&lt;br&gt;Remember that if the time taken for execution is too small, it might show that it is taking zero milliseconds for execution. Try it on a method which is big enough, in the sense the one which is doing considerable amout of processing.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are wrapper classes?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Java provides specialized classes corresponding to each of the primitive data types. These are called wrapper classes. They are e.g. Integer, Character, Double etc.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Why do we need wrapper classes?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are checked exceptions?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Checked exception are those which the Java compiler forces you to catch. e.g. IOException are checked Exceptions.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are runtime exceptions?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked by the compiler at compile time.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between error and an exception?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime. While exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist. Or a NullPointerException will take place if you try using a null reference. In most of the cases it is possible to recover from an exception (probably by giving user a feedback for entering proper values etc.).&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How to create custom exceptions?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Your class should extend class Exception, or some more specific type thereof.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;If I want an object of my class to be thrown as an exception object, what should I do?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The class should extend from Exception class. Or you can extend your class from some more precise exception type also.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;If my class already extends from some other class what should I do if I want an instance of my class to be thrown as an exception object?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What happens to an unhandled exception?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How does an exception permeate through the code?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  An unhandled exception moves up the method stack in search of a matching When an exception is thrown from a code which is wrapped in a try block followed by one or more catch blocks, a search is made for matching catch block. If a matching type is found then that block will be invoked. If a matching type is not found then the exception moves up the method stack and reaches the caller method. Same procedure is repeated if the caller method is included in a try catch block. This process continues until a catch block handling the appropriate type of exception is found. If it does not find such a block then finally the program terminates.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the different ways to handle exceptions?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  There are two ways to handle exceptions, &lt;br&gt;1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and &lt;br&gt;2. List the desired exceptions in the throws clause of the method and let the caller of the method hadle those exceptions.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Q: What is the basic difference between the 2 approaches to exception handling...1&amp;gt; try catch block and 2&amp;gt; specifying the candidate exceptions in the throws clause?&lt;/b&gt;&lt;br&gt;&lt;b&gt;When should you use which approach?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  In the first approach as a programmer of the method, you urself are dealing with the exception. This is fine if you are in a best position to decide should be done in case of an exception. Whereas if it is not the responsibility of the method to deal with it&amp;#39;s own exceptions, then do not use this approach. In this case use the second approach. In the second approach we are forcing the caller of the method to catch the exceptions, that the method is likely to throw. This is often the approach library creators use. They list the exception in the throws clause and we must catch them. You will find the same approach throughout the java libraries we use.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Is it necessary that each try block must be followed by a catch block?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block OR a finally block. And whatever exceptions are likely to be thrown should be declared in the throws clause of the method.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;If I write return at the end of the try block, will the finally block still execute?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will execute and then the control return.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;If I write System.exit (0); at the end of the try block, will the finally block still execute?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;&lt;u&gt;JSP&lt;/u&gt;&lt;/b&gt;   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is a output comment? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A comment that is sent to the client in the viewable page source.The JSP engine handles an output comment as uninterpreted HTML text, returning the comment in the HTML output sent to the client. You can see the comment by viewing the page source from your Web browser. &lt;b&gt;&lt;i&gt;JSP Syntax&lt;/i&gt;&lt;/b&gt;&lt;br&gt;&amp;lt;!-- comment [ &amp;lt;%= expression %&amp;gt; ] --&amp;gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Example 1&lt;/i&gt;&lt;/b&gt;&lt;br&gt;&amp;lt;!-- This is a commnet sent to client on&lt;br&gt;&amp;lt;%= (new java.util.Date()).toLocaleString() %&amp;gt;&lt;br&gt;--&amp;gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Displays in the page source:&lt;/i&gt;&lt;/b&gt;&lt;br&gt;&amp;lt;!-- This is a commnet sent to client on January 24, 2004 --&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is a Hidden Comment?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A comments that documents the JSP page but is not sent to the client. The JSP engine ignores a hidden comment, and does not process any code within hidden comment tags. A hidden comment is not sent to the client, either in the displayed JSP page or the HTML page source. The hidden comment is useful when you want to hide or &amp;quot;comment out&amp;quot; part of your JSP page. &lt;br&gt;You can use any characters in the body of the comment except the closing --%&amp;gt; combination. If you need to use --%&amp;gt; in your comment, you can escape it by typing --%\&amp;gt;. &lt;br&gt;&lt;b&gt;&lt;i&gt;JSP Syntax&lt;/i&gt;&lt;/b&gt;&lt;br&gt;&amp;lt;%-- comment --%&amp;gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Examples&lt;/i&gt;&lt;/b&gt;&lt;br&gt;&amp;lt;%@ page language=&amp;quot;java&amp;quot; %&amp;gt;&lt;br&gt;&amp;lt;html&amp;gt;&lt;br&gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;A Hidden Comment &amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br&gt;&amp;lt;body&amp;gt;&lt;br&gt;&amp;lt;%-- This comment will not be visible to the colent in the page source --%&amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/html&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is a Expression?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  An expression tag contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file. Because the value of an expression is converted to a String, you can use an expression within text in a JSP file. Like&lt;br&gt;&amp;lt;%= someexpression %&amp;gt; &lt;br&gt;&amp;lt;%= (new java.util.Date()).toLocaleString() %&amp;gt;&lt;br&gt;You cannot use a semicolon to end an expression &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is a Declaration? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A declaration declares one or more variables or methods for use later in the JSP source file. &lt;br&gt;A declaration must contain at least one complete declarative statement. You can declare any number of variables or methods within one declaration tag, as long as they are separated by semicolons. The declaration must be valid in the scripting language used in the JSP file. &lt;br&gt;&lt;br&gt;&amp;lt;%! somedeclarations %&amp;gt;&lt;br&gt;&amp;lt;%! int i = 0; %&amp;gt;&lt;br&gt;&amp;lt;%! int a, b, c; %&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is a Scriptlet? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A scriptlet can contain any number of language statements, variable or method declarations, or expressions that are valid in the page scripting language.Within scriptlet tags, you can &lt;br&gt;1.Declare variables or methods to use later in the file (see also Declaration).&lt;br&gt;&lt;br&gt;2.Write expressions valid in the page scripting language (see also Expression). &lt;br&gt;&lt;br&gt;3.Use any of the JSP implicit objects or any object declared with a &amp;lt;jsp:useBean&amp;gt; tag. &lt;br&gt;You must write plain text, HTML-encoded text, or other JSP tags outside the scriptlet. &lt;br&gt;Scriptlets are executed at request time, when the JSP engine processes the client request. If the scriptlet produces output, the output is stored in the out object, from which you can display it.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are implicit objects? List them?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Certain objects that are available for the use in JSP documents without being declared first. These objects are parsed by the JSP engine and inserted into the generated servlet. The implicit objects re listed below&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &amp;middot; request &amp;middot; response &amp;middot; pageContext &amp;middot; session &amp;middot; application &amp;middot; out &amp;middot; config &amp;middot; page &amp;middot; exception&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Difference between forward and sendRedirect?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  When you invoke a forward request, the request is sent to another resource on the server, without the client being informed that a different resource is going to process the request. This process occurs completly with in the web container. When a sendRedirtect method is invoked, it causes the web container to return to the browser indicating that a new URL should be requested. Because the browser issues a completly new request any object that are stored as request attributes before the redirect occurs will be lost. This extra round trip a redirect is slower than forward.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the different scope valiues for the &amp;lt;jsp:useBean&amp;gt;?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The different scope values for &amp;lt;jsp:useBean&amp;gt; are &lt;br&gt;1. page&lt;br&gt;2. request&lt;br&gt;3.session&lt;br&gt;4.application&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Explain the life-cycle mehtods in JSP?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  THe generated servlet class for a JSP page implements the HttpJspPage interface of the javax.servlet.jsp package. Hte HttpJspPage interface extends the JspPage interface which inturn extends the Servlet interface of the javax.servlet package. the generated servlet class thus implements all the methods of the these three interfaces. The JspPage interface declares only two mehtods - &lt;i&gt;jspInit()&lt;/i&gt; and&lt;i&gt; jspDestroy()&lt;/i&gt; that must be implemented by all JSP pages regardless of the client-server protocol. However the JSP specification has provided the HttpJspPage interfaec specifically for the JSp pages serving HTTP requests. This interface declares one method &lt;i&gt;_jspService()&lt;/i&gt;. &lt;br&gt;The jspInit()- The container calls the jspInit() to initialize te servlet instance.It is called before any other method, and is called only once for a servlet instance.&lt;br&gt;The _jspservice()- The container calls the _jspservice() for each request, passing it the request and the response objects.&lt;br&gt;The jspDestroy()- The container calls this when it decides take the instance out of service. It is the last method called n the servlet instance.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;How do I prevent the output of my JSP or Servlet pages from being cached by the browser?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP page from being cached by the browser. Just execute the following scriptlet at the beginning of your JSP pages to prevent them from being cached at the browser. You need both the statements to take care of some of the older browser versions. &amp;lt;%&lt;br&gt;response.setHeader(&amp;quot;Cache-Control&amp;quot;,&amp;quot;no-store&amp;quot;); //HTTP 1.1&lt;br&gt;response.setHeader(&amp;quot;Pragma\&amp;quot;,&amp;quot;no-cache&amp;quot;); //HTTP 1.0&lt;br&gt;response.setDateHeader (&amp;quot;Expires&amp;quot;, 0); //prevents caching at the proxy server&lt;br&gt;%&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;How does JSP handle run-time exceptions? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  You can use the errorPage attribute of the page directive to have uncaught run-time exceptions automatically forwarded to an error processing page. For example:&lt;br&gt;&amp;lt;%@ page errorPage=\&amp;quot;error.jsp\&amp;quot; %&amp;gt; redirects the browser to the JSP page error.jsp if an uncaught exception is encountered during request processing. Within error.jsp, if you indicate that it is an error-processing page, via the directive: &amp;lt;%@ page isErrorPage=\&amp;quot;true\&amp;quot; %&amp;gt; Throwable object describing the exception may be accessed within the error page via the exception implicit object. Note: You must always use a relative URL as the value for the errorPage attribute.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;How can I implement a thread-safe JSP page? What are the advantages and Disadvantages of using it?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive &amp;lt;%@ page isThreadSafe=&amp;quot;false&amp;quot; %&amp;gt; within your JSP page. With this, instead of a single instance of the servlet generated for your JSP page loaded in memory, you will have N instances of the servlet loaded and initialized, with the service method of each instance effectively synchronized. You can typically control the number of instances (N) that are instantiated for all servlets implementing SingleThreadModel through the admin screen for your JSP engine. More importantly, avoid using the tag for variables. If you do use this tag, then you should set isThreadSafe to true, as mentioned above. Otherwise, all requests to that page will access those variables, causing a nasty race condition. SingleThreadModel is not recommended for normal use. There are many pitfalls, including the example above of not being able to use &amp;lt;%! %&amp;gt;. You should try really hard to make them thread-safe the old fashioned way: by making them thread-safe .&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;How do I use a scriptlet to initialize a newly instantiated bean?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A jsp:useBean action may optionally have a body. If the body is specified, its contents will be automatically invoked when the specified bean is instantiated. Typically, the body will contain scriptlets or jsp:setProperty tags to initialize the newly instantiated bean, although you are not restricted to using those alone.&lt;br&gt;The following example shows the &amp;ldquo;today&amp;rdquo; property of the Foo bean initialized to the current date when it is instantiated. Note that here, we make use of a JSP expression within the jsp:setProperty action.&lt;br&gt;&lt;br&gt;&amp;lt;jsp:useBean id=&amp;quot;foo&amp;quot; class=&amp;quot;com.Bar.Foo&amp;quot; &amp;gt; &lt;br&gt;&amp;lt;jsp:setProperty name=&amp;quot;foo&amp;quot; property=&amp;quot;today&amp;quot; &lt;br&gt;value=&amp;quot;&amp;lt;%=java.text.DateFormat.getDateInstance().format(new java.util.Date()) %&amp;gt;&amp;quot; / &amp;gt;&lt;br&gt;&amp;lt;%-- scriptlets calling bean setter methods go here --%&amp;gt; &amp;lt;/jsp:useBean &amp;gt; &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;How can I prevent the word &amp;quot;null&amp;quot; from appearing in my HTML input text fields when I populate them with a resultset that has null values? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  You could make a simple wrapper function, like &lt;br&gt;&amp;lt;%!&lt;br&gt;String blanknull(String s) {&lt;br&gt;return (s == null) ? \&amp;quot;\&amp;quot; : s;&lt;br&gt;}&lt;br&gt;%&amp;gt;&lt;br&gt;then use it inside your JSP form, like &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lastName&amp;quot; value=&amp;quot;&amp;lt;%=blanknull(lastName)% &amp;gt;&amp;quot; &amp;gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What&amp;#39;s a better approach for enabling thread-safe servlets and JSPs? SingleThreadModel Interface or Synchronization?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Although the SingleThreadModel technique is easy to use, and works well for low volume sites, it does not scale well. If you anticipate your users to increase in the future, you may be better off implementing explicit synchronization for your shared data. The key however, is to effectively minimize the amount of code that is synchronzied so that you take maximum advantage of multithreading. Also, note that SingleThreadModel is pretty resource intensive from the server\&amp;#39;s perspective. The most serious issue however is when the number of concurrent requests exhaust the servlet instance pool. In that case, all the unserviced requests are queued until something becomes free - which results in poor performance. Since the usage is non-deterministic, it may not help much even if you did add more memory and increased the size of the instance pool.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;How can I enable session tracking for JSP pages if the browser has disabled cookies?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  We know that session tracking uses cookies by default to associate a session identifier with a unique user. If the browser does not support cookies, or if cookies are disabled, you can still enable session tracking using URL rewriting. URL rewriting essentially includes the session ID within the link itself as a name/value pair. However, for this to be effective, you need to append the session ID for each and every link that is part of your servlet response. Adding the session ID to a link is greatly simplified by means of of a couple of methods: response.encodeURL() associates a session ID with a given URL, and if you are using redirection, response.encodeRedirectURL() can be used by giving the redirected URL as input. Both encodeURL() and encodeRedirectedURL() first determine whether cookies are supported by the browser; if so, the input URL is returned unchanged since the session ID will be persisted as a cookie.&lt;br&gt;&lt;br&gt;Consider the following example, in which two JSP files, say hello1.jsp and hello2.jsp, interact with each other. Basically, we create a new session within hello1.jsp and place an object within this session. The user can then traverse to hello2.jsp by clicking on the link present within the page. Within hello2.jsp, we simply extract the object that was earlier placed in the session and display its contents. Notice that we invoke the encodeURL() within hello1.jsp on the link used to invoke hello2.jsp; if cookies are disabled, the session ID is automatically appended to the URL, allowing hello2.jsp to still retrieve the session object. Try this example first with cookies enabled. Then disable cookie support, restart the brower, and try again. Each time you should see the maintenance of the session across pages. Do note that to get this example to work with cookies disabled at the browser, your JSP engine has to support URL rewriting. &lt;br&gt;&lt;b&gt;hello1.jsp&lt;/b&gt;&lt;br&gt;&amp;lt;%@ page session=\&amp;quot;true\&amp;quot; %&amp;gt;&lt;br&gt;&amp;lt;%&lt;br&gt;Integer num = new Integer(100);&lt;br&gt;session.putValue(&amp;quot;num&amp;quot;,num);&lt;br&gt;String url =response.encodeURL(&amp;quot;hello2.jsp&amp;quot;);&lt;br&gt;%&amp;gt;&lt;br&gt;&amp;lt;a href=\&amp;#39;&amp;lt;%=url%&amp;gt;\&amp;#39;&amp;gt;hello2.jsp&amp;lt;/a&amp;gt;&lt;br&gt;&lt;b&gt;hello2.jsp&lt;/b&gt;&lt;br&gt;&amp;lt;%@ page session=&amp;quot;true&amp;quot; %&amp;gt;&lt;br&gt;&amp;lt;%&lt;br&gt;Integer i= (Integer )session.getValue(&amp;quot;num&amp;quot;);&lt;br&gt;out.println(&amp;quot;Num value in session is &amp;quot; + i.intValue());&lt;br&gt;%&amp;gt; &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;&lt;u&gt;SERVLET&lt;/u&gt;&lt;/b&gt;   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Explain the life cycle methods of a Servlet.&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The javax.servlet.Servlet interface defines the three methods known as life-cycle method.&lt;br&gt;&lt;b&gt;&lt;i&gt;public void init(ServletConfig config) throws ServletException&lt;/i&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException&lt;/i&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;public void destroy()&lt;/i&gt;&lt;/b&gt;&lt;br&gt;First the servlet is constructed, then initialized wih the &lt;b&gt;&lt;i&gt;init()&lt;/i&gt;&lt;/b&gt; method.&lt;br&gt;Any request from client are handled initially by the &lt;b&gt;&lt;i&gt;service()&lt;/i&gt;&lt;/b&gt; method before delegating to the &lt;b&gt;&lt;i&gt;doXxx()&lt;/i&gt;&lt;/b&gt; methods in the case of HttpServlet.&lt;br&gt;&lt;br&gt;The servlet is removed from service, destroyed with the &lt;b&gt;&lt;i&gt;destroy()&lt;/i&gt;&lt;/b&gt; methid, then garbaged collected and finalized.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is the difference between the getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface and javax.servlet.ServletContext interface?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a &amp;quot;/&amp;quot; it is interpreted as relative to the current context root.&lt;br&gt;&lt;br&gt;The getRequestDispatcher(String path) method of javax.servlet.ServletContext interface cannot accepts relative paths. All path must sart with a &amp;quot;/&amp;quot; and are interpreted as relative to curent context root.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Explain the directory structure of a web application.&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The directory structure of a web application consists of two parts. &lt;br&gt;A private directory called WEB-INF&lt;br&gt;A public resource directory which contains public resource folder.&lt;br&gt;&lt;br&gt;WEB-INF folder consists of &lt;br&gt;1. web.xml&lt;br&gt;2. classes directory&lt;br&gt;3. lib directory&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What are the common mechanisms used for session tracking?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Cookies&lt;br&gt;SSL sessions&lt;br&gt;URL- rewriting&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Explain ServletContext.&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  ServletContext interface is a window for a servlet to view it&amp;#39;s environment. A servlet can use this interface to get information such as initialization parameters for the web applicationor servlet container&amp;#39;s version. Every web application has one and only one ServletContext and is accessible to all active resource of that application.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is preinitialization of a servlet?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A container doesnot initialize the servlets ass soon as it starts up, it initializes a servlet when it receives a request for that servlet first time. This is called lazy loading. The servlet specification defines the &amp;lt;load-on-startup&amp;gt; element, which can be specified in the deployment descriptor to make the servlet container load and initialize the servlet as soon as it starts up. The process of loading a servlet before any request comes in is called preloading or preinitializing a servlet.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is the difference between Difference between doGet() and doPost()?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A doGet() method is limited with 2k of data to be sent, and doPost() method doesn&amp;#39;t have this limitation. A request string for doGet() looks like the following: &lt;br&gt;http://www.allapplabs.com/svt1?p1=v1&amp;amp;p2=v2&amp;amp;...&amp;amp;pN=vN&lt;br&gt;doPost() method call doesn&amp;#39;t need a long text tail after a servlet name in a request. All parameters are stored in a request itself, not in a request string, and it&amp;#39;s impossible to guess the data transmitted to a servlet only looking at a request string.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is the difference between HttpServlet and GenericServlet?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A GenericServlet has a service() method aimed to handle requests. HttpServlet extends GenericServlet and adds support for doGet(), doPost(), doHead() methods (HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods (HTTP 1.1). &lt;br&gt;Both these classes are abstract.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;&lt;u&gt;EJB&lt;/u&gt;&lt;/b&gt;   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the different kinds of enterprise beans?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_types_of_ejb.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Different kind of enterrise beans are Stateless session bean, Stateful session bean, Entity bean, Message-driven bean...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is Session Bean?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_session_beans.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;A session bean is a non-persistent object that implements some business logic running on the server. One way to think of a session object...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is Entity Bean?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_entity_beans.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;The entity bean is used to represent data in the database. It provides an object-oriented interface to ...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the methods of Entity Bean?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_entity_beans_method.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;An entity bean consists of 4 groups of methods, create methods...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between Container-Managed Persistent (CMP) bean and Bean-Managed Persistent(BMP) ?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_difference_bmp_cmp.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Container-managed persistence (CMP) and bean-managed persistence (BMP). With CMP, the container manages the persistence of the entity bean............&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the callback methods in Entity beans?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_callback_methods.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Callback methods allows the container to notify the bean of events in&lt;/a&gt;&lt;br&gt;&lt;u&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_callback_methods.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;its life cycle. The callback methods are defined in the javax.ejb.EntityBean interface............&lt;/a&gt;&lt;/u&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is software architecture of EJB?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_architecture_of_ejb.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Session and Entity EJBs consist of 4 and 5 parts respectively, a remote interface...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Can Entity Beans have no create() methods?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_no_create_methods.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Yes. In some cases the data is inserted NOT using Java application,...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is bean managed transaction?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_bean_managed_transactions.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;If a developer doesn&amp;#39;t want a Container to manage transactions, it&amp;#39;s possible to implement all database operations manually...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are transaction attributes? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_transaction_attributes.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;The transaction attribute specifies how the Container must manage transactions for a method when a client invokes the method via the enterprise bean&amp;rsquo;s home or...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions.htm#top&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are transaction isolation levels in EJB?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.allapplabs.com/interview_questions/ejb_interview_questions_transaction_isolation_levels.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Transaction_read_uncommitted , Transaction_read_committed , Transaction_repeatable_read...........&lt;/a&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;How EJB Invocation happens?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Step 1: Retrieve Home Object reference from Naming Service via JNDI.&lt;br&gt;step 2: Return Home Object reference to the client.&lt;br&gt;step 3: Create me a new EJB Object through Home Object interface.&lt;br&gt;step 4: Create EJB Object from the Ejb Object&lt;br&gt;step 5: Return EJB Object reference to the client.&lt;br&gt;step 6: Invoke business method using EJB Object reference.&lt;br&gt;step 7: Delegate request to Bean (Enterprise Bean). &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  You can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable.This has to be consider as ?passed-by-value&amp;quot;, that means that it?s read-only in the EJB. If anything is altered from inside the EJB, it won?t be reflected back to the HttpSession of the Servlet Container.The ?pass-by-reference? can be used between EJBs Remote Interfaces, as they are remote references. While it IS possible to pass an HttpSession as a parameter to an EJB object, it is considered to be ?bad practice ? in terms of object oriented design. This is because you are creating an unnecessary coupling between back-end objects (ejbs) and front-end objects (HttpSession). Create a higher-level of abstraction for your ejb?s api. Rather than passing the whole, fat, HttpSession (which carries with it a bunch of http semantics), create a class that acts as a value object (or structure) that holds all the data you need to pass back and forth between front-end/back-end. Consider the case where your ejb needs to support a non-http-based client. This higher level of abstraction will be flexible enough to support it.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;The EJB container implements the EJBHome and EJBObject classes. For every request from a unique client, does the container create a separate instance of the generated EJBHome and EJBObject classes?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The EJB container maintains an instance pool. The container uses these instances for the EJB Home reference irrespective of the client request. while refering the EJB Object classes the container creates a separate instance for each client request. The instance pool maintainence is up to the implementation of the container. If the container provides one, it is available otherwise it is not mandatory for the provider to implement it. Having said that, yes most of the container providers implement the pooling functionality to increase the performance of the application server. The way it is implemented is again up to the implementer. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Can the primary key in the entity bean be a Java primitive type such as int? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The primary key can&amp;#39;t be a primitive type--use the primitive wrapper classes, instead. For example, you can use java.lang.Integer as the primary key class, but not int (it has to be a class, not a primitive) &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Can you control when passivation occurs? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The developer, according to the specification, cannot directly control when passivation occurs. Although for Stateful Session Beans, the container cannot passivate an instance that is inside a transaction. So using transactions can be a a strategy to control passivation.&lt;br&gt;The ejbPassivate() method is called during passivation, so the developer has control over what to do during this exercise and can implement the require optimized logic.&lt;br&gt;Some EJB containers, such as BEA WebLogic, provide the ability to tune the container to minimize passivation calls. &lt;br&gt;Taken from the WebLogic 6.0 DTD -&amp;quot;The passivation-strategy can be either &amp;quot;default&amp;quot; or &amp;quot;transaction&amp;quot;. With the default setting the container will attempt to keep a working set of beans in the cache. With the &amp;quot;transaction&amp;quot; setting, the container will passivate the bean after every transaction (or method call for a non-transactional invocation).&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is the advantage of using Entity bean for database operations, over directly using JDBC API to do database operations? When would I use one over the other? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Entity Beans actually represents the data in a database. It is not that Entity Beans replaces JDBC API. There are two types of Entity Beans Container Managed and Bean Mananged. In Container Managed Entity Bean - Whenever the instance of the bean is created the container automatically retrieves the data from the DB/Persistance storage and assigns to the object variables in bean for user to manipulate or use them. For this the developer needs to map the fields in the database to the variables in deployment descriptor files (which varies for each vendor).&lt;br&gt;In the Bean Managed Entity Bean - The developer has to specifically make connection, retrive values, assign them to the objects in the ejbLoad() which will be called by the container when it instatiates a bean object. Similarly in the ejbStore() the container saves the object values back the the persistance storage. ejbLoad and ejbStore are callback methods and can be only invoked by the container. Apart from this, when you use Entity beans you dont need to worry about database transaction handling, database connection pooling etc. which are taken care by the ejb container. But in case of JDBC you have to explicitly do the above features. what suresh told is exactly perfect. ofcourse, this comes under the database transations, but i want to add this. the great thing about the entity beans of container managed, whenever the connection is failed during the transaction processing, the database consistancy is mantained automatically. the container writes the data stored at persistant storage of the entity beans to the database again to provide the database consistancy. where as in jdbc api, we, developers has to do manually.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is EJB QL? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  EJB QL is a Query Language provided for navigation across a network of enterprise beans and dependent objects defined by means of container managed persistence. EJB QL is introduced in the EJB 2.0 specification. The EJB QL query language defines finder methods for entity beans with container managed persistenceand is portable across containers and persistence managers. EJB QL is used for queries of two types of finder methods: Finder methods that are defined in the home interface of an entity bean and which return entity objects. Select methods, which are not exposed to the client, but which are used by the Bean Provider to select persistent values that are maintained by the Persistence Manager or to select entity objects that are related to the entity bean on which the query is defined. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Brief description about local interfaces? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  EEJB was originally designed around remote invocation using the Java Remote Method Invocation (RMI) mechanism, and later extended to support to standard CORBA transport for these calls using RMI/IIOP. This design allowed for maximum flexibility in developing applications without consideration for the deployment scenario, and was a strong feature in support of a goal of component reuse in J2EE. &lt;br&gt;Many developers are using EJBs locally -- that is, some or all of their EJB calls are between beans in a single container. &lt;br&gt;With this feedback in mind, the EJB 2.0 expert group has created a local interface mechanism. The local interface may be defined for a bean during development, to allow streamlined calls to the bean if a caller is in the same container. This does not involve the overhead involved with RMI like marshalling etc. This facility will thus improve the performance of applications in which co-location is planned. &lt;br&gt;Local interfaces also provide the foundation for container-managed relationships among entity beans with container-managed persistence. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What are the special design care that must be taken when you work with local interfaces? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  EIt is important to understand that the calling semantics of local interfaces are different from those of remote interfaces. For example, remote interfaces pass parameters using call-by-value semantics, while local interfaces use call-by-reference. &lt;br&gt;This means that in order to use local interfaces safely, application developers need to carefully consider potential deployment scenarios up front, then decide which interfaces can be local and which remote, and finally, develop the application code with these choices in mind. &lt;br&gt;While EJB 2.0 local interfaces are extremely useful in some situations, the long-term costs of these choices, especially when changing requirements and component reuse are taken into account, need to be factored into the design decision.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What happens if remove( ) is never invoked on a session bean? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  In case of a stateless session bean it may not matter if we call or not as in both cases nothing is done. The number of beans in cache is managed by the container. &lt;br&gt;In case of stateful session bean, the bean may be kept in cache till either the session times out, in which case the bean is removed or when there is a requirement for memory in which case the data is cached and the bean is sent to free pool.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is the difference between Message Driven Beans and Stateless Session beans? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  In several ways, the dynamic creation and allocation of message-driven bean instances mimics the behavior of stateless session EJB instances, which exist only for the duration of a particular method call. However, message-driven beans are different from stateless session EJBs (and other types of EJBs) in several significant ways:&lt;br&gt;&lt;br&gt;Message-driven beans process multiple JMS messages asynchronously, rather than processing a serialized sequence of method calls. &lt;br&gt;Message-driven beans have no home or remote interface, and therefore cannot be directly accessed by internal or external clients. Clients interact with message-driven beans only indirectly, by sending a message to a JMS Queue or Topic. &lt;br&gt;Note: Only the container directly interacts with a message-driven bean by creating bean instances and passing JMS messages to those instances as necessary. &lt;br&gt;The Container maintains the entire lifecycle of a message-driven bean; instances cannot be created or removed as a result of client requests or other API calls. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;How can I call one EJB from inside of another EJB? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  EJBs can be clients of other EJBs. It just works. Use JNDI to locate the Home Interface of the other bean, then acquire an instance reference, and so forth. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is an EJB Context? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  EJBContext is an interface that is implemented by the container, and it is also a part of the bean-container contract. Entity beans use a subclass of EJBContext called EntityContext. Session beans use a subclass called SessionContext. These EJBContext objects provide the bean class with information about its container, the client using the bean and the bean itself. They also provide other functions. See the API docs and the spec for more details. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;&lt;u&gt;JMS&lt;/u&gt;&lt;/b&gt;   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is JMS?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  JMS is an acronym used for Java Messaging Service. It is Java&amp;#39;s answer to creating software using asynchronous messaging. It is one of the official specifications of the J2EE technologies and is a key technology.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How JMS is different from RPC?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  In RPC the method invoker waits for the method to finish execution and return the control back to the invoker. Thus it is completely synchronous in nature. While in JMS the message sender just sends the message to the destination and continues it&amp;#39;s own processing. The sender does not wait for the receiver to respond. This is asynchronous behavior.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the advantages of JMS?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  JMS is asynchronous in nature. Thus not all the pieces need to be up all the time for the application to function as a whole. Even if the receiver is down the MOM will store the messages on it&amp;#39;s behalf and will send them once it comes back up. Thus at least a part of application can still function as there is no blocking. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Are you aware of any major JMS products available in the market? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  IBM&amp;#39;s MQ Series is one of the most popular product used as Message Oriented Middleware. Some of the other products are SonicMQ, iBus etc. Weblogic application server also comes with built in support for JMS messaging. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the different types of messages available in the JMS API? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Message, TextMessage, BytesMessage, StreamMessage, ObjectMessage, MapMessage are the different messages available in the JMS API. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the different messaging paradigms JMS supports?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Publish and Subscribe i.e. pub/suc and Point to Point i.e. p2p.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between topic and queue?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A topic is typically used for one to many messaging i.e. it supports publish subscribe model of messaging. While queue is used for one-to-one messaging i.e. it supports Point to Point Messaging.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the role of JMS in enterprise solution development?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  JMS is typically used in the following scenarios&lt;br&gt;1. Enterprise Application Integration: - Where a legacy application is integrated with a new application via messaging.&lt;br&gt;2. B2B or Business to Business: - Businesses can interact with each other via messaging because JMS allows organizations to cooperate without tightly coupling their business systems.&lt;br&gt;3. Geographically dispersed units: - JMS can ensure safe exchange of data amongst the geographically dispersed units of an organization.&lt;br&gt;4. One to many applications: - The applications that have to push data in packet to huge number of clients in a one-to-many fashion are good candidates for the use JMS. Typical such applications are Auction Sites, Stock Quote Services etc.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the use of Message object?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Message is a light weight message having only header and properties and no payload. Thus if the received are to be notified abt an event, and no data needs to be exchanged then using Message can be very efficient.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the basic difference between Publish Subscribe model and P2P model?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Publish Subscribe model is typically used in one-to-many situation. It is unreliable but very fast. P2P model is used in one-to-one situation. It is highly reliable.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the use of BytesMessage?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  BytesMessage contains an array of primitive bytes in it&amp;#39;s payload. Thus it can be used for transfer of data between two applications in their native format which may not be compatible with other Message types. It is also useful where JMS is used purely as a transport between two systems and the message payload is opaque to the JMS client. Whenever you store any primitive type, it is converted into it&amp;#39;s byte representation and then stored in the payload. There is no boundary line between the different data types stored. Thus you can even read a long as short. This would result in erroneous data and hence it is advisable that the payload be read in the same order and using the same type in which it was created by the sender.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the use of StreamMessage?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  StreamMessage carries a stream of Java primitive types as it&amp;#39;s payload. It contains some conveient methods for reading the data stored in the payload. However StreamMessage prevents reading a long value as short, something that is allwed in case of BytesMessage. This is so because the StreamMessage also writes the type information alonwgith the value of the primitive type and enforces a set of strict conversion rules which actually prevents reading of one primitive type as another. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the use of TextMessage?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  TextMessage contains instance of java.lang.String as it&amp;#39;s payload. Thus it is very useful for exchanging textual data. It can also be used for exchanging complex character data such as an XML document.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the use of ObjectMessage?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  ObjectMessage contains a Serializable java object as it&amp;#39;s payload. Thus it allows exchange of Java objects between applications. This in itself mandates that both the applications be Java applications. The consumer of the message must typecast the object received to it&amp;#39;s appropriate type. Thus the consumer should before hand know the actual type of the object sent by the sender. Wrong type casting would result in ClassCastException. Moreover the class definition of the object set in the payload should be available on both the machine, the sender as well as the consumer. If the class definition is not available in the consumer machine, an attempt to type cast would result in ClassNotFoundException. Some of the MOMs might support dynamic loading of the desired class over the network, but the JMS specification does not mandate this behavior and would be a value added service if provided by your vendor. And relying on any such vendor specific functionality would hamper the portability of your application. Most of the time the class need to be put in the classpath of both, the sender and the consumer, manually by the developer.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the use of MapMessage?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  A MapMessage carries name-value pair as it&amp;#39;s payload. Thus it&amp;#39;s payload is similar to the java.util.Properties object of Java. The values can be Java primitives or their wrappers.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference between BytesMessage and StreamMessage??&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  BytesMessage stores the primitive data types by converting them to their byte representation. Thus the message is one contiguous stream of bytes. While the StreamMessage maintains a boundary between the different data types stored because it also stores the type information along with the value of the primitive being stored. BytesMessage allows data to be read using any type. Thus even if your payload contains a long value, you can invoke a method to read a short and it will return you something. It will not give you a semantically correct data but the call will succeed in reading the first two bytes of data. This is strictly prohibited in the StreamMessage. It maintains the type information of the data being stored and enforces strict conversion rules on the data being read.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;&lt;u&gt;DATABASE&lt;/u&gt;&lt;/b&gt;   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;What is SQL? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SQL stands for &amp;#39;Structured Query Language&amp;#39;.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is SELECT statement?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The SELECT statement lets you select a set of values from a table in a database. The values selected from the database table would depend on the various conditions that are specified in the SQL query.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How can you compare a part of the name rather than the entire name?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SELECT * FROM people WHERE empname LIKE &amp;#39;%ab%&amp;#39;&lt;br&gt;Would return a recordset with records consisting empname the sequence &amp;#39;&lt;b&gt;ab&lt;/b&gt;&amp;#39; in empname .&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;98%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the INSERT statement? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The INSERT statement lets you insert information into a database.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How do you delete a record from a database? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Use the DELETE statement to remove records or any particular column values from a database.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How could I get distinct entries from a table?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The SELECT statement in conjunction with DISTINCT lets you select a set of distinct values from a table in a database. The values selected from the database table would of course depend on the various conditions that are specified in the SQL query. Example&lt;br&gt;&lt;i&gt;SELECT DISTINCT empname FROM emptable &lt;/i&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How to get the results of a Query sorted in any order?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  You can sort the results and return the sorted results to your program by using ORDER BY keyword thus saving you the pain of carrying out the sorting yourself. The ORDER BY keyword is used for sorting.&lt;br&gt;&lt;i&gt;SELECT empname, age, city FROM emptable ORDER BY empname&lt;/i&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;How can I find the total number of records in a table?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  You could use the COUNT keyword , example&lt;br&gt;&lt;br&gt;&lt;i&gt;SELECT COUNT(*) FROM emp WHERE age&amp;gt;40 &lt;/i&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is GROUP BY?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  The GROUP BY keywords have been added to SQL because aggregate functions (like SUM) return the aggregate of all column values every time they are called. Without the GROUP BY functionality, finding the sum for each individual group of column values was not possible. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is the difference among &amp;quot;dropping a table&amp;quot;, &amp;quot;truncating a table&amp;quot; and &amp;quot;deleting all records&amp;quot; from a table&lt;/b&gt;.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Dropping :&lt;/b&gt; (Table structure + Data are deleted), Invalidates the dependent objects ,Drops the indexes &lt;br&gt;&lt;b&gt;Truncating:&lt;/b&gt; (Data alone deleted), Performs an automatic commit, Faster than delete&lt;br&gt;&lt;b&gt;Delete :&lt;/b&gt; (Data alone deleted), Doesn&amp;rsquo;t perform automatic commit&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are the Large object types suported by Oracle? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Blob and Clob.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;Difference between a &amp;quot;where&amp;quot; clause and a &amp;quot;having&amp;quot; clause.&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Having clause is used only with group functions whereas Where is not used with.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What&amp;#39;s the difference between a primary key and a unique key? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn&amp;#39;t allow NULLs, but unique key allows one NULL only.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Cursors allow row-by-row prcessing of the resultsets.&lt;br&gt;Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.&lt;br&gt;Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.&lt;br&gt;Most of the times, set based operations can be used instead of cursors. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What are triggers? How to invoke a trigger on demand? &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table. &lt;br&gt;Triggers can&amp;#39;t be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.&lt;br&gt;Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is a join and explain different types of joins. &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table. &lt;br&gt;Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;3%&quot;&gt;  &lt;b&gt;Q:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td width=&quot;97%&quot;&gt;  &lt;b&gt;What is a self join?&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;A:&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Self join is just like any other join, except that two instances of the same table will be joined in the query.&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;Java API&lt;/b&gt;   &lt;br&gt;The Java API is what makes Java attractive and useful. It consists of a set of packages that are distributed with the JDK as class libraries. These packages provide a common interface for developing Java programs on all Java platforms. The Java API furnishes all the capabilities needed to develop console programs, window programs, client and server networking software, applets, and other applications. It is the difference that takes Java from being a really good programming language to making it a very powerful and efficient programming environment.&lt;br&gt;The Java API consists of eight major development packages and a supporting debug package; Packages are collections of related objects. For example, there are separate packages for developing window programs, applets, and networking software.&lt;br&gt;Java packages contain classes, interfaces, and exceptions&lt;br&gt;Classes form the basis for object-oriented software development in Java. They contain variables and methods. Variables are data containers. Methods implement operations on the class and its variables. &lt;br&gt;Interfaces are collections of related methods. An example of an interface is the DataInput interfacee of the java.io package. It specifies a collection of methods that must be defined for a class to implement the DataInput interface. Exceptions are events that alter the normal course of program execution. &lt;b&gt;Java applets&lt;/b&gt;&lt;br&gt;An applet is a mini-program that will run only under a Web browser. The applet is downloaded automatically as part of a Web page. When the applet is activated it executes a program. This is part of its beauty &amp;ndash; it provides you with a way to automatically distribute the client software from the server at the time the user needs the client software, and no sooner. They get the latest version of the client software without fail and without difficult re-installation. Because of the way&lt;br&gt;Java is designed, the programmer needs to create only a single program, and that program automatically works with all computers that have browsers with built-in Java interpreters.&lt;br&gt;&lt;br&gt;Applets are Java programs that execute within the context of a Web page. They interact with the user while his Web page is active and stop their execution when his Web page is no longer active. Applets are valuable because they are simple to use. A user only needs to open an applet&amp;#39;s Web page to download and execute an applet. &lt;br&gt;&lt;br&gt;Java applets, are run from inside a browser. A reference to an applet is embedded in a Web page using a special HTML tag. When a reader, using a Java-enabled browser, loads a Web page with an applet in it, the browser downloads that applet from a Web server and executes it on the local system Because Java applets run inside a Java browser, they have access to the structure the browser provides: an existing window, an event-handling and graphics context, and the surrounding user interface.&lt;br&gt;One advantage a Java applet has over a scripted program is that it&amp;rsquo;s in compiled form, so the source code isn&amp;rsquo;t available to the client.&lt;br&gt;Applet security is a major concern among Web users and applet developers. From a user&amp;#39;s perspective, an exploitable applet security flaw could result in sensitive data being modified or disclosed, or their computer being rendered inoperable. From a developer&amp;#39;s perspective, strong applet security is necessary to make Web users comfortable with using applets. However, too high a level of security limits their applets&amp;#39; capabilities. &lt;b&gt;Struts&lt;/b&gt;&lt;br&gt;Struts is a open source framework which make building of the web applications easier based on the java Servlet and JavaServer pages technologies. &lt;br&gt;&lt;br&gt;Struts framework was created by Craig R. McClanahan and donated to the Apache Software Foundation in 2000. The Project now has several committers, and many developers are contributing to overall to the framework.&lt;br&gt;&lt;br&gt;Developing web application using struts frame work is fairly complex, but it eases things after it is setup. It encourages software development following the MVC design pattern. Many web applications are JSP-only or Servlets-only. With JSP and Servlets, Java code is embedded in the HTML code and the Java code calls println methods to generate the HTML code respectively. Both approaches have their advantages and drawbacks; Struts gathers their strengths to get the best of their association. Struts is based on Model-View-Controller (MVC) design paradigm, it is an implementation of JSP Model 2 Architecture. For more of Model-View-Controller (MVC) click here. &lt;br&gt;&lt;br&gt;Consists of 8 Top-Level Packages and approx 250 Classes and Interfaces. &lt;br&gt;&lt;br&gt;Struts is a set of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design. This definition implies that Struts is a framework, rather than a library, but Struts also contains an extensive tag library and utility classes that work independently of the framework. &lt;br&gt;&lt;br&gt;&lt;b&gt;The overview of struts&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Client browser&lt;/i&gt;&lt;/b&gt;&lt;br&gt;An HTTP request from the client browser creates an event. The Web container will respond with an HTTP response.&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Controller&lt;/i&gt;&lt;/b&gt;&lt;br&gt;The controller is responsible for intercepting and translating user input into actions to&lt;br&gt;be performed by the model. The controller is responsible for selecting the next view based on user input and the outcome of model operations.The Controller receives the request from the browser, and makes the decision where to send the request. With Struts, the Controller is a command design pattern implemented as a servlet. The struts-config.xml file configures the Controller. &lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;Business logic&lt;/i&gt;&lt;/b&gt;&lt;br&gt;The business logic updates the state of the model and helps control the flow of the application. With Struts this is done with an Action class as a thin wrapper to the actual business logic.&lt;br&gt;&lt;b&gt;&lt;i&gt;Model &lt;/i&gt;&lt;/b&gt;&lt;br&gt;A model represents an application&amp;rsquo;s data and contains the logic for accessing and manipulating that data. Any data that is part of the persistent state of the application should reside in the model objects. The business objects update the application state. ActionForm bean represents the Model state at a session or request level, and not at a persistent level. Model services are accessed by the controller for either querying or effecting a change in the model state. The model notifies the view when a state change occurs in the model.The JSP file reads information from the ActionForm bean using JSP tags.&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;i&gt;View&lt;/i&gt;&lt;/b&gt;&lt;br&gt;The view is responsible for rendering the state of the model. The presentation semantics are encapsulated within the view, therefore model data can be adapted for several different kinds of clients.The view modifies itself when a change in the model is communicated to the view. A view forwards user input to the controller.The view is simply a JSP file. There is no flow logic, no business logic, and no model information -- just tags. Tags are one of the things that make Struts unique compared to other frameworks like Velocity. &lt;b&gt;What is RmiJdbc ?&lt;/b&gt; RmiJdbc is a type 3 JDBC driver that can network any local JDBC API. &lt;br&gt;It is just a bridge, not a driver dedicated to a specific database: RmiJdbc works in conjunction with a local JDBC driver on the server side (often a type 1 or type 2 driver, that does not offer remote access facilities). &lt;br&gt;RmiJdbc is made of a server-side component (daemon), and client classes that implement the java.sql.* interfaces. All JDBC classes (like Connection, ResultSet, etc...) are distributed as RMI objects, so that you can distribute as you like the access to any database supporting the JDBC API. &lt;br&gt;&lt;b&gt;Using RmiJdbc is a good idea...&lt;/b&gt; &amp;middot; to access remotely an ODBC datasource (suing the JDBC/ODBC bridge) &amp;middot; to network a database that only offers a local JDBC API (like InstantDB) &lt;b&gt;Using RmiJdbc is a bad idea...&lt;/b&gt; &amp;middot; along with a database that already has a good type 4 driver (like Oracle, PostgreSQL or MySQL) - better use the specific product. &amp;middot; when using JDBc from an applet: RMI is not properly supported by Microsoft Internet Explorer, and using JDBC from an applet is not really a good idea indeed. &lt;b&gt;Some specific usages:&lt;/b&gt; &amp;middot; If you write your own database with a JDBC API, you can use RmiJdbc to network it &amp;middot; If you need serializable JDBC classes, the RmiJdbc client classes are serializable. &lt;b&gt;RmiJdbc Story&lt;/b&gt; RmiJdbc was born in September 1997, at the Inria research center located in Montbonnot, France. The product was financed by GIE Dyade, a joint venture between groupe Bull and Inria. &lt;br&gt;Like many open-source initiatives, RmiJdbc was first a personal work; but its success quickly made it an &amp;quot;official&amp;quot; project. It was ther release under the GPL (Gnu Public License). &lt;br&gt;At the end of 1999, I was thinking of hosting &amp;amp; managing RmiJdbc by myself: RmiJdbc had no more official existence at Inria (I had left a few months ago to create my own company), although it was still hosted on their servers. &lt;br&gt;The ObjectWeb team proposed me to host RmiJdbc and make it one of their projects: I immediately accepted the proposal, and RmiJdbc joined ObjectWeb in June 2000. &lt;br&gt;In may 2001, the RmiJdbc license moved from GPL to LGPL (Lesser Gnu Public License), a license we at ObjectWeb consider more open. &lt;br&gt;Since the beginning of the story, some major contributions came from developers all over the world: for example, JDBC 3.0 is supported, RmiJdbc can be run on a single port, SSL can be used to secure RmiJdbc - and most of this is due to external contributors, as well as many bug fixes and enhancements. &lt;br&gt;In the future, I will do my best to maintain RmiJdbc, and integrate later contributions as efficiently as I can. I hope you will find RmiJdbc friendly and useful, &lt;u&gt;A Bit of History Of JVM&lt;/u&gt; The Java programming language is a general-purpose object-oriented concurrent language. Its syntax is similar to C and C++, but it omits many of the features that make C and C++ complex, confusing, and unsafe. The Java platform was initially developed to address the problems of building software for networked consumer devices. It was designed to support multiple host architectures and to allow secure delivery of software components. To meet these requirements, compiled code had to survive transport across networks, operate on any client, and assure the client that it was safe to run. The popularization of the World Wide Web made these attributes much more interesting. The Internet demonstrated how media-rich content could be made accessible in simple ways. Web browsers such as Mosaic enabled millions of people to roam the Net and made Web surfing part of popular culture. At last there was a medium where what you saw and heard was essentially the same whether you were using a Mac, PC, or UNIX machine, and whether you were connected to a high-speed network or a slow modem. Web enthusiasts soon discovered that the content supported by the Web&amp;#39;s HTML document format was too limited. HTML extensions, such as forms, only highlighted those limitations, while making it clear that no browser could include all the features users wanted. Extensibility was the answer. Sun&amp;#39;s HotJava browser showcases the interesting properties of the Java programming language and platform by making it possible to embed programs inside HTML pages. These programs are transparently downloaded into the HotJava browser along with the HTML pages in which they appear. Before being accepted by the browser, the programs are carefully checked to make sure they are safe. Like HTML pages, compiled programs are network- and host-independent. The programs behave the same way regardless of where they come from or what kind of machine they are being loaded into and run on. A Web browser incorporating the Java or Java 2 platform is no longer limited to a predetermined set of capabilities. Visitors to Web pages incorporating dynamic content can be assured that their machines cannot be damaged by that content. Programmers can write a program once, and it will run on any machine supplying a Java or Java 2 runtime environment. &lt;u&gt;The Java Virtual Machine&lt;/u&gt; The Java virtual machine is the cornerstone of the Java and Java 2 platforms. It is the component of the technology responsible for its hardware- and operating system- independence, the small size of its compiled code, and its ability to protect users from malicious programs. The Java virtual machine is an abstract computing machine. Like a real computing machine, it has an instruction set and manipulates various memory areas at run time. It is reasonably common to implement a programming language using a virtual machine; the best-known virtual machine may be the P-Code machine of UCSD Pascal. The first prototype implementation of the Java virtual machine, done at Sun Microsystems, Inc., emulated the Java virtual machine instruction set in software hosted by a handheld device that resembled a contemporary Personal Digital Assistant (PDA). Sun&amp;#39;s current Java virtual machine implementations, components of its JavaTM 2 SDK and JavaTM 2 Runtime Environment products, emulate the Java virtual machine on Win32 and Solaris hosts in much more sophisticated ways. However, the Java virtual machine does not assume any particular implementation technology, host hardware, or host operating system. It is not inherently interpreted, but can just as well be implemented by compiling its instruction set to that of a silicon CPU. It may also be implemented in microcode or directly in silicon. The Java virtual machine knows nothing of the Java programming language, only of a particular binary format, the class file format. A class file contains Java virtual machine instructions (or bytecodes) and a symbol table, as well as other ancillary information. For the sake of security, the Java virtual machine imposes strong format and structural constraints on the code in a class file. However, any language with functionality that can be expressed in terms of a valid class file can be hosted by the Java virtual machine. Attracted by a generally available, machine-independent platform, implementors of other languages are turning to the Java virtual machine as a delivery vehicle for their languages.&lt;br&gt;&lt;br&gt;&lt;br&gt;  &lt;table align=&quot;center&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;div&gt;1. What is a transient variable?&lt;br&gt;A transient variable is a variable that may not be serialized.&lt;br&gt;&lt;br&gt;2. Which containers use a border Layout as their default layout?&lt;br&gt;The window, Frame and Dialog classes use a border layout as their default layout.&lt;br&gt;&lt;br&gt;3. Why do threads block on I/O?&lt;br&gt;Threads block on I/O (that is enters the waiting state) so that other threads may execute while the I/O Operation is performed.&lt;br&gt;&lt;br&gt;4. How are Observer and Observable used?&lt;br&gt;Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.&lt;br&gt;&lt;br&gt;5. What is synchronization and why is it important?&lt;br&gt;With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object&amp;#39;s value. This often leads to significant errors.&lt;br&gt;&lt;br&gt;6. Can a lock be acquired on a class?&lt;br&gt;Yes, a lock can be acquired on a class. This lock is acquired on the class&amp;#39;s Class object.&lt;br&gt;&lt;br&gt;7. What&amp;#39;s new with the stop(), suspend() and resume() methods in JDK 1.2?&lt;br&gt;The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.&lt;br&gt;8. Is null a keyword?&lt;br&gt;The null value is not a keyword.&lt;br&gt;&lt;br&gt;9. What is the preferred size of a component?&lt;br&gt;The preferred size of a component is the minimum component size that will allow the component to display normally.&lt;br&gt;&lt;br&gt;10. What method is used to specify a container&amp;#39;s layout?&lt;br&gt;The setLayout() method is used to specify a container&amp;#39;s layout.&lt;br&gt;&lt;br&gt;11. Which containers use a FlowLayout as their default layout?&lt;br&gt;The Panel and Applet classes use the FlowLayout as their default layout.&lt;br&gt;&lt;br&gt;12. What state does a thread enter when it terminates its processing?&lt;br&gt;When a thread terminates its processing, it enters the dead state.&lt;br&gt;&lt;br&gt;13. What is the Collections API?&lt;br&gt;The Collections API is a set of classes and interfaces that support operations on collections of objects.&lt;br&gt;&lt;br&gt;14. which characters may be used as the second character of an identifier, but not as the first character of an identifier?&lt;br&gt;The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.&lt;br&gt;15. What is the List interface?&lt;br&gt;The List interface provides support for ordered collections of objects.&lt;br&gt;&lt;br&gt;16. How does Java handle integer overflows and underflows?&lt;br&gt;It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.&lt;br&gt;&lt;br&gt;17. What is the Vector class?&lt;br&gt;The Vector class provides the capability to implement a growable array of objects&lt;br&gt;&lt;br&gt;18. What modifiers may be used with an inner class that is a member of an outer class?&lt;br&gt;A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.&lt;br&gt;&lt;br&gt;19. What is an Iterator interface?&lt;br&gt;The Iterator interface is used to step through the elements of a Collection.&lt;br&gt;&lt;br&gt;20. What is the difference between the &amp;gt;&amp;gt; and &amp;gt;&amp;gt;&amp;gt; operators?&lt;br&gt;The &amp;gt;&amp;gt; operator carries the sign bit when shifting right. The &amp;gt;&amp;gt;&amp;gt; zero-fills bits that have been shifted out.&lt;br&gt;&lt;br&gt;21. Which method of the Component class is used to set the position and size of a component?&lt;br&gt;setBounds()&lt;br&gt;22. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?&lt;br&gt;Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 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.&lt;br&gt;&lt;br&gt;23 What is the difference between yielding and sleeping?&lt;br&gt;When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.&lt;br&gt;&lt;br&gt;24. Which java.util classes and interfaces support event handling?&lt;br&gt;The EventObject class and the EventListener interface support event processing.&lt;br&gt;&lt;br&gt;25. Is sizeof a keyword?&lt;br&gt;The sizeof operator is not a keyword.&lt;br&gt;&lt;br&gt;26. What are wrapper classes?&lt;br&gt;Wrapper classes are classes that allow primitive types to be accessed as objects.&lt;br&gt;&lt;br&gt;27. Does garbage collection guarantee that a program will not run out of memory?&lt;br&gt;Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.&lt;br&gt;&lt;br&gt;28. What restrictions are placed on the location of a package statement within a source code file?&lt;br&gt;A package statement must appear as the first line in a source code file (excluding blank lines and comments).&lt;br&gt;29. Can an object&amp;#39;s finalize() method be invoked while it is reachable?&lt;br&gt;An object&amp;#39;s finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object&amp;#39;s finalize() method may be invoked by other objects.&lt;br&gt;&lt;br&gt;30. What is the immediate superclass of the Applet class?&lt;br&gt;Panel&lt;br&gt;&lt;br&gt;31. What is the difference between preemptive scheduling and time slicing?&lt;br&gt;Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.&lt;br&gt;&lt;br&gt;32. Name three Component subclasses that support painting.&lt;br&gt;The Canvas, Frame, Panel, and Applet classes support painting.&lt;br&gt;&lt;br&gt;33. What value does readLine() return when it has reached the end of a file?&lt;br&gt;The readLine() method returns null when it has reached the end of a file.&lt;br&gt;&lt;br&gt;34. What is the immediate superclass of the Dialog class?&lt;br&gt;Window.&lt;br&gt;&lt;br&gt;35. What is clipping?&lt;br&gt;Clipping is the process of confining paint operations to a limited area or shape.&lt;br&gt;36. What is a native method?&lt;br&gt;A native method is a method that is implemented in a language other than Java.&lt;br&gt;&lt;br&gt;37. Can a for statement loop indefinitely?&lt;br&gt;Yes, a for statement can loop indefinitely. For example, consider the following:&lt;br&gt;for(;;) ;&lt;br&gt;&lt;br&gt;38. What are order of precedence and associativity, and how are they used?&lt;br&gt;Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left&lt;br&gt;&lt;br&gt;39. When a thread blocks on I/O, what state does it enter?&lt;br&gt;A thread enters the waiting state when it blocks on I/O.&lt;br&gt;&lt;br&gt;40. To what value is a variable of the String type automatically initialized?&lt;br&gt;The default value of a String type is null.&lt;br&gt;&lt;br&gt;41. What is the catch or declare rule for method declarations?&lt;br&gt;If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.&lt;br&gt;&lt;br&gt;42. What is the difference between a MenuItem and a CheckboxMenuItem?&lt;br&gt;The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.&lt;br&gt;43. What is a task&amp;#39;s priority and how is it used in scheduling?&lt;br&gt;A task&amp;#39;s priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.&lt;br&gt;&lt;br&gt;44. What class is the top of the AWT event hierarchy?&lt;br&gt;The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.&lt;br&gt;&lt;br&gt;45. When a thread is created and started, what is its initial state?&lt;br&gt;A thread is in the ready state after it has been created and started.&lt;br&gt;&lt;br&gt;46. Can an anonymous class be declared as implementing an interface and extending a class?&lt;br&gt;An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.&lt;br&gt;&lt;br&gt;47. What is the range of the short type?&lt;br&gt;The range of the short type is -(2^15) to 2^15 - 1.&lt;br&gt;&lt;br&gt;48. What is the range of the char type?&lt;br&gt;The range of the char type is 0 to 2^16 - 1.&lt;br&gt;&lt;br&gt;49. In which package are most of the AWT events that support the event-delegation model defined?&lt;br&gt;Most of the AWT-related events of the event-delegation model are defined in the java.awt.event package. The AWTEvent class is defined in the java.awt package.&lt;br&gt;50. What is the immediate superclass of Menu?&lt;br&gt;MenuItem&lt;br&gt;&lt;br&gt;51. What is the purpose of finalization?&lt;br&gt;The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.&lt;br&gt;&lt;br&gt;52. Which class is the immediate superclass of the MenuComponent class.&lt;br&gt;Object&lt;br&gt;&lt;br&gt;53. What invokes a thread&amp;#39;s run() method?&lt;br&gt;After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread&amp;#39;s run() method when the thread is initially executed.&lt;br&gt;&lt;br&gt;54. What is the difference between the Boolean &amp;amp; operator and the &amp;amp;&amp;amp; operator?&lt;br&gt;If an expression involving the Boolean &amp;amp; operator is evaluated, both operands are evaluated. Then the &amp;amp; operator is applied to the operand. When an expression involving the &amp;amp;&amp;amp; operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The &amp;amp;&amp;amp; operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.&lt;br&gt;&lt;br&gt;55. Name three subclasses of the Component class.&lt;br&gt;Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent&lt;br&gt;&lt;br&gt;56. What is the GregorianCalendar class?&lt;br&gt;The GregorianCalendar provides support for traditional Western calendars.&lt;br&gt;57. Which Container method is used to cause a container to be laid out and redisplayed?&lt;br&gt;validate()&lt;br&gt;&lt;br&gt;58. What is the purpose of the Runtime class?&lt;br&gt;The purpose of the Runtime class is to provide access to the Java runtime system.&lt;br&gt;&lt;br&gt;59. How many times may an object&amp;#39;s finalize() method be invoked by the &lt;br&gt;garbage collector?&lt;br&gt;An object&amp;#39;s finalize() method may only be invoked once by the garbage collector.&lt;br&gt;&lt;br&gt;60. What is the purpose of the finally clause of a try-catch-finally statement?&lt;br&gt;The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.&lt;br&gt;&lt;br&gt;61. What is the argument type of a program&amp;#39;s main() method?&lt;br&gt;A program&amp;#39;s main() method takes an argument of the String[] type.&lt;br&gt;&lt;br&gt;62. Which Java operator is right associative?&lt;br&gt;The = operator is right associative.&lt;br&gt;&lt;br&gt;63. What is the Locale class?&lt;br&gt;The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.64. Can a double value be cast to a byte?&lt;br&gt;Yes, a double value can be cast to a byte.&lt;br&gt;&lt;br&gt;65. What is the difference between a break statement and a continue statement?&lt;br&gt;A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.&lt;br&gt;&lt;br&gt;66. What must a class do to implement an interface?&lt;br&gt;It must provide all of the methods in the interface and identify the interface in its implements clause.&lt;br&gt;&lt;br&gt;67. What method is invoked to cause an object to begin executing as a separate thread?&lt;br&gt;The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.&lt;br&gt;&lt;br&gt;68. Name two subclasses of the TextComponent class.&lt;br&gt;TextField and TextArea&lt;br&gt;&lt;br&gt;69. What is the advantage of the event-delegation model over the earlier event-inheritance model?&lt;br&gt;The event-delegation model has two advantages over the event-inheritance model. First, it enables event handling to be handled by objects other than the ones that generate the events (or their containers). This allows a clean separation between a component&amp;#39;s design and its use. The other advantage of the event-delegation model is that 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 &lt;br&gt;model.&lt;br&gt;&lt;br&gt;70. Which containers may have a MenuBar?&lt;br&gt;Frame&lt;br&gt;71. How are commas used in the initialization and iteration parts of a for statement?&lt;br&gt;Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.&lt;br&gt;&lt;br&gt;72. What is the purpose of the wait(), notify(), and notifyAll() methods?&lt;br&gt;The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object&amp;#39;s wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object&amp;#39;s notify() or notifyAll() methods.&lt;br&gt;&lt;br&gt;73. What is an abstract method?&lt;br&gt;An abstract method is a method whose implementation is deferred to a subclass.&lt;br&gt;&lt;br&gt;74. How are Java source code files named?&lt;br&gt;A Java source code file takes the name of a public class or interface that is defined within the file. A source code file may contain at most one public class or interface. If a public class or interface is defined within a source code file, then the source code file must take the name of the public class or interface. If no public class or interface is defined within a source code file, then the file must take on a name that is different than its classes and interfaces. Source code files use the .java extension.&lt;br&gt;&lt;br&gt;75. What is the relationship between the Canvas class and the Graphics class?&lt;br&gt;A Canvas object provides access to a Graphics object via its paint() method.&lt;br&gt;&lt;br&gt;76. What are the high-level thread states?&lt;br&gt;The high-level thread states are ready, running, waiting, and dead.&lt;br&gt;&lt;br&gt;77. What value does read() return when it has reached the end of a file?&lt;br&gt;The read() method returns -1 when it has reached the end of a file.&lt;br&gt;78. Can a Byte object be cast to a double value?&lt;br&gt;No, an object cannot be cast to a primitive value.&lt;br&gt;&lt;br&gt;79. What is the difference between a static and a non-static inner class?&lt;br&gt;A non-static inner class may have object instances that are associated with instances of the class&amp;#39;s outer class. A static inner class does not have any object instances.&lt;br&gt;&lt;br&gt;80. What is the difference between the String and StringBuffer classes?&lt;br&gt;String objects are constants. StringBuffer objects are not.&lt;br&gt;&lt;br&gt;81. If a variable is declared as private, where may the variable be accessed?&lt;br&gt;A private variable may only be accessed within the class in which it is declared.&lt;br&gt;&lt;br&gt;82. What is an object&amp;#39;s lock and which objects have locks?&lt;br&gt;An object&amp;#39;s lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object&amp;#39;s lock. All objects and classes have locks. A class&amp;#39;s lock is acquired on the class&amp;#39;s Class object.&lt;br&gt;&lt;br&gt;83. What is the Dictionary class?&lt;br&gt;The Dictionary class provides the capability to store key-value pairs.&lt;br&gt;&lt;br&gt;84. How are the elements of a BorderLayout organized?&lt;br&gt;The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.&lt;br&gt;85. What is the % operator?&lt;br&gt;It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.&lt;br&gt;&lt;br&gt;86. When can an object reference be cast to an interface reference?&lt;br&gt;An object reference be cast to an interface reference when the object implements the referenced interface.&lt;br&gt;&lt;br&gt;87. What is the difference between a Window and a Frame?&lt;br&gt;The Frame class extends Window to define a main application window that can have a menu bar.&lt;br&gt;&lt;br&gt;88. Which class is extended by all other classes?&lt;br&gt;The Object class is extended by all other classes.&lt;br&gt;&lt;br&gt;89. Can an object be garbage collected while it is still reachable?&lt;br&gt;A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected..&lt;br&gt;&lt;br&gt;90. Is the ternary operator written x : y ? z or x ? y : z ?&lt;br&gt;It is written x ? y : z.&lt;br&gt;&lt;br&gt;91. What is the difference between the Font and FontMetrics classes?&lt;br&gt;The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.&lt;br&gt;92. How is rounding performed under integer division?&lt;br&gt;The fractional part of the result is truncated. This is known as rounding toward zero.&lt;br&gt;&lt;br&gt;93. What happens when a thread cannot acquire a lock on an object?&lt;br&gt;If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object&amp;#39;s lock, it enters the waiting state until the lock becomes available.&lt;br&gt;&lt;br&gt;94. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?&lt;br&gt;The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.&lt;br&gt;&lt;br&gt;95. What classes of exceptions may be caught by a catch clause?&lt;br&gt;A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.&lt;br&gt;&lt;br&gt;96. If a class is declared without any access modifiers, where may the class be accessed?&lt;br&gt;A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.&lt;br&gt;&lt;br&gt;97. What is the SimpleTimeZone class?&lt;br&gt;The SimpleTimeZone class provides support for a Gregorian calendar.&lt;br&gt;&lt;br&gt;98. What is the Map interface?&lt;br&gt;The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.99. Does a class inherit the constructors of its superclass?&lt;br&gt;A class does not inherit constructors from any of its super classes.&lt;br&gt;&lt;br&gt;100. For which statements does it make sense to use a label?&lt;br&gt;The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement.&lt;br&gt;&lt;br&gt;101. What is the purpose of the System class?&lt;br&gt;The purpose of the System class is to provide access to system resources.&lt;br&gt;&lt;br&gt;102. Which TextComponent method is used to set a TextComponent to the read-only state?&lt;br&gt;setEditable()&lt;br&gt;&lt;br&gt;103. How are the elements of a CardLayout organized?&lt;br&gt;The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.&lt;br&gt;&lt;br&gt;104. Is &amp;amp;&amp;amp;= a valid Java operator?&lt;br&gt;No, it is not.&lt;br&gt;&lt;br&gt;105. Name the eight primitive Java types.&lt;br&gt;The eight primitive types are byte, char, short, int, long, float, double, and boolean.&lt;br&gt;106. Which class should you use to obtain design information about an object?&lt;br&gt;The Class class is used to obtain information about an object&amp;#39;s design.&lt;br&gt;&lt;br&gt;107. What is the relationship between clipping and repainting?&lt;br&gt;When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.&lt;br&gt;&lt;br&gt;108. Is &amp;quot;abc&amp;quot; a primitive value?&lt;br&gt;The String literal &amp;quot;abc&amp;quot; is not a primitive value. It is a String object.&lt;br&gt;&lt;br&gt;109. What is the relationship between an event-listener interface and an event-adapter class?&lt;br&gt;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.&lt;br&gt;&lt;br&gt;110. What restrictions are placed on the values of each case of a switch statement?&lt;br&gt;During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.&lt;br&gt;&lt;br&gt;111. What modifiers may be used with an interface declaration?&lt;br&gt;An interface may be declared as public or abstract.&lt;br&gt;&lt;br&gt;112. Is a class a subclass of itself?&lt;br&gt;A class is a subclass of itself.&lt;br&gt;113. What is the highest-level event class of the event-delegation model?&lt;br&gt;The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.&lt;br&gt;&lt;br&gt;114. What event results from the clicking of a button?&lt;br&gt;The ActionEvent event is generated as the result of the clicking of a button.&lt;br&gt;&lt;br&gt;115. How can a GUI component handle its own events?&lt;br&gt;A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.&lt;br&gt;&lt;br&gt;116. What is the difference between a while statement and a do statement?&lt;br&gt;A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.&lt;br&gt;&lt;br&gt;117. How are the elements of a GridBagLayout organized?&lt;br&gt;The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.&lt;br&gt;&lt;br&gt;118. What advantage do Java&amp;#39;s layout managers provide over traditional windowing systems?&lt;br&gt;Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java&amp;#39;s layout managers aren&amp;#39;t tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.&lt;br&gt;&lt;br&gt;119. What is the Collection interface?&lt;br&gt;The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.&lt;br&gt;120. What modifiers can be used with a local inner class?&lt;br&gt;A local inner class may be final or abstract.&lt;br&gt;&lt;br&gt;121. What is the difference between static and non-static variables?&lt;br&gt;A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.&lt;br&gt;&lt;br&gt;122. What is the difference between the paint() and repaint() methods?&lt;br&gt;The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.&lt;br&gt;&lt;br&gt;123. What is the purpose of the File class?&lt;br&gt;The File class is used to create objects that provide access to the files and directories of a local file system.&lt;br&gt;&lt;br&gt;124. Can an exception be rethrown?&lt;br&gt;Yes, an exception can be rethrown.&lt;br&gt;&lt;br&gt;125. Which Math method is used to calculate the absolute value of a number?&lt;br&gt;The abs() method is used to calculate absolute values.&lt;br&gt;&lt;br&gt;126. How does multithreading take place on a computer with a single CPU?&lt;br&gt;The operating system&amp;#39;s task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.&lt;br&gt;127. When does the compiler supply a default constructor for a class?&lt;br&gt;The compiler supplies a default constructor for a class if no other constructors are provided.&lt;br&gt;&lt;br&gt;128. When is the finally clause of a try-catch-finally statement executed?&lt;br&gt;The finally clause of the try-catch-finally statement is always executed unless the thread of execution terminates or an exception occurs within the execution of the finally clause.&lt;br&gt;&lt;br&gt;129. Which class is the immediate superclass of the Container class?&lt;br&gt;Component&lt;br&gt;&lt;br&gt;130. If a method is declared as protected, where may the method be accessed?&lt;br&gt;A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.&lt;br&gt;&lt;br&gt;131. How can the Checkbox class be used to create a radio button?&lt;br&gt;By associating Checkbox objects with a CheckboxGroup.&lt;br&gt;&lt;br&gt;132. Which non-Unicode letter characters may be used as the first character of an identifier?&lt;br&gt;The non-Unicode letter characters $ and _ may appear as the first character of an identifier&lt;br&gt;&lt;br&gt;133. What restrictions are placed on method overloading?&lt;br&gt;Two methods may not have the same name and argument list but different return types.&lt;br&gt;134. What happens when you invoke a thread&amp;#39;s interrupt method while it is sleeping or waiting?&lt;br&gt;When a task&amp;#39;s interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.&lt;br&gt;&lt;br&gt;135. What is casting?&lt;br&gt;There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference.&lt;br&gt;&lt;br&gt;136. What is the return type of a program&amp;#39;s main() method?&lt;br&gt;A program&amp;#39;s main() method has a void return type.&lt;br&gt;&lt;br&gt;137. Name four Container classes.&lt;br&gt;Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane&lt;br&gt;&lt;br&gt;138. What is the difference between a Choice and a List?&lt;br&gt;A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.&lt;br&gt;&lt;br&gt;139. What class of exceptions are generated by the Java run-time system?&lt;br&gt;The Java runtime system generates RuntimeException and Error exceptions.&lt;br&gt;&lt;br&gt;140. What class allows you to read objects directly from a stream?&lt;br&gt;The ObjectInputStream class supports the reading of objects from input streams.&lt;br&gt;141. What is the difference between a field variable and a local variable?&lt;br&gt;A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.&lt;br&gt;&lt;br&gt;142. Under what conditions is an object&amp;#39;s finalize() method invoked by the garbage collector?&lt;br&gt;The garbage collector invokes an object&amp;#39;s finalize() method when it detects that the object has become unreachable.&lt;br&gt;&lt;br&gt;143. How are this () and super () used with constructors?&lt;br&gt;this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.&lt;br&gt;&lt;br&gt;144. What is the relationship between a method&amp;#39;s throws clause and the exceptions that can be thrown during the method&amp;#39;s execution?&lt;br&gt;A method&amp;#39;s throws clause must declare any checked exceptions that are not caught within the body of the method.&lt;br&gt;&lt;br&gt;145. What is the difference between the JDK 1.02 event model and the event-delegation model introduced with JDK 1.1?&lt;br&gt;The JDK 1.02 event model uses an event inheritance or bubbling approach. In this model, components are required to handle their own events. If they do not handle a particular event, the event is inherited by (or bubbled up to) the component&amp;#39;s container. The container then either handles the event or it is bubbled up to its container and so on, until the highest-level container has been tried.&lt;br&gt;In the event-delegation model, specific objects are designated as event handlers for GUI components. These objects implement event-listener interfaces. The event-delegation model is more efficient than the event-inheritance model because it eliminates the processing required to support the bubbling of unhandled events.&lt;br&gt;&lt;br&gt;146. How is it possible for two String objects with identical values not to be equal under the == operator?&lt;br&gt;The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory.&lt;br&gt;&lt;br&gt;147. Why are the methods of the Math class static?&lt;br&gt;So they can be invoked as if they are a mathematical code library.&lt;br&gt;148. What Checkbox method allows you to tell if a Checkbox is checked?&lt;br&gt;getState()&lt;br&gt;&lt;br&gt;149. What state is a thread in when it is executing?&lt;br&gt;An executing thread is in the running state.&lt;br&gt;&lt;br&gt;150. What are the legal operands of the instanceof operator?&lt;br&gt;The left operand is an object reference or null value and the right operand is a class, interface, or array type.&lt;br&gt;&lt;br&gt;151. How are the elements of a GridLayout organized?&lt;br&gt;The elements of a GridBad layout are of equal size and are laid out using the squares of a grid.&lt;br&gt;&lt;br&gt;152. What an I/O filter?&lt;br&gt;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.&lt;br&gt;&lt;br&gt;153. If an object is garbage collected, can it become reachable again?&lt;br&gt;Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.&lt;br&gt;&lt;br&gt;154. What is the Set interface?&lt;br&gt;The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements. &lt;br&gt;155. What classes of exceptions may be thrown by a throw statement?&lt;br&gt;A throw statement may throw any expression that may be assigned to the Throwable type.&lt;br&gt;&lt;br&gt;156. What are E and PI?&lt;br&gt;E is the base of the natural logarithm and PI is mathematical value pi.&lt;br&gt;&lt;br&gt;157. Are true and false keywords?&lt;br&gt;The values true and false are not keywords.&lt;br&gt;&lt;br&gt;158. What is a void return type?&lt;br&gt;A void return type indicates that a method does not return a value.&lt;br&gt;&lt;br&gt;159. What is the purpose of the enableEvents() method?&lt;br&gt;The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.&lt;br&gt;&lt;br&gt;160. What is the difference between the File and RandomAccessFile classes?&lt;br&gt;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.&lt;br&gt;&lt;br&gt;161. What happens when you add a double value to a String?&lt;br&gt;The result is a String object.162. What is your platform&amp;#39;s default character encoding?&lt;br&gt;If you are running Java on English Windows platforms, it is probably Cp1252. If you are running Java on English Solaris platforms, it is most likely 8859_1..&lt;br&gt;&lt;br&gt;163. Which package is always imported by default?&lt;br&gt;The java.lang package is always imported by default.&lt;br&gt;&lt;br&gt;164. What interface must an object implement before it can be written to a stream as an object?&lt;br&gt;An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.&lt;br&gt;&lt;br&gt;165. How are this and super used?&lt;br&gt;this is used to refer to the current object instance. super is used to refer to the variables and methods of the superclass of the current object instance.&lt;br&gt;&lt;br&gt;166. What is the purpose of garbage collection?&lt;br&gt;The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources may be reclaimed and &lt;br&gt;reused.&lt;br&gt;&lt;br&gt;167. What is a compilation unit?&lt;br&gt;A compilation unit is a Java source code file.&lt;br&gt;&lt;br&gt;168. What interface is extended by AWT event listeners?&lt;br&gt;All AWT event listeners extend the java.util.EventListener interface.&lt;br&gt;169. What restrictions are placed on method overriding?&lt;br&gt;Overridden methods must have the same name, argument list, and return type. &lt;br&gt;The overriding method may not limit the access of the method it overrides. &lt;br&gt;The overriding method may not throw any exceptions that may not be thrown &lt;br&gt;by the overridden method.&lt;br&gt;&lt;br&gt;170. How can a dead thread be restarted?&lt;br&gt;A dead thread cannot be restarted.&lt;br&gt;&lt;br&gt;171. What happens if an exception is not caught?&lt;br&gt;An uncaught exception results in the uncaughtException() method of the thread&amp;#39;s ThreadGroup being invoked, which eventually results in the termination of the program in which it is thrown.&lt;br&gt;&lt;br&gt;172. What is a layout manager?&lt;br&gt;A layout manager is an object that is used to organize components in a container.&lt;br&gt;&lt;br&gt;173. Which arithmetic operations can result in the throwing of an ArithmeticException?&lt;br&gt;Integer / and % can result in the throwing of an ArithmeticException.&lt;br&gt;&lt;br&gt;174. What are three ways in which a thread can enter the waiting state?&lt;br&gt;A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object&amp;#39;s lock, or by invoking an object&amp;#39;s wait() method. It can also enter the waiting state by invoking its &lt;br&gt;(deprecated) suspend() method.&lt;br&gt;&lt;br&gt;175. Can an abstract class be final?&lt;br&gt;An abstract class may not be declared as final.176. What is the ResourceBundle class?&lt;br&gt;The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program&amp;#39;s appearance to the particular locale in which it is being run.&lt;br&gt;&lt;br&gt;177. What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?&lt;br&gt;The exception propagates up to the next higher level try-catch statement (if any) or results in the program&amp;#39;s termination.&lt;br&gt;&lt;br&gt;178. What is numeric promotion?&lt;br&gt;Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int &lt;br&gt;values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required.&lt;br&gt;&lt;br&gt;179. What is the difference between a Scrollbar and a ScrollPane?&lt;br&gt;A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.&lt;br&gt;&lt;br&gt;180. What is the difference between a public and a non-public class?&lt;br&gt;A public class may be accessed outside of its package. A non-public class may not be accessed outside of its package.&lt;br&gt;&lt;br&gt;181. To what value is a variable of the boolean type automatically initialized?&lt;br&gt;The default value of the boolean type is false.&lt;br&gt;&lt;br&gt;182. Can try statements be nested?&lt;br&gt;Try statements may be tested.&lt;br&gt;183. What is the difference between the prefix and postfix forms of the ++ operator?&lt;br&gt;The prefix form performs the increment operation and returns the value of the increment operation. The postfix form returns the current value all of the expression and then performs the increment operation on that value.&lt;br&gt;&lt;br&gt;184. What is the purpose of a statement block?&lt;br&gt;A statement block is used to organize a sequence of statements as a single statement group.&lt;br&gt;&lt;br&gt;185. What is a Java package and how is it used?&lt;br&gt;A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.&lt;br&gt;&lt;br&gt;186. What modifiers may be used with a top-level class?&lt;br&gt;A top-level class may be public, abstract, or final.&lt;br&gt;&lt;br&gt;187. What are the Object and Class classes used for?&lt;br&gt;The Object class is the highest-level class in the Java class hierarchy. The Class class is used to represent the classes and interfaces that are loaded by a Java program.&lt;br&gt;&lt;br&gt;188. How does a try statement determine which catch clause should be used to handle an exception?&lt;br&gt;When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. &lt;br&gt;The remaining catch clauses are ignored.&lt;br&gt;&lt;br&gt;189. Can an unreachable object become reachable again?&lt;br&gt;An unreachable object may become reachable again. This can happen when the object&amp;#39;s finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.190. When is an object subject to garbage collection?&lt;br&gt;An object is subject to garbage collection when it becomes unreachable to the program in which it is used.&lt;br&gt;&lt;br&gt;191. What method must be implemented by all threads?&lt;br&gt;All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.&lt;br&gt;&lt;br&gt;192. What methods are used to get and set the text label displayed by a Button object?&lt;br&gt;getLabel() and setLabel()&lt;br&gt;&lt;br&gt;193. Which Component subclass is used for drawing and painting?&lt;br&gt;Canvas&lt;br&gt;&lt;br&gt;194. What are synchronized methods and synchronized statements?&lt;br&gt;Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method&amp;#39;s object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement195. What are the two basic ways in which classes that can be run as threads may be defined?&lt;br&gt;A thread class may be declared as a subclass of Thread, or it may implement the Runnable interface.&lt;br&gt;&lt;br&gt;196. What are the problems faced by Java programmers who don&amp;#39;t use layout managers?&lt;br&gt;Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system.&lt;br&gt;&lt;br&gt;197. What is the difference between an if statement and a switch statement?&lt;br&gt;The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed.&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>our galary</title><link>http://faqworldofrastogi.wetpaint.com/page/our+galary</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/our+galary</guid><pubDate>Tue, 27 Feb 2007 02:28:54 CST</pubDate><description>&lt;b&gt;&lt;br&gt;&lt;/b&gt;    &lt;table align=&quot;bottom&quot; class=&quot;wp-border-none&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;   &lt;br&gt;&lt;br&gt;Type your photo caption or credit here.&lt;/td&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;  &lt;br&gt;&lt;br&gt; &lt;br&gt;&lt;/td&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;   &lt;br&gt;&lt;br&gt;Type your photo caption or credit here.&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;  &lt;br&gt; &lt;br&gt;&lt;br&gt;Type your photo caption or credit here.&lt;/td&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;  &lt;br&gt; &lt;br&gt;&lt;br&gt;Type your photo caption or credit here.&lt;/td&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;  &lt;br&gt; &lt;br&gt;&lt;br&gt;Type your photo caption or credit here.&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;  &lt;br&gt; &lt;br&gt;&lt;br&gt;Type your photo caption or credit here.&lt;/td&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;  &lt;br&gt; &lt;br&gt;&lt;br&gt;Type your photo caption or credit here.&lt;/td&gt;  &lt;td align=&quot;middle&quot; class=&quot;wp-border-none&quot; width=&quot;33%&quot;&gt;  &lt;br&gt; &lt;br&gt;&lt;br&gt;Type your photo caption or credit here.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>C Apptitude Test</title><link>http://faqworldofrastogi.wetpaint.com/page/C+Apptitude+Test</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/C+Apptitude+Test</guid><pubDate>Wed, 22 Nov 2006 03:20:09 CST</pubDate><description>C,C++ Questions&lt;br&gt;1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived &lt;br&gt;object,. calling of that virtual method will result in which method being called?  &lt;br&gt;a. Base method &lt;br&gt;b. Derived method..&lt;br&gt;&lt;b&gt;Ans. B&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;/b&gt; &lt;br&gt;2. For the following C program&lt;br&gt;#define AREA(x)(3.14*x*x)&lt;br&gt;main()&lt;br&gt;{float r1=6.25,r2=2.5,a;&lt;br&gt;a=AREA(r1);&lt;br&gt;printf(&amp;quot;\n Area of the circle is %f&amp;quot;, a);&lt;br&gt;a=AREA(r2);&lt;br&gt;printf(&amp;quot;\n Area of the circle is %f&amp;quot;, a);&lt;br&gt;}&lt;br&gt;What is the output?&lt;br&gt;&lt;b&gt;Ans. Area of the circle is 122.656250&lt;br&gt;        Area of the circle is  19.625000&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt; &lt;br&gt;3. What do the following statements indicate. Explain.   &amp;middot;         int(*p)[10]   &amp;middot;         int*f()   &amp;middot;         int(*pf)()   &amp;middot;         int*p[10] &lt;br&gt;&lt;b&gt;Refer to:&lt;br&gt;-- Kernighan &amp;amp; Ritchie page no. 122&lt;br&gt;-- Schaum series page no. 323&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;4.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int d=5;&lt;br&gt;printf(&amp;quot;%f&amp;quot;,d);&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans: Undefined&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt;&lt;br&gt;5. &lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int i;&lt;br&gt;for(i=1;i&amp;lt;4,i++)&lt;br&gt;switch(i)&lt;br&gt;case 1: printf(&amp;quot;%d&amp;quot;,i);break;&lt;br&gt;{&lt;br&gt;case 2:printf(&amp;quot;%d&amp;quot;,i);break;&lt;br&gt;case 3:printf(&amp;quot;%d&amp;quot;,i);break;&lt;br&gt;}&lt;br&gt;switch(i) case 4:printf(&amp;quot;%d&amp;quot;,i);&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans: 1,2,3,4 &lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;6.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;char *s=&amp;quot;\12345s\n&amp;quot;;&lt;br&gt;printf(&amp;quot;%d&amp;quot;,sizeof(s));&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans: 6&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;7. &lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;unsigned i=1; /* unsigned char k= -1 =&amp;gt; k=255; */&lt;br&gt;signed j=-1; /* char k= -1 =&amp;gt; k=65535 */&lt;br&gt;/* unsigned or signed int k= -1 =&amp;gt;k=65535 */&lt;br&gt;if(i&amp;lt;j)&lt;br&gt;printf(&amp;quot;less&amp;quot;);&lt;br&gt;else&lt;br&gt;if(i&amp;gt;j)&lt;br&gt;printf(&amp;quot;greater&amp;quot;);&lt;br&gt;else&lt;br&gt;if(i==j)&lt;br&gt;printf(&amp;quot;equal&amp;quot;);&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans: less&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt;&lt;br&gt;8.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;float j;&lt;br&gt;j=1000*1000;&lt;br&gt;printf(&amp;quot;%f&amp;quot;,j);&lt;br&gt;}&lt;br&gt;&lt;br&gt;1. 1000000&lt;br&gt;2. Overflow&lt;br&gt;3. Error&lt;br&gt;4. None &lt;br&gt;&lt;b&gt;Ans: 4 &lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;9.  How do you declare an array of N pointers to functions returning&lt;br&gt;     pointers to functions returning pointers to characters?&lt;br&gt;&lt;br&gt;&lt;b&gt;Ans: The first part of this question can be answered in at least&lt;br&gt;        three ways:&lt;br&gt;&lt;br&gt;    1. char *(*(*a[N])())();&lt;br&gt;&lt;br&gt;    2. Build the declaration up incrementally, using typedefs:&lt;br&gt;&lt;br&gt;        typedef char *pc;    /* pointer to char */&lt;br&gt;        typedef pc fpc();    /* function returning pointer to char */&lt;br&gt;        typedef fpc *pfpc;    /* pointer to above */&lt;br&gt;        typedef pfpc fpfpc();    /* function returning... */&lt;br&gt;        typedef fpfpc *pfpfpc;    /* pointer to... */&lt;br&gt;        pfpfpc a[N];         /* array of... */&lt;br&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;    3. Use the cdecl program, which turns English into C and vice&lt;br&gt;    versa:&lt;br&gt;&lt;br&gt;        cdecl&amp;gt; declare a as array of pointer to function returning&lt;br&gt;            pointer to function returning pointer to char&lt;br&gt;        char *(*(*a[])())()&lt;br&gt;&lt;br&gt;    cdecl can also explain complicated declarations, help with&lt;br&gt;    casts, and indicate which set of parentheses the arguments&lt;br&gt;    go in (for complicated function definitions, like the one&lt;br&gt;    above). &lt;br&gt;    Any good book on C should explain how to read these complicated&lt;br&gt;    C declarations &amp;quot;inside out&amp;quot; to understand them (&amp;quot;declaration&lt;br&gt;    mimics use&amp;quot;).&lt;br&gt;    The pointer-to-function declarations in the examples above have&lt;br&gt;    not included parameter type information. When the parameters&lt;br&gt;    have complicated types, declarations can *really* get messy.&lt;br&gt;    (Modern versions of cdecl can help here, too.)&lt;br&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;10. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers.&lt;br&gt;    Write the way to initialize the 2nd element to 10.&lt;br&gt;&lt;br&gt;11. In the above question an array of pointers is declared.&lt;br&gt;    Write the statement to initialize the 3rd element of the 2 element to 10;&lt;br&gt;&lt;br&gt;12.&lt;br&gt;int f()&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;f(1);&lt;br&gt;f(1,2);&lt;br&gt;f(1,2,3);&lt;br&gt;}&lt;br&gt;f(int i,int j,int k)&lt;br&gt;{&lt;br&gt;printf(&amp;quot;%d %d %d&amp;quot;,i,j,k);&lt;br&gt;}&lt;br&gt;&lt;br&gt;What are the number of syntax errors in the above? &lt;br&gt;&lt;br&gt;&lt;b&gt;Ans: None.&lt;/b&gt;&lt;br&gt;&lt;br&gt;13. &lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int i=7;&lt;br&gt;printf(&amp;quot;%d&amp;quot;,i++*i++);&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;b&gt;Ans: 56&lt;/b&gt;&lt;br&gt;&lt;br&gt;14. &lt;br&gt;#define one 0&lt;br&gt;#ifdef one &lt;br&gt;printf(&amp;quot;one is defined &amp;quot;);&lt;br&gt;#ifndef one&lt;br&gt;printf(&amp;quot;one is not defined &amp;quot;);&lt;br&gt;&lt;br&gt;&lt;b&gt;Ans: &amp;quot;one is defined&amp;quot;&lt;br&gt;&lt;br&gt;&lt;/b&gt;&lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;15.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int count=10,*temp,sum=0;&lt;br&gt;temp=&amp;amp;count;&lt;br&gt;*temp=20;&lt;br&gt;temp=&amp;amp;sum;&lt;br&gt;*temp=count;&lt;br&gt;printf(&amp;quot;%d %d %d &amp;quot;,count,*temp,sum);&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;b&gt;Ans: 20 20 20&lt;br&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;16. There was question in c working only on unix machine with pattern matching.&lt;br&gt;&lt;br&gt;&lt;br&gt;14. what is alloca()&lt;br&gt;&lt;b&gt;Ans : It allocates and frees memory after use/after getting out of scope&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;17. &lt;br&gt;main()&lt;br&gt;{&lt;br&gt;static i=3;&lt;br&gt;printf(&amp;quot;%d&amp;quot;,i--);&lt;br&gt;return i&amp;gt;0 ? main():0;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;b&gt;Ans: 321&lt;/b&gt;&lt;br&gt;&lt;br&gt;18. &lt;br&gt;char *foo()&lt;br&gt;{&lt;br&gt;char result[100]);&lt;br&gt;strcpy(result,&amp;quot;anything is good&amp;quot;);&lt;br&gt;return(result);&lt;br&gt;}&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;char *j;&lt;br&gt;j=foo()&lt;br&gt;printf(&amp;quot;%s&amp;quot;,j);&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;b&gt;Ans: anything is good.&lt;/b&gt;&lt;br&gt; &lt;br&gt;19.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;char *s[]={ &amp;quot;dharma&amp;quot;,&amp;quot;hewlett-packard&amp;quot;,&amp;quot;siemens&amp;quot;,&amp;quot;ibm&amp;quot;};&lt;br&gt;char **p;&lt;br&gt;p=s;&lt;br&gt;printf(&amp;quot;%s&amp;quot;,++*p);&lt;br&gt;printf(&amp;quot;%s&amp;quot;,*p++);&lt;br&gt;printf(&amp;quot;%s&amp;quot;,++*p);&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans: &amp;quot;harma&amp;quot; (p-&amp;gt;add(dharma) &amp;amp;&amp;amp; (*p)-&amp;gt;harma)&lt;br&gt;&amp;quot;harma&amp;quot; (after printing, p-&amp;gt;add(hewlett-packard) &amp;amp;&amp;amp;(*p)-&amp;gt;harma)&lt;br&gt;&amp;quot;ewlett-packard&amp;quot; &lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;20. Output of the following program is&lt;br&gt;main()&lt;br&gt;{int i=0;&lt;br&gt;for(i=0;i&amp;lt;20;i++)&lt;br&gt;{switch(i)&lt;br&gt;case 0:i+=5;&lt;br&gt;case 1:i+=2;&lt;br&gt;case 5:i+=5;&lt;br&gt;default i+=4;&lt;br&gt;break;}&lt;br&gt;printf(&amp;quot;%d,&amp;quot;,i);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;a) 0,5,9,13,17&lt;br&gt;b) 5,9,13,17&lt;br&gt;c) 12,17,22&lt;br&gt;d) 16,21&lt;br&gt;e) Syntax error&lt;br&gt;&lt;b&gt;Ans. (d)&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;21. What is the ouptut in the following program&lt;br&gt;main()&lt;br&gt;{char c=-64;&lt;br&gt;int i=-32&lt;br&gt;unsigned int u =-16;&lt;br&gt;if(c&amp;gt;i)&lt;br&gt;{printf(&amp;quot;pass1,&amp;quot;);&lt;br&gt;if(c&amp;lt;u)&lt;br&gt;printf(&amp;quot;pass2&amp;quot;);&lt;br&gt;else&lt;br&gt;printf(&amp;quot;Fail2&amp;quot;);&lt;br&gt;}&lt;br&gt;else&lt;br&gt;printf(&amp;quot;Fail1);&lt;br&gt;if(i&amp;lt;u)&lt;br&gt;printf(&amp;quot;pass2&amp;quot;);&lt;br&gt;else&lt;br&gt;printf(&amp;quot;Fail2&amp;quot;)&lt;br&gt;}&lt;br&gt;a) Pass1,Pass2&lt;br&gt;b) Pass1,Fail2&lt;br&gt;c) Fail1,Pass2&lt;br&gt;d) Fail1,Fail2&lt;br&gt;e) None of these&lt;br&gt;&lt;b&gt;Ans. (c)&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;22. What will the following program do?&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int i;&lt;br&gt;char a[]=&amp;quot;String&amp;quot;;&lt;br&gt;char *p=&amp;quot;New Sring&amp;quot;;&lt;br&gt;char *Temp;&lt;br&gt;Temp=a;&lt;br&gt;a=malloc(strlen(p) + 1);&lt;br&gt;strcpy(a,p); //Line number:9//&lt;br&gt;p = malloc(strlen(Temp) + 1);&lt;br&gt;strcpy(p,Temp);&lt;br&gt;printf(&amp;quot;(%s, %s)&amp;quot;,a,p);&lt;br&gt;free(p);&lt;br&gt;free(a);&lt;br&gt;} //Line number 15//&lt;br&gt;a) Swap contents of p &amp;amp; a and print:(New string, string)&lt;br&gt;b) Generate compilation error in line number 8&lt;br&gt;c) Generate compilation error in line number 5&lt;br&gt;d) Generate compilation error in line number 7&lt;br&gt;e) Generate compilation error in line number 1&lt;br&gt;&lt;b&gt;Ans. (b)&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;23. In the following code segment what will be the result of the function, &lt;br&gt;value of x , value of y&lt;br&gt;{unsigned int x=-1;&lt;br&gt;int y;&lt;br&gt;y = ~0;&lt;br&gt;if(x == y)&lt;br&gt;printf(&amp;quot;same&amp;quot;);&lt;br&gt;else&lt;br&gt;printf(&amp;quot;not same&amp;quot;);&lt;br&gt;}&lt;br&gt;a) same, MAXINT, -1&lt;br&gt;b) not same, MAXINT, -MAXINT&lt;br&gt;c) same , MAXUNIT, -1&lt;br&gt;d) same, MAXUNIT, MAXUNIT&lt;br&gt;e) not same, MAXINT, MAXUNIT&lt;br&gt;&lt;b&gt;Ans. (a)&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;24. What will be the result of the following program ?&lt;br&gt;char *gxxx()&lt;br&gt;{static char xxx[1024];&lt;br&gt;return xxx;&lt;br&gt;}&lt;br&gt;main()&lt;br&gt;{char *g=&amp;quot;string&amp;quot;;&lt;br&gt;strcpy(gxxx(),g);&lt;br&gt;g = gxxx();&lt;br&gt;strcpy(g,&amp;quot;oldstring&amp;quot;);&lt;br&gt;printf(&amp;quot;The string is : %s&amp;quot;,gxxx());&lt;br&gt;}&lt;br&gt;a) The string is : string&lt;br&gt;b) The string is :Oldstring&lt;br&gt;c) Run time error/Core dump&lt;br&gt;d) Syntax error during compilation&lt;br&gt;e) None of these&lt;br&gt;&lt;b&gt;Ans. (b)&lt;/b&gt;&lt;br&gt;25.  Find the output for the following C program &lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char *p1=&amp;quot;Name&amp;quot;;&lt;br&gt;char *p2;&lt;br&gt;p2=(char *)malloc(20);&lt;br&gt;while(*p2++=*p1++);&lt;br&gt;printf(&amp;quot;%s\n&amp;quot;,p2);&lt;br&gt;}&lt;br&gt;&lt;b&gt; Ans. An empty string&lt;/b&gt;&lt;br&gt;26.  Find the output for the following C program&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=20,y=35;&lt;br&gt;x = y++ + x++;&lt;br&gt;y = ++y + ++x;&lt;br&gt;printf(&amp;quot;%d %d\n&amp;quot;,x,y);&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans. 57 94&lt;/b&gt;&lt;br&gt;27.  Find the output for the following C program&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=5;&lt;br&gt;printf(&amp;quot;%d %d %d\n&amp;quot;,x,x&amp;lt;&amp;lt;2,x&amp;gt;&amp;gt;2);&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans. 5 20 1&lt;/b&gt;&lt;br&gt;28 Find the output for the following C program&lt;br&gt;#define swap1(a,b) a=a+b;b=a-b;a=a-b;&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=5,y=10;&lt;br&gt;swap1(x,y);&lt;br&gt;printf(&amp;quot;%d %d\n&amp;quot;,x,y);&lt;br&gt;swap2(x,y);&lt;br&gt;printf(&amp;quot;%d %d\n&amp;quot;,x,y);&lt;br&gt;}&lt;br&gt;int swap2(int a,int b)&lt;br&gt;{&lt;br&gt;int temp;&lt;br&gt;temp=a;&lt;br&gt;b=a;&lt;br&gt;a=temp;&lt;br&gt;return;&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans. 10 5&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;29 Find the output for the following C program&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char *ptr = &amp;quot;Ramco Systems&amp;quot;;&lt;br&gt;(*ptr)++;&lt;br&gt;printf(&amp;quot;%s\n&amp;quot;,ptr);&lt;br&gt;ptr++;&lt;br&gt;printf(&amp;quot;%s\n&amp;quot;,ptr);&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans. Samco Systems&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;30 Find the output for the following C program&lt;br&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char s1[]=&amp;quot;Ramco&amp;quot;;&lt;br&gt;char s2[]=&amp;quot;Systems&amp;quot;;&lt;br&gt;s1=s2;&lt;br&gt;printf(&amp;quot;%s&amp;quot;,s1);&lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans. Compilation error giving it cannot be an modifiable &amp;#39;lvalue&amp;#39;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;31 Find the output for the following C program&lt;br&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char *p1;&lt;br&gt;char *p2;&lt;br&gt;p1=(char *) malloc(25);&lt;br&gt;p2=(char *) malloc(25);&lt;br&gt;strcpy(p1,&amp;quot;Ramco&amp;quot;);&lt;br&gt;strcpy(p2,&amp;quot;Systems&amp;quot;);&lt;br&gt;strcat(p1,p2);&lt;br&gt;printf(&amp;quot;%s&amp;quot;,p1);&lt;br&gt;}&lt;br&gt; &lt;b&gt;Ans. RamcoSystems&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;32.  Find the output for the following C program given that&lt;br&gt;[1]. The following variable is available in file1.c&lt;br&gt;static int average_float;&lt;br&gt;&lt;b&gt;Ans. All the functions in the file1.c can access the variable&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;33.  Find the output for the following C program&lt;br&gt;# define TRUE 0&lt;br&gt;some code&lt;br&gt;while(TRUE)&lt;br&gt;{&lt;br&gt;some code &lt;br&gt;}&lt;br&gt;&lt;b&gt;Ans. This won&amp;#39;t go into the loop as TRUE is defined as 0&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;&lt;a&gt;34. struct list{&lt;br&gt;       int x; &lt;br&gt;      struct list *next; &lt;br&gt;      }*head; &lt;br&gt;&lt;br&gt;        the struct head.x =100 &lt;br&gt;&lt;br&gt;       Is the above assignment to pointer is correct or wrong ?&lt;/a&gt;&lt;br&gt;&lt;b&gt;Ans. Wrong&lt;/b&gt;&lt;b&gt; &lt;/b&gt;&lt;b&gt;&lt;/b&gt;  35.What is the output of the following ? &lt;br&gt;&lt;br&gt;      int i; &lt;br&gt;      i=1; &lt;br&gt;      i=i+2*i++; &lt;br&gt;      printf(%d,i);&lt;br&gt;&lt;b&gt;Ans. 4&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;36. FILE *fp1,*fp2; &lt;br&gt;      &lt;br&gt;      fp1=fopen(&amp;quot;one&amp;quot;,&amp;quot;w&amp;quot;) &lt;br&gt;      fp2=fopen(&amp;quot;one&amp;quot;,&amp;quot;w&amp;quot;) &lt;br&gt;      fputc(&amp;#39;A&amp;#39;,fp1) &lt;br&gt;      fputc(&amp;#39;B&amp;#39;,fp2) &lt;br&gt;      fclose(fp1) &lt;br&gt;      fclose(fp2) &lt;br&gt;     }&lt;br&gt;&lt;br&gt;     Find the Error, If Any?&lt;br&gt;&lt;b&gt;Ans. no error. But It will over writes on same file.&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br&gt;37. What are the output(s) for the following ?&lt;br&gt;38. #include&amp;lt;malloc.h&amp;gt;&lt;br&gt;      char *f()&lt;br&gt;      {char *s=malloc(8); &lt;br&gt;        strcpy(s,&amp;quot;goodbye&amp;quot;);&lt;br&gt;     }&lt;br&gt;&lt;br&gt;      main()&lt;br&gt;      { &lt;br&gt;      char *f(); &lt;br&gt;      printf(&amp;quot;%c&amp;quot;,*f()=&amp;#39;A&amp;#39;);     }&lt;br&gt; &lt;br&gt; &lt;br&gt;39. #define MAN(x,y) (x)&amp;gt;(y)?(x):(y) &lt;br&gt;      {int i=10;&lt;br&gt;      j=5;&lt;br&gt;      k=0;&lt;br&gt;      k=MAX(i++,++j);&lt;br&gt;      printf(%d %d %d %d,i,j,k);&lt;br&gt;      }&lt;br&gt;&lt;b&gt;Ans. 10 5 0&lt;/b&gt;&lt;br&gt;40. &lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int i=7;&lt;br&gt;printf(&amp;quot;%d&amp;quot;,i++*i++);&lt;br&gt;}&lt;br&gt;&lt;b&gt;&lt;br&gt;Ans: 56&lt;/b&gt;&lt;br&gt;   1.      Please ignore any case-sensitive errors and un-included libraries.&lt;br&gt;2. You may use the back of this question paper for any rough work.  2.         Q1.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int i;&lt;br&gt;clrscr();&lt;br&gt;printf(&amp;quot;%d&amp;quot;, &amp;amp;i)+1;&lt;br&gt;scanf(&amp;quot;%d&amp;quot;, i)-1;&lt;br&gt;}&lt;br&gt;a. Runtime error.&lt;br&gt;b. Runtime error. Access violation.&lt;br&gt;c. Compile error. Illegal syntax&lt;br&gt;d. None of the above  &lt;b&gt;Ans: d, printf( ) prints address/garbage of i,&lt;br&gt;scanf() dont hav &amp;amp; sign, so scans address for i&lt;br&gt;+1, -1 dont hav any effect on code&lt;/b&gt;     &lt;br&gt;Q2.&lt;br&gt;main(int argc, char *argv[])&lt;br&gt;{&lt;br&gt;(main &amp;amp;&amp;amp; argc) ? main(argc-1, NULL) : return 0;&lt;br&gt;}&lt;br&gt;a. Runtime error.&lt;br&gt;b. Compile error. Illegal syntax&lt;br&gt;c. Gets into Infinite loop&lt;br&gt;d. None of the above  &lt;b&gt;Ans: b) illegal syntax for using return&lt;/b&gt;     &lt;br&gt;Q3.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int i;&lt;br&gt;float *pf;&lt;br&gt;pf = (float *)&amp;amp;i;&lt;br&gt;*pf = 100.00;&lt;br&gt;printf(&amp;quot;\n %d&amp;quot;, i);&lt;br&gt;}&lt;br&gt;a. Runtime error.&lt;br&gt;b. 100&lt;br&gt;c. Some Integer not 100&lt;br&gt;d. None of the above  &lt;b&gt;Ans: d) 0&lt;/b&gt;  &lt;b&gt;&lt;/b&gt;   Q4.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int i = 0xff ;&lt;br&gt;printf(&amp;quot;\n%d&amp;quot;, ipName,&amp;quot;Your Name&amp;quot;);&lt;br&gt;printf(&amp;quot;%s&amp;quot;, obj-&amp;gt;pName);&lt;br&gt;}&lt;br&gt;a. Your Name&lt;br&gt;b. compile error&lt;br&gt;c. Name&lt;br&gt;d. Runtime error  &lt;b&gt;Ans a)&lt;/b&gt;  &lt;br&gt;Q16.&lt;br&gt;struct Foo&lt;br&gt;{&lt;br&gt;char *pName;&lt;br&gt;char *pAddress;&lt;br&gt;};&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;struct Foo *obj = malloc(sizeof(struct Foo));&lt;br&gt;clrscr();&lt;br&gt;obj-&amp;gt;pName = malloc(100);&lt;br&gt;obj-&amp;gt;pAddress = malloc(100);&lt;br&gt;strcpy(obj-&amp;gt;pName,&amp;quot;Your Name&amp;quot;);&lt;br&gt;strcpy(obj-&amp;gt;pAddress, &amp;quot;Your Address&amp;quot;);&lt;br&gt;free(obj);&lt;br&gt;printf(&amp;quot;%s&amp;quot;, obj-&amp;gt;pName);&lt;br&gt;printf(&amp;quot;%s&amp;quot;, obj-&amp;gt;pAddress);&lt;br&gt;}&lt;br&gt;a. Your Name, Your Address&lt;br&gt;b. Your Address, Your Address&lt;br&gt;c. Your Name Your Name&lt;br&gt;d. None of the above  &lt;b&gt;Ans: d) printd Nothing, as after free(obj), no memory is there containing&lt;br&gt;obj-&amp;gt;pName &amp;amp; pbj-&amp;gt;pAddress&lt;/b&gt;  &lt;b&gt;&lt;br&gt;&lt;/b&gt;Q17.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char *a = &amp;quot;Hello &amp;quot;;&lt;br&gt;char *b = &amp;quot;World&amp;quot;;&lt;br&gt;clrscr();&lt;br&gt;printf(&amp;quot;%s&amp;quot;, strcat(a,b));&lt;br&gt;}&lt;br&gt;a. Hello&lt;br&gt;b. Hello World&lt;br&gt;c. HelloWorld&lt;br&gt;d. None of the above  &lt;b&gt;Ans: b)&lt;/b&gt;  &lt;br&gt;Q18.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char *a = &amp;quot;Hello &amp;quot;;&lt;br&gt;char *b = &amp;quot;World&amp;quot;;&lt;br&gt;clrscr();&lt;br&gt;printf(&amp;quot;%s&amp;quot;, strcpy(a,b));&lt;br&gt;}&lt;br&gt;a. &amp;ldquo;Hello&amp;rdquo;&lt;br&gt;b. &amp;ldquo;Hello World&amp;rdquo;&lt;br&gt;c. &amp;ldquo;HelloWorld&amp;rdquo;&lt;br&gt;d. None of the above  &lt;b&gt;Ans: d) World, copies World on a, overwrites Hello in a.&lt;/b&gt;  &lt;br&gt;Q19.&lt;br&gt;void func1(int (*a)[10])&lt;br&gt;{&lt;br&gt;printf(&amp;quot;Ok it works&amp;quot;);&lt;br&gt;}&lt;br&gt;void func2(int a[][10])&lt;br&gt;{&lt;br&gt;printf(&amp;quot;Will this work?&amp;quot;);&lt;br&gt;}  main()&lt;br&gt;{&lt;br&gt;int a[10][10];&lt;br&gt;func1(a);&lt;br&gt;func2(a);&lt;br&gt;}&lt;br&gt;a. Ok it works&lt;br&gt;b. Will this work?&lt;br&gt;c. Ok it worksWill this work?&lt;br&gt;d. None of the above  &lt;b&gt;Ans: c)&lt;/b&gt;  &lt;br&gt;Q20.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;printf(&amp;quot;%d, %d&amp;quot;, sizeof(&amp;#39;c&amp;#39;), sizeof(100));&lt;br&gt;}&lt;br&gt;a. 2, 2&lt;br&gt;b. 2, 100&lt;br&gt;c. 4, 100&lt;br&gt;d. 4, 4  &lt;b&gt;Ans: a) 2, 2&lt;/b&gt;     &lt;br&gt;Q21.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int i = 100;&lt;br&gt;clrscr();&lt;br&gt;printf(&amp;quot;%d&amp;quot;, sizeof(sizeof(i)));&lt;br&gt;}&lt;br&gt;a. 2&lt;br&gt;b. 100&lt;br&gt;c. 4&lt;br&gt;d. none of the above  &lt;b&gt;Ans: a) 2&lt;/b&gt;  &lt;br&gt;Q22.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int c = 5;&lt;br&gt;printf(&amp;quot;%d&amp;quot;, main||c);&lt;br&gt;}&lt;br&gt;a. 1&lt;br&gt;b. 5&lt;br&gt;c. 0&lt;br&gt;d. none of the above  &lt;b&gt;Ans: a) 1, if we use main|c then error, illegal use of pointer&lt;/b&gt;  &lt;b&gt;&lt;/b&gt;   Q23.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char c;&lt;br&gt;int i = 456;&lt;br&gt;clrscr();&lt;br&gt;c = i;&lt;br&gt;printf(&amp;quot;%d&amp;quot;, c);&lt;br&gt;}&lt;br&gt;a. 456&lt;br&gt;b. -456&lt;br&gt;c. random number&lt;br&gt;d. none of the above  &lt;b&gt;Ans: d) -56&lt;/b&gt;  &lt;b&gt;&lt;/b&gt;   &lt;b&gt;&lt;br&gt;&lt;/b&gt;Q24.&lt;br&gt;void main ()&lt;br&gt;{&lt;br&gt;int x = 10;&lt;br&gt;printf (&amp;quot;x = %d, y = %d&amp;quot;, x,--x++);&lt;br&gt;}&lt;br&gt;a. 10, 10&lt;br&gt;b. 10, 9&lt;br&gt;c. 10, 11&lt;br&gt;d. none of the above  &lt;b&gt;Ans: d) Lvalue required&lt;/b&gt;     &lt;br&gt;Q25.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int i =10, j = 20;&lt;br&gt;clrscr();&lt;br&gt;printf(&amp;quot;%d, %d, &amp;quot;, j-- , --i);&lt;br&gt;printf(&amp;quot;%d, %d &amp;quot;, j++ , ++i);&lt;br&gt;}&lt;br&gt;a. 20, 10, 20, 10&lt;br&gt;b. 20, 9, 20, 10&lt;br&gt;c. 20, 9, 19, 10&lt;br&gt;d. 19, 9, 20, 10  &lt;b&gt;Ans: c)&lt;/b&gt;     &lt;br&gt;Q26.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=5;&lt;br&gt;clrscr();&lt;br&gt;for(;x==0;x--) {&lt;br&gt;printf(&amp;quot;x=%d\n&amp;rdquo;&amp;quot;, x--);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;a. 4, 3, 2, 1, 0&lt;br&gt;b. 1, 2, 3, 4, 5&lt;br&gt;c. 0, 1, 2, 3, 4&lt;br&gt;d. none of the above  &lt;b&gt;Ans: d) prints nothing, as condition x==0 is False&lt;/b&gt;  &lt;b&gt;&lt;/b&gt;   &lt;b&gt;&lt;br&gt;&lt;/b&gt;Q27&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=5;&lt;br&gt;for(;x!=0;x--) {&lt;br&gt;printf(&amp;quot;x=%d\n&amp;quot;, x--);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;a. 5, 4, 3, 2,1&lt;br&gt;b. 4, 3, 2, 1, 0&lt;br&gt;c. 5, 3, 1&lt;br&gt;d. none of the above  &lt;b&gt;Ans: d) Infinite loop as x is decremented twice, it never be 0&lt;br&gt;and loop is going on &amp;amp; on&lt;/b&gt;  &lt;b&gt;&lt;/b&gt;   Q28&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=5;&lt;br&gt;clrscr();&lt;br&gt;for(;x&amp;gt; (i - (i -1)));&lt;br&gt;}&lt;br&gt;}&lt;br&gt;a. 512, 256, 0, 0, 0&lt;br&gt;b. 256, 256, 0, 0, 0&lt;br&gt;c. 512, 512, 512, 512, 512&lt;br&gt;d. 256, 256, 256, 256, 256  &lt;b&gt;Ans: d) bit&amp;#39;s value is not changed&lt;/b&gt;  &lt;br&gt;Q33.&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;if (!(1&amp;amp;&amp;amp;0))&lt;br&gt;{&lt;br&gt;printf(&amp;quot;OK I am done.&amp;quot;);&lt;br&gt;}&lt;br&gt;else&lt;br&gt;{&lt;br&gt;printf(&amp;quot;OK I am gone.&amp;quot;);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;a. OK I am done&lt;br&gt;b. OK I am gone&lt;br&gt;c. compile error&lt;br&gt;d. none of the above  &lt;b&gt;Ans: a)&lt;/b&gt;  &lt;br&gt;Q34&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;if ((1||0) &amp;amp;&amp;amp; (0||1))&lt;br&gt;{&lt;br&gt;printf(&amp;quot;OK I am done.&amp;quot;);&lt;br&gt;}&lt;br&gt;else&lt;br&gt;{&lt;br&gt;printf(&amp;quot;OK I am gone.&amp;quot;);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;a. OK I am done&lt;br&gt;b. OK I am gone&lt;br&gt;c. compile error&lt;br&gt;d. none of the above  &lt;b&gt;Ans: a)&lt;br&gt;&lt;/b&gt;Q35&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;signed int bit=512, mBit;&lt;br&gt;{&lt;br&gt;mBit = ~bit;&lt;br&gt;bit = bit &amp;amp; ~bit ;&lt;br&gt;printf(&amp;quot;%d %d&amp;quot;, bit, mBit);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;a. 0, 0&lt;br&gt;b. 0, 513&lt;br&gt;c. 512, 0&lt;br&gt;d. 0, -513  &lt;b&gt;Ans: d)&lt;/b&gt;&lt;br&gt; &lt;br&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>More On C#</title><link>http://faqworldofrastogi.wetpaint.com/page/More+On+C%23</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/More+On+C%23</guid><pubDate>Wed, 22 Nov 2006 00:38:37 CST</pubDate><description>&lt;br&gt;&lt;div&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;  &lt;div&gt;&lt;/div&gt;  &lt;div&gt;  &lt;blockquote&gt;  &lt;div&gt;&lt;b&gt;&lt;u&gt;C# FAQ for C++ programmers &lt;br&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;br&gt;&lt;h2&gt;&lt;a&gt;1. Introduction&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.1 What is C#?&lt;/a&gt;&lt;/h3&gt;  C# is a programming language designed by Microsoft. It is loosely based on C/C++, and bears a striking similarity to Java. Microsoft describe C# as follows:&lt;br&gt;&amp;quot;C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced &amp;#39;C sharp&amp;#39;) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++.&amp;quot;&lt;br&gt;You can get the ECMA C# spec in PDF form &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.ecma-international.org/publications/standards/Ecma-334.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;, or use Jon Jagger&amp;#39;s &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.jaggersoft.com/csharp_standard/index.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;html version&lt;/a&gt;.&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.2 How do I develop C# apps?&lt;/a&gt;&lt;/h3&gt;  The (free) &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/netframework/downloads/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;.NET SDK&lt;/a&gt; contains the C# command-line compiler (csc.exe). Visual Studio has fully integrated support for C# development. On Linux you can use &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.mono-project.com/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Mono&lt;/a&gt;.&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.3 Does C# replace C++?&lt;/a&gt;&lt;/h3&gt;  There are three options open to the Windows developer from a C++ background:&lt;br&gt;&lt;ul&gt;  &lt;li&gt;Stick with standard C++. Don&amp;#39;t use .NET at all.   &lt;/li&gt;&lt;li&gt;Use C++ with .NET. Microsoft supply a .NET C++ compiler that produces IL rather than machine code. However to make full use of the .NET environment (e.g. garbage collection), a set of extensions are required to standard C++. In .NET 1.x this extended language is called Managed Extensions for C++. In .NET 2.0 ME C++ has been completely redesigned under the stewardship of &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blogs.msdn.com/slippman&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Stan Lippman&lt;/a&gt;, and renamed C++/CLI.   &lt;/li&gt;&lt;li&gt;Forget C++ and use C#.&lt;/li&gt;&lt;/ul&gt;  Each of these options has merits, depending on the developer and the application. For my own part, I intend to use C# where possible, falling back to C++ only where necessary. ME C++ (soon to be C++/CLI) is very useful for interop between new .NET code and old C++ code - simply write a managed wrapper class using ME C++, then use the managed class from C#. From experience, this works well.&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.4 Does C# have its own class library?&lt;/a&gt;&lt;/h3&gt;  Not exactly. The .NET Framework has a comprehensive class library, which C# can make use of. C# does not have its own class library.&lt;br&gt;&lt;h2&gt;&lt;a&gt;2. Types&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;2.1 What standard types does C# use?&lt;/a&gt;&lt;/h3&gt;  C# supports a very similar range of basic types to C++, including int, long, float, double, char, string, arrays, structs and classes. However, don&amp;#39;t assume too much. The names may be familiar, but many of the details are different. For example, a long is 64 bits in C#, whereas in C++ the size of a long depends on the platform (typically 32 bits on a 32-bit platform, 64 bits on a 64-bit platform). Also classes and structs are almost the same in C++ - this is not true for C#. Finally, chars and strings in .NET are 16-bit (Unicode/UTF-16), not 8-bit like C++.&lt;br&gt;&lt;h3&gt;&lt;a&gt;2.2 Is it true that all C# types derive from a common base class?&lt;/a&gt;&lt;/h3&gt;  Yes and no. All types can be treated as if they derive from &lt;b&gt;object&lt;/b&gt; (System.Object), but in order to treat an instance of a value type (e.g. int, float) as object-derived, the instance must be converted to a reference type using a process called &amp;#39;boxing&amp;#39;. In theory a developer can forget about this and let the run-time worry about when the conversion is necessary, but in reality this implicit conversion can have side-effects that may trip up the unwary.&lt;br&gt;&lt;h3&gt;&lt;a&gt;2.3 So I can pass an instance of a value type to a method that takes an object as a parameter?&lt;/a&gt;&lt;/h3&gt;  Yes. For example:    class CApplication      {          public static void Main()          {               int x = 25;               string s = &amp;quot;fred&amp;quot;;                         DisplayMe( x );               DisplayMe( s );           }                 static void DisplayMe( object o )           {               System.Console.WriteLine( &amp;quot;You are {0}&amp;quot;, o );           }      }   This would display:    You are 25      You are fred    &lt;br&gt;&lt;h3&gt;&lt;a&gt;2.4 What are the fundamental differences between value types and reference types?&lt;/a&gt;&lt;/h3&gt;  C# divides types into two categories - &lt;b&gt;value&lt;/b&gt; types and &lt;b&gt;reference&lt;/b&gt; types. Most of the intrinsic types (e.g. int, char) are value types. Structs are also value types. Reference types include classes, arrays and strings. The basic idea is straightforward - an instance of a value type represents the actual data, whereas an instance of a reference type represents a pointer or reference to the data.&lt;br&gt;The most confusing aspect of this for C++ developers is that C# has predetermined which types are represented as values, and which are represented as references. A C++ developer expects to take responsibility for this decision.&lt;br&gt;For example, in C++ we can do this:    int x1 = 3;        // x1 is a value on the stack      int *x2 = new int(3)    // x2 is a pointer to a value on the heap  but in C# there is no control:    int x1 = 3;        // x1 is a value on the stack      int x2 = new int();       x2 = 3;        // x2 is also a value on the stack!  &lt;br&gt;&lt;h3&gt;&lt;a&gt;2.5 Okay, so an int is a value type, and a class is a reference type. How can int be derived from object?&lt;/a&gt;&lt;/h3&gt;  It isn&amp;#39;t, really. When an int is being used as an int, it is a value. However, when it is being used as an object, it is a reference to an integer value (on the managed heap). In other words, when you treat an int as an object, the runtime automatically converts the int value to an object reference. This process is called &lt;b&gt;boxing&lt;/b&gt;. The conversion involves copying the int to the heap, and creating an object instance which refers to it. Unboxing is the reverse process - the object is converted back to a value.    int x = 3;        // new int value 3 on the stack      object objx = x;    // new int on heap, set to value 3 - still have x=3 on stack      int y = (int)objx;    // new value 3 on stack, still got x=3 on stack and objx=3 on heap  &lt;br&gt;&lt;h3&gt;&lt;a&gt;2.6 Are C# references the same as C++ references?&lt;/a&gt;&lt;/h3&gt;  Not quite. The basic idea is the same, but one significant difference is that C# references can be null . So you cannot rely on a C# reference pointing to a valid object. In that respect a C# reference is more like a C++ pointer than a C++ reference. If you try to use a null reference, a NullReferenceException is thrown.&lt;br&gt;For example, look at the following method:    void displayStringLength( string s )      {          Console.WriteLine( &amp;quot;String is length {0}&amp;quot;, s.Length );      }          The problem with this method is that it will throw a NullReferenceException if called like this:    string s = null;      displayStringLength( s );  Of course for some situations you may deem a NullReferenceException to be a perfectly acceptable outcome, but in this case it might be better to re-write the method like this:    void displayStringLength( string s )      {          if( s == null )              Console.WriteLine( &amp;quot;String is null&amp;quot; );          else              Console.WriteLine( &amp;quot;String is length {0}&amp;quot;, s.Length );      }          &lt;br&gt;&lt;h3&gt;&lt;a&gt;2.7 Can I use typedefs in C#?&lt;/a&gt;&lt;/h3&gt;  No, C# has no direct equivalent of the C++ typedef. C# does allow an alias to be specified via the &lt;b&gt;using&lt;/b&gt; keyword:    using IntList = System.Collections.Generic.List&amp;lt;int&amp;gt;;  but the alias only applies in the file in which it is declared. A workaround in some cases is to use inheritance:    public class IntList : List&amp;lt;int&amp;gt; { }  The pros and cons of this approach are discussed &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blogs.msdn.com/ericgu/archive/2004/08/17/215740.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;h2&gt;&lt;a&gt;3. Classes and Structs&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.1 Structs are largely redundant in C++. Why does C# have them?&lt;/a&gt;&lt;/h3&gt;  In C++, a struct and a class are pretty much the same thing. The only difference is the default visibility level (public for structs, private for classes). However, in C# structs and classes are very different. In C#, structs are value types (instances stored directly on the stack, or inline within heap-based objects), whereas classes are reference types (instances stored on the heap, accessed indirectly via a reference). Also structs cannot inherit from structs or classes, though they can implement interfaces. Structs cannot have destructors. A C# struct is much more like a C struct than a C++ struct.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.2 Does C# support multiple inheritance (MI)?&lt;/a&gt;&lt;/h3&gt;  No, though it does support implementation of multiple interfaces on a single class or struct.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.3 Is a C# interface the same as a C++ abstract class?&lt;/a&gt;&lt;/h3&gt;  No, not quite. An abstract class in C++ cannot be instantiated, but it can (and often does) contain implementation code and/or data members. A C# interface cannot contain any implementation code or data members - it is simply a group of method names &amp;amp; signatures. A C# interface is more like a COM interface than a C++ abstract class.&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.4 Are C# constructors the same as C++ constructors?&lt;/a&gt;&lt;/h3&gt;  Very similar, but there are some significant differences. First, C# supports &lt;i&gt;constructor chaining&lt;/i&gt;. This means one constructor can call another:    class Person      {          public Person( string name, int age ) { ... }          public Person( string name ) : this( name, 0 ) {}          public Person() : this( &amp;quot;&amp;quot;, 0 ) {}      }  Another difference is that virtual method calls within a constructor are routed to the most derived implementation - see &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.andymcm.com/csharpfaq.htm#3.9&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Can I Call a virtual method from a constructor&lt;/a&gt;.&lt;br&gt;Error handling is also somewhat different. If an exception occurs during construction of a C# object, the destuctor (finalizer) &lt;i&gt;will&lt;/i&gt; still be called. This is unlike C++ where the destructor is not called if construction is not completed. (Thanks to &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.jaggersoft.com/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Jon Jagger&lt;/a&gt; for pointing this out.)&lt;br&gt;Finally, C# has &lt;i&gt;static&lt;/i&gt; constructors. The static constructor for a class runs before the first instance of the class is created.&lt;br&gt;Also note that (like C++) some C# developers prefer the factory method pattern over constructors. See Brad Wilson&amp;#39;s &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.dotnetdevs.com/advice/PreferFactories.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;article&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.5 Are C# destructors the same as C++ destructors?&lt;/a&gt;&lt;/h3&gt;  No. They look the same but they are very different. The C# destructor syntax (with the familiar ~ character) is just syntactic sugar for an override of the System.Object Finalize method. This Finalize method is called by the garbage collector when it determines that an object is no longer referenced, before it frees the memory associated with the object. So far this sounds like a C++ destructor. The difference is that the garbage collector makes no guarantees about &lt;i&gt;when&lt;/i&gt; this procedure happens. Indeed, the algorithm employed by the CLR garbage collector means that it may be a long time after the application has finished with the object. This lack of certainty is often termed &amp;#39;non-deterministic finalization&amp;#39;, and it means that C# destructors are not suitable for releasing scarce resources such as database connections, file handles etc.&lt;br&gt;To achieve deterministic destruction, a class must offer a method to be used for the purpose. The standard approach is for the class to implement the IDisposable interface. The user of the object must call the Dispose() method when it has finished with the object. C# offers the &amp;#39;using&amp;#39; construct to make this easier.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.6 If C# destructors are so different to C++ destructors, why did MS use the same syntax?&lt;/a&gt;&lt;/h3&gt;  Presumably they wanted C++ programmers to feel at home. I think they made a mistake.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.7 Are all methods virtual in C#?&lt;/a&gt;&lt;/h3&gt;  No. Like C++, methods are non-virtual by default, but can be marked as virtual.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.8 How do I declare a pure virtual function in C#?&lt;/a&gt;&lt;/h3&gt;  Use the abstract modifier on the method. The class must also be marked as abstract (naturally). Note that abstract methods cannot have an implementation (unlike pure virtual C++ methods).&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.9 Can I call a virtual method from a constructor/destructor?&lt;/a&gt;&lt;/h3&gt;  Yes, but it&amp;#39;s generally not a good idea. The mechanics of object construction in .NET are quite different from C++, and this affects virtual method calls in constructors. &lt;br&gt;C++ constructs objects from base to derived, so when the base constructor is executing the object is effectively a base object, and virtual method calls are routed to the base class implementation. By contrast, in .NET the derived constructor is executed first, which means the object is always a derived object and virtual method calls are always routed to the derived implementation. (Note that the C# compiler inserts a call to the base class constructor at the start of the derived constructor, thus preserving standard OO semantics by creating the illusion that the base constructor is executed first.)&lt;br&gt;The same issue arises when calling virtual methods from C# destructors. A virtual method call in a base destructor will be routed to the derived implementation.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.10 Should I make my destructor virtual?&lt;/a&gt;&lt;/h3&gt;  A C# destructor is really just an override of the System.Object Finalize method, and so is virtual by definition.&lt;br&gt;&lt;h2&gt;&lt;a&gt;4. Exceptions&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;4.1 Can I use exceptions in C#?&lt;/a&gt;&lt;/h3&gt;  Yes, in fact exceptions are the recommended error-handling mechanism in C# (and in .NET in general). Most of the .NET framework classes use exceptions to signal errors.&lt;br&gt;&lt;h3&gt;&lt;a&gt;4.2 What types of object can I throw as exceptions?&lt;/a&gt;&lt;/h3&gt;  Only instances of the System.Exception classes, or classes derived from System.Exception. This is in sharp contrast with C++ where instances of almost any type can be thrown.&lt;br&gt;&lt;h3&gt;&lt;a&gt;4.3 Can I define my own exceptions?&lt;/a&gt;&lt;/h3&gt;  Yes, just derive your exception class from System.Exception.&lt;br&gt;Note that if you want your exception to cross remoting boundaries you&amp;#39;ll need to do some extra work - see &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.thinktecture.com/Resources/RemotingFAQ/CustomExceptions.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://www.thinktecture.com/Resources/RemotingFAQ/CustomExceptions.html&lt;/a&gt; for details.&lt;br&gt;&lt;h3&gt;&lt;a&gt;4.4 Does the System.Exception class have any cool features?&lt;/a&gt;&lt;/h3&gt;  Yes - the feature which stands out is the StackTrace property. This provides a call stack which records where the exception was thrown from. For example, the following code:    using System;        class CApp       {            public static void Main()           {               try               {                   f();               }               catch( Exception e )               {                   Console.WriteLine( &amp;quot;System.Exception stack trace = \n{0}&amp;quot;, e.StackTrace );               }          }             static void f()           {               throw new Exception( &amp;quot;f went pear-shaped&amp;quot; );           }       }  produces this output:    System.Exception stack trace =           at CApp.f()           at CApp.Main()  Note, however, that this stack trace was produced from a debug build. A release build may optimise away some of the method calls which could mean that the call stack isn&amp;#39;t quite what you expect.&lt;br&gt;&lt;h3&gt;&lt;a&gt;4.5 When should I throw an exception?&lt;/a&gt;&lt;/h3&gt;  This is the subject of some debate, and is partly a matter of taste. However, it is accepted by many that exceptions should be thrown only when an &amp;#39;unexpected&amp;#39; error occurs. How do you decide if an error is expected or unexpected? This is a judgement call, but a straightforward example of an expected error is failing to read from a file because the seek pointer is at the end of the file, whereas an example of an unexpected error is failing to allocate memory from the heap.&lt;br&gt;&lt;h3&gt;&lt;a&gt;4.6 Does C# have a &amp;#39;throws&amp;#39; clause?&lt;/a&gt;&lt;/h3&gt;  No, unlike Java, C# does not require (or even allow) the developer to specify the exceptions that a method can throw.&lt;br&gt;&lt;h2&gt;&lt;a&gt;5. Run-time Type Information&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.1 How can I check the type of an object at runtime?&lt;/a&gt;&lt;/h3&gt;  You can use the &lt;b&gt;is&lt;/b&gt; keyword. For example:    using System;         class CApp      {          public static void Main()          {               string s = &amp;quot;fred&amp;quot;;               long i = 10;                 Console.WriteLine( &amp;quot;{0} is {1}an integer&amp;quot;, s, (IsInteger(s) ? &amp;quot;&amp;quot; : &amp;quot;not &amp;quot;) );               Console.WriteLine( &amp;quot;{0} is {1}an integer&amp;quot;, i, (IsInteger(i) ? &amp;quot;&amp;quot; : &amp;quot;not &amp;quot;) );           }                static bool IsInteger( object obj )          {               if( obj is int || obj is long )                  return true;               else                   return false;          }      }   produces the output:    fred is not an integer       10 is an integer  &lt;br&gt;&lt;h3&gt;&lt;a&gt;5.2 Can I get the name of a type at runtime?&lt;/a&gt;&lt;/h3&gt;  Yes, use the GetType method of the object class (which all types inherit from). For example:    using System;         class CTest      {          class CApp           {              public static void Main()              {                   long i = 10;                   CTest ctest = new CTest();                     DisplayTypeInfo( ctest );                   DisplayTypeInfo( i );               }                        static void DisplayTypeInfo( object obj )               {                   Console.WriteLine( &amp;quot;Type name = {0}, full type name = {1}&amp;quot;, obj.GetType(), obj.GetType().FullName );               }          }      }  produces the following output:    Type name = CTest, full type name = CTest       Type name = Int64, full type name = System.Int64  &lt;br&gt;&lt;h3&gt;&lt;a&gt;5.3 What is the difference between typeof and GetType()?&lt;/a&gt;&lt;/h3&gt;  Apart from the obvious (i.e. typeof operates on a type whereas GetType operates on an object), the main thing to watch out for is that GetType returns the underlying type of the object, which may not be the same as the type of the reference to the object. For example:    class Base { }      class Derived : Base { }        class Program      {          static void Main()          {              ShowType( new Derived() );          }            static void ShowType( Base b )          {              Console.WriteLine(typeof(Base));              Console.WriteLine(b.GetType());          }      }  gives the following output:    Base      Derived    &lt;br&gt;&lt;h2&gt;&lt;a&gt;6. Miscellaneous&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.1 How do I do a case-insensitive string comparison?&lt;/a&gt;&lt;/h3&gt;  Use the String.Compare function. Its third parameter is a boolean which specifies whether case should be ignored or not.    &amp;quot;fred&amp;quot; == &amp;quot;Fred&amp;quot;    // false      System.String.Compare( &amp;quot;fred&amp;quot;, &amp;quot;Fred&amp;quot;, true ) == 0    // true  For more control over the comparison, e.g. exotic features like width-sensitivity, consider using System.Globalization.CompareInfo.Compare(), e.g.    CultureInfo.CurrentCulture.CompareInfo.Compare(          &amp;quot;fred&amp;quot;, &amp;quot;Fred&amp;quot;,           CompareOptions.IgnoreCase |           CompareOptions.IgnoreKanaType |           CompareOptions.IgnoreWidth          );    &lt;br&gt;&lt;h3&gt;&lt;a&gt;6.2 Does C# support a variable number of arguments?&lt;/a&gt;&lt;/h3&gt;  Yes, using the params keyword. The arguments are specified as a list of arguments of a specific type, e.g. int. For ultimate flexibility, the type can be object. The standard example of a method which uses this approach is System.Console.WriteLine().&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.3 How can I process command-line arguments?&lt;/a&gt;&lt;/h3&gt;  Like this:    using System;        class CApp      {          public static void Main( string[] args )          {              Console.WriteLine( &amp;quot;You passed the following arguments:&amp;quot; );              foreach( string arg in args )                  Console.WriteLine( arg );          }      }  &lt;br&gt;&lt;h3&gt;&lt;a&gt;6.4 Does C# do array bounds checking?&lt;/a&gt;&lt;/h3&gt;  Yes. An IndexOutOfRange exception is used to signal an error.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.5 How can I make sure my C# classes will interoperate with other .NET languages?&lt;/a&gt;&lt;/h3&gt;  Make sure your C# code conforms to the Common Language Subset (CLS). To help with this, add the [assembly:CLSCompliant(true)] global attribute to your C# source files. The compiler will emit an error if you use a C# feature which is not CLS-compliant.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.6 How do I use the &amp;#39;using&amp;#39; keyword with multiple objects?&lt;/a&gt;&lt;/h3&gt;  You can nest using statements, like this:    using( obj1 )      {          using( obj2 )          {              ...              }      }  However consider using this more aesthetically pleasing (but functionally identical) formatting:    using( obj1 )      using( obj2 )      {          ...      }    &lt;br&gt;&lt;h3&gt;&lt;a&gt;6.7 What is the difference between == and object.Equals?&lt;/a&gt;&lt;/h3&gt;  For value types, == and Equals() usually compare two objects by &lt;i&gt;value&lt;/i&gt;. For example:    int x = 10;      int y = 10;      Console.WriteLine( x == y );      Console.WriteLine( x.Equals(y) );  will display:    True      True  However things are more complex for reference types. Generally speaking, for reference types == is expected to perform an &lt;i&gt;identity&lt;/i&gt; comparison, i.e. it will only return true if both references point to the same object. By contrast, Equals() is expected to perform a &lt;i&gt;value&lt;/i&gt; comparison, i.e. it will return true if the references point to objects that are &lt;i&gt;equivalent&lt;/i&gt;. For example:    StringBuilder s1 = new StringBuilder(&amp;quot;fred&amp;quot;);      StringBuilder s2 = new StringBuilder(&amp;quot;fred&amp;quot;);      Console.WriteLine( s1 == s2 );      Console.WriteLine( s1.Equals(s2) );  will display:    False      True  s1 and s2 are different objects (hence == returns false), but they &lt;i&gt;are&lt;/i&gt; equivalent (hence Equals() returns true).&lt;br&gt;Unfortunately there are exceptions to these rules. The implementation of Equals() in System.Object (the one you&amp;#39;ll inherit by default if you write a class) compares identity, i.e. it&amp;#39;s the same as operator==. So Equals() only tests for equivalence if the class author overrides the method (and implements it correctly). Another exception is the string class - its operator== compares value rather than identity.&lt;br&gt;Bottom line: If you want to perform an identity comparison use the ReferenceEquals() method. If you want to perform a value comparison, use Equals() but be aware that it will only work if the type has overridden the default implementation. Avoid operator== with reference types (except perhaps strings), as it&amp;#39;s simply too ambiguous.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.8 How do I enforce const correctness in C#?&lt;/a&gt;&lt;/h3&gt;  You can&amp;#39;t - at least not in the same way you do in C++. C# (actually, the CLI) has no real concept of const correctness, For example, there&amp;#39;s no way to specify that a method should not modify an argument passed in to it. And there&amp;#39;s no way to specify that a method does not modify the object on which it is acting. &lt;br&gt;To get a feel for the angst this causes among some C++ programmers, read the feedback on &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://weblogs.asp.net/oldnewthing/archive/2004/04/27/121049.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;this post&lt;/a&gt; from Raymond Chen.&lt;br&gt;There are of course ways of addressing this issue. For example, see &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blogs.msdn.com/brada/archive/2004/02/04/67859.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Brad Abram&amp;#39;s post&lt;/a&gt; (and associated feedback) for some ideas on adding optional read-only behaviour to collection classes. &lt;br&gt;&lt;h2&gt;&lt;a&gt;7. C# 2.0&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;7.1 What are the new features in C# 2.0?&lt;/a&gt;&lt;/h3&gt;  Support for all of the new framework features such as generics, anonymous methods, partial classes, iterators and static classes. See the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.andymcm.com/dotnetfaq.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;.NET FAQ&lt;/a&gt; for more on these features.&lt;br&gt;Delegate inference is a new feature of the C# compiler which makes delegate usage a little simpler. It allows you to write this:    Thread t = new Thread(ThreadFunc);  instead of this:    Thread t = new Thread( new ThreadStart(ThreadFunc) );  Another minor but welcome addition is the explicit global namespace, which fixes a hole in namespace usage in C# 1.x. You can prefix a type name with &lt;b&gt;global::&lt;/b&gt; to indicate that the type belongs to the global namespace, thus avoiding problems where the compiler infers the namespace and gets it wrong.&lt;br&gt;Finally C# 2.0 includes some syntactic sugar for the new System.Nullable type. You can use &lt;b&gt;T?&lt;/b&gt; as a synonym for &lt;b&gt;System.Nullable&amp;lt;T&amp;gt;&lt;/b&gt;, where T is a value type. As suggested by the name, this allows values of the type to be &amp;#39;null&amp;#39;, or &amp;#39;undefined&amp;#39;. &lt;br&gt;&lt;h3&gt;&lt;a&gt;7.2 Are C# generics the same as C++ templates?&lt;/a&gt;&lt;/h3&gt;  No, not really. There are some similarities, but there are also fundamental differences. See the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.andymcm.com/dotnetfaq.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;.NET FAQ&lt;/a&gt; for more details.&lt;br&gt;&lt;h2&gt;&lt;a&gt;8. Resources&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;8.1 Books&lt;/a&gt;&lt;/h3&gt;  I recommend the following books, either because I personally like them, or because I think they are well regarded by other C# developers. (Note that I get a commission from Amazon if you buy a book after following one of these links.)&lt;br&gt;&lt;ul&gt;  &lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/1590594193/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Pro C# 2005 and the .NET 2.0 Platform, 3nd Edition - Andrew Troelsen&lt;/a&gt;&lt;br&gt;Regarded by many as the best all round C#/.NET book. Wide coverage including Windows Forms, COM interop, ADO.NET, ASP.NET etc.   &lt;/li&gt;&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/0735621632/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;CLR via C#&lt;/a&gt; is the .NET 2.0 version of Jeffrey Richter&amp;#39;s acclaimed &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/0735614229/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Applied Microsoft .NET Framework Programming&lt;/a&gt; book.&lt;br&gt;Despite the &amp;#39;applied&amp;#39; in the original title, these books are mostly about how the .NET Framework works &amp;#39;under the hood&amp;#39;. Examples are in C#.&lt;/li&gt;&lt;/ul&gt;  See also my &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.andymcm.com/dotnetfaq.htm#15.1&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;.NET recommended books&lt;/a&gt;.&lt;br&gt;&lt;br&gt;  This site is hosted by &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.webhost4life.com/default.asp?refid=andymcm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;WebHost4Life&lt;/a&gt; &lt;/div&gt;_uacct = &amp;quot;UA-395673-1&amp;quot;; urchinTracker();   &lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>More On C# 2</title><link>http://faqworldofrastogi.wetpaint.com/page/More+On+C%23+2</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/More+On+C%23+2</guid><pubDate>Wed, 22 Nov 2006 00:30:36 CST</pubDate><description>  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Why does DllImport not work for me?     A: All methods marked with the DllImport attribute must be marked as &lt;b&gt;public static extern&lt;/b&gt;.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;My switch statement works differently! Why?   &lt;br&gt;A: C# does not support an explicit fall through for case blocks. The following code is not legal and will not compile in C#:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;switch(x)  {     case 0:         // do something     case 1:         // do something in common with 0     default:         // do something in common with 0, 1 and everything else         break;  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  In order to achieve the same effect in C# the code must be modified as shown below (notice how the control flows are very explicit):   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;class Test  {      public static void Main()      {          int x = 3;            switch(x)          {              case 0:                  // do something                  goto case 1;              case 1:                  // do something in common with 0                  goto default;              default:                  // do something in common with 0, 1, and anything else                  break;          }      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;What is the difference between const and static readonly?   &lt;br&gt;A: The difference is that &lt;b&gt;static readonly&lt;/b&gt; can be modified by the containing class, but &lt;b&gt;const&lt;/b&gt; can never be modified and must be initialized to a compile time constant. &lt;br&gt;&lt;br&gt;To expand on the static readonly case a bit, the containing class can only modify it:&lt;br&gt;&lt;br&gt;- in the variable declaration (through a variable initializer)&lt;br&gt;- in the static constructor (instance constructors if it&amp;#39;s not static) &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I do implement a trace and assert?   &lt;br&gt;A: Use a conditional attribute on the method:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;class Debug  {      [conditional(&amp;quot;TRACE&amp;quot;)]      public void Trace(string s)      {          Console.WriteLine(s);      }  }    class MyClass  {      public static void Main()      {          Debug.Trace(&amp;quot;hello&amp;quot;);      }  }    &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  In this example the call to Debug.Trace() is only made if the preprocessor symbol TRACE is defined at the call site. You can define preprocessor symbols on the command line using the /D switch. The restriction on conditional methods is that they must have void return type.   &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I make a DLL in C#?   &lt;br&gt;A: You need to use the /target:library compiler option.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Why do I get a syntax error when trying to declare a variable called checked?   &lt;br&gt;A: The word &lt;b&gt;checked&lt;/b&gt; is a keyword in C#. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?   &lt;br&gt;A: The syntax for calling another constructor is:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;class B  {      B(int i)      {  }  }    class C : B  {      C() : base(5)      // call base constructor B(5)      {  }        C(int i) : this()  // call C()      {  }        public static void Main() {}  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;&lt;a&gt;&lt;/a&gt;Is there an equivalent to the instanceof operator in Visual J++?   &lt;br&gt;A: C# has the &lt;b&gt;&lt;i&gt;is&lt;/i&gt;&lt;/b&gt; operator:        &lt;i&gt;expr&lt;/i&gt; &lt;b&gt;is&lt;/b&gt; &lt;i&gt;type&lt;/i&gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I use enum&amp;#39;s in C#?   &lt;br&gt;A: Here&amp;#39;s an example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;namespace Foo  {      enum Colors      {          BLUE,          GREEN      }        class Bar      {          Colors color;          Bar() { color = Colors.GREEN;}                    public static void Main() {}      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Why do I get an error (CS1006) when trying to declare a method without specifying a return type?   &lt;br&gt;A: If you leave off the return type on a method declaration the compiler thinks you are trying to declare a constructor. &lt;br&gt;&lt;br&gt;So if you are trying to declare a method that returns nothing, use void.&lt;br&gt;&lt;br&gt;For example: Here&amp;#39;s an example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;// This results in a CS1006 error  public static staticMethod (mainStatic obj)    // This will work as wanted  public static void staticMethod (mainStatic obj)  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;I have several source files, each has a Main() method. How do I specify which of those Main()&amp;#39;s is supposed to be used?   &lt;br&gt;A: The entry point of your program must be static, named Main, have arguments of either none or string[], and return either int or void. &lt;br&gt;&lt;br&gt;The C# compiler now allows you to have multiple Main() methods in your application, but requires you to specify the fully qualified class name that has the Main() method you want to use. You specify the class by using the /main compiler option. (e.g. csc /main:MyClass *.cs) &lt;br&gt;&lt;br&gt;Note that the way to set it in the Visual Studio .NET IDE is through -&amp;gt; Project Properties, Common properties, General, and then setting the Startup object to the name of the class that contains the main method you want to use. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Does Console.WriteLine() stop printing when it reaches a NULL character within a string?   &lt;br&gt;A: String are not null terminated in the Runtime so embedded nulls are allowed. Console.WriteLine() and all similar methods continue until the end of the string. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is it possible to use multicast delegates in C#? What&amp;#39;s the syntax?   &lt;br&gt;A: All delegates in C# are multicast, therefore there is no &amp;#39;multicast&amp;#39; keyword as there was in Visual J++.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I create a Delegate/MulticastDelegate?   &lt;br&gt;A: C# simply requires a single parameter for delegates: the method address. Unlike other languages, where the programmer must specify an object reference and the method to invoke, C# can infer both pieces of information by just specifying the method&amp;#39;s name. For example, let&amp;#39;s use System.Threading.ThreadStart:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;    Foo MyFoo = new Foo();      ThreadStart del = new ThreadStart(MyFoo.Baz);  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  This means that delegates can invoke static class methods and instance methods with the exact same syntax! &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Why does my windows application pop up a console window every time I run it?   &lt;br&gt;A: Make sure that the target type set in the project properties setting is set to Windows Application, and not Console Application. If youre using the command line, compile with /target:winexe &amp;amp; not /target:exe.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is there a way to force garbage collection?   &lt;br&gt;A: Yes. Set all references to null and then call System.GC.Collect().&lt;br&gt;&lt;br&gt;If you need to have some objects destructed and System.GC.Collect() doesn&amp;#39;t seem to be doing it for you, you can force finalizers to be run by setting all the references to the object to null and then calling System.GC.RunFinalizers(). &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Does C# support C type macros?   &lt;br&gt;A: No. C# does not have macros.&lt;br&gt;&lt;br&gt;Keep in mind that what some of the predefined C macros (e.g. __LINE__ and __FILE__) give you can also be found in COM+ classes like System.Diagnostics (e.g. StackTrace and StackFrame), but it&amp;#39;ll only work on debug builds.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Why is the compiler referencing things that I&amp;#39;m not telling it to reference?   &lt;br&gt;A: The C# compiler automatically references all the assemblies listed in the &amp;#39;csc.rsp&amp;#39; file. You can disable the usage of the csc.rsp file by using the /noconfig compiler option on your command line.&lt;br&gt;&lt;br&gt;Note that the Visual Studio .NET IDE never uses the response file. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do you directly call a native function exported from a DLL?   &lt;br&gt;A: Here&amp;#39;s a quick example of the DllImport attribute in action:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System.Runtime.InteropServices;    class C  {      [DllImport(&amp;quot;user32.dll&amp;quot;)]      public static extern int MessageBoxA(int h, string m, string c, int type);        public static int Main()       {  	return MessageBoxA(0, &amp;quot;Hello World!&amp;quot;, &amp;quot;Caption&amp;quot;, 0);      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  This example shows the minimum requirements for declaring a C# method which is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and extern modifiers, and has the DllImport attribute which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA.&lt;br&gt;For more information, look at the Platform Invoke tutorial in the documentation.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;I&amp;#39;m trying to implement an interface defined in COM+ runtime. &amp;quot;public Object* GetObject() { ... }&amp;quot; doesn&amp;#39;t seem to work. What can I do?   &lt;br&gt;A: In managed C++ the &amp;quot;Object&lt;b&gt;*&lt;/b&gt; GetObject()&amp;quot; (pointer to Object) syntax is required. But in C#, it should work by just using &amp;quot;public Object GetObject() { ... }&amp;quot; instead.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Does C# support templates?   &lt;br&gt;A: No. However, there are plans for C# to support a type of template known as a generic. These generic types have similar syntax, but are instantiated at runtime as opposed to compile time. You can read more about them &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://research.microsoft.com/projects/clrgen&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Why do I get a CS0117 error when attempting to use the &amp;#39;Item&amp;#39; property?   &lt;br&gt;A: Properties are supported in C#, but the &amp;quot;Item&amp;quot; property is special on classes - it is actually the default indexed property.  In C# the way to access these is to simply leave the &amp;quot;Item&amp;quot; specifier off.  &lt;br&gt;&lt;br&gt;Here&amp;#39;s a simple program:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;  using System.Collections;    class Test  {      public static void Main()       {          ArrayList al = new ArrayList();          al.Add( new Test() );          al.Add( new Test() );          Console.WriteLine(&amp;quot;First Element is {0}&amp;quot;, al[0]);      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Notice the way that you don&amp;#39;t use &amp;quot;.Item[0]&amp;quot; in the WriteLine. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;I was trying to use an &amp;quot;out int&amp;quot; parameter in one of my functions. How should I declare the variable which I am passing to it?   &lt;br&gt;A: You should declare the variable as an int, but when you pass it in you must specify it as &amp;#39;out&amp;#39; like the following:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;   int i;     foo(out i);  where foo is declared as follows:    [return-type] foo(out int o) { }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is there an equivalent to C++&amp;#39;s reference parameters in C#? (i.e. void foo(int &amp;amp;i))   &lt;br&gt;A: We call them &lt;b&gt;ref&lt;/b&gt; parameters:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;class Test  {      public void foo(ref int i)       {          i = 1;      }        public void bar()       {          int a = 0;          foo(ref a);          if (a == 1)              Console.WriteLine(&amp;quot;It worked&amp;quot;);      }        public static void Main() {}  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Note that you&amp;#39;re required to restate the &lt;b&gt;ref&lt;/b&gt; in a method invocation. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I declare &lt;i&gt;inout&lt;/i&gt; arguments in C#?   &lt;br&gt;A: The equivalent of inout in C# is ref.  For example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;public void MyMethod (&lt;b&gt;ref&lt;/b&gt; String str1, out String str2)   {      ...  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;When calling the method, it would be called like this:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;    String s1;      String s2;      s1 = &amp;quot;Hello&amp;quot;;      MyMethod(&lt;b&gt;ref&lt;/b&gt; s1, out s2);      Console.WriteLine(s1);      Console.WriteLine(s2);  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Notice that you need to specify &lt;b&gt;ref&lt;/b&gt; when declaring the function and calling it.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do destructors and garbage collection work in C#?   &lt;br&gt;A: C# has finalizers (similar to destructors except that the runtime doesn&amp;#39;t guarantee they&amp;#39;ll be called) and they are specified as follows:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;class C  {      ~C()      {          // your code      }        public static void Main() {}  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Currently, they override object.Finalize() which is called during the GC process.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Why do I get a &amp;quot;CS5001: does not have an entry point defined&amp;quot; error when compiling?   &lt;br&gt;A: The most common problem is that you used a lowercase &amp;#39;m&amp;#39; when defining the Main method. The correct way to implement the entry point is:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;class test   {      static void Main(string[] args) {}  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I port &amp;quot;synchronized&amp;quot; functions from Visual J++ to C#?   &lt;br&gt;A: Original Visual J++ code:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;public synchronized void Run()   {      // function body  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Ported C# code:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;class C  {      public void Run()      {          lock(this)          {              // function body           }      }         public static void Main() {}  }   &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do you implement thread synchronization (Object.Wait, Notify, and CriticalSection) in C#?   &lt;br&gt;A: You want the lock statement which is the same as Monitor Enter/Exit:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;lock(obj)   {      // code  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;translates to:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;try   {      CriticalSection.Enter(obj);      // code  }   finally   {      CriticalSection.Exit(obj);  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;What&amp;#39;s the syntax for a static initializer for my class?   &lt;br&gt;A: The following is a class with a static initializer block:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;class MyClass  {      static MyClass()      {          // initialize static variables here      }        public static void Main() {}  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is it possible to have different access modifiers on the get/set methods of a property?   &lt;br&gt;A: No. The access modifier on a property applies to both it&amp;#39;s get and set accessors. What you probably want to do if you need them to be different is make the property read-only (by only providing a get accessor) and creating a private/internal set method separate from the property.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I create a multi-language single-file assembly?   &lt;br&gt;A: This is currently not supported by Visual Studio .NET.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Does C# support properties of array types?   &lt;br&gt;A: Yes. Here&amp;#39;s a simple example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;    class Class1   {      private string[] MyField;        public string[] MyProperty       {          get { return MyField;  }          set { MyField = value; }      }  }    class MainClass  {      public static int Main(string[] args)       {          Class1 c = new Class1();            string[] arr = new string[] {&amp;quot;apple&amp;quot;, &amp;quot;banana&amp;quot;};          c.MyProperty = arr;          Console.WriteLine(c.MyProperty[0]);  // &amp;quot;apple&amp;quot;                return 0;      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I create a multi-language multi-file assembly?   &lt;br&gt;A: Unfortunately, this is currently not supported in the IDE. In order to do this from the command line, you must compile your projects into netmodules (/target:module on the C# compiler), then use the command line tool al.exe (alink) to link these netmodules together.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I simulate optional parameters to COM calls?   &lt;br&gt;A: You must use the Missing class, and pass Missing.Value (in System.Reflection) for any values that have optional parameters.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is there an equivalent to C++&amp;#39;s default values for function arguments?   &lt;br&gt;A: Default arguments are not supported but you can attain the same effect through function overloading.&lt;br&gt;&lt;br&gt;The reason we prefer overloading as the solution to this problem is that it allows you, at a later time, to change the default value of a parameter without having to recompile existing client code. With C++ style default values, the defaults get burned into the client code, and you can therefore never change them once you&amp;#39;ve published an API. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is there a way of specifying which block or loop to break out of when working with nested loops?   A: The easiest way is to use goto:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;  class BreakExample   {      public static void Main(String[] args)       {          for(int i=0; i&amp;lt;3; i++)           {              Console.WriteLine(&amp;quot;Pass {0}: &amp;quot;, i);              for( int j=0 ; j&amp;lt;100 ; j++ )               {                  if ( j == 10) goto done;                  Console.WriteLine(&amp;quot;{0} &amp;quot;, j);              }              Console.WriteLine(&amp;quot;This will not print&amp;quot;);          }          done:          Console.WriteLine(&amp;quot;Loops complete.&amp;quot;);      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I get deterministic finalization in C#?   &lt;br&gt;A: In a garbage collected environment its impossible to get true determinism. However, a design pattern that we recommend is implementing IDisposable on any class that contains a critical resource. Whenever this class is consumed it may be placed in a using statement for example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;   using(FileStream myFile = File.Open(@&amp;quot;c:\temp\test.txt&amp;quot;, FileMode.Open))  {    int fileOffset = 0;       while(fileOffset &amp;lt; myFile.Length)    {      Console.Write((char)myFile.ReadByte());      fileOffset++;    }  }             &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  When myFile leaves the lexical scope of the using, its dispose method will be called. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Does C# support variable arguments (vararg&amp;#39;s) on methods?   &lt;br&gt;A: The params keyword lets you specify a method parameter that takes an argument where the number of arguments is variable. No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration. Here&amp;#39;s an example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;    public class MyClass   {     public static void UseParams(params int[] list)      {        for ( int i = 0 ; i &amp;lt; list.Length ; i++ )           Console.WriteLine(list[i]);        Console.WriteLine();     }       public static void UseParams2(params object[] list)      {        for ( int i = 0 ; i &amp;lt; list.Length ; i++ )           Console.WriteLine((object)list[i]);        Console.WriteLine();     }       public static void Main()      {        UseParams(1, 2, 3);        UseParams2(1, &amp;#39;a&amp;#39;, &amp;quot;test&amp;quot;);           int[] myarray = new int[3] {10,11,12};        UseParams(myarray);     }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Output:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;1  2  3    1  a  test    10  11  12  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I convert a string to an int in C#?   &lt;br&gt;A: Here&amp;#39;s an example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;    class StringToInt  {      public static void Main()      {  	String s = &amp;quot;105&amp;quot;;  	int x = Convert.ToInt32(s);  	Console.WriteLine(x);      }  }&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is there an equivalent of exit() for quitting a C# .NET application?   &lt;br&gt;A: Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it&amp;#39;s a Windows Forms app. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do you specify a custom attribute for the entire assembly (rather than for a class)?   &lt;br&gt;A: Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. &lt;br&gt;&lt;br&gt;Example Usage:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;    using System;        [assembly : MyAttributeClass]        class X {}  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Note that in IDE created project, by convention, these attributes are placed in AssemblyInfo.cs. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I register my code for use by classic COM clients?   &lt;br&gt;A: Use the regasm.exe utility to generate a type library (if needed) and the necessary entries in the Windows Registry to make a class available to classic COM clients. Once a class is registered in the Windows Registry with regasm.exe, a COM client can use the class as though it were a COM class. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;When using multiple compilation units (C# source files), how is the executable&amp;#39;s name determined?   &lt;br&gt;A: The executable&amp;#39;s name is the same as the source file&amp;#39;s name that has the Main() method. &lt;br&gt;&lt;br&gt;You can also specify the executable&amp;#39;s name by using the /out argument from the command line when compiling. For example: &lt;br&gt;&lt;br&gt;C:\&amp;gt;csc /out:myname.exe file1.cs file2.cs &lt;br&gt;&lt;br&gt;will name your executable &amp;#39;myname.exe&amp;#39;. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How does one compare strings in C#?   &lt;br&gt;A: In the past, you had to call .ToString() on the strings when using the == or != operators to compare the strings&amp;#39; values. That will still work, but the C# compiler now automatically compares the values instead of the references when the == or != operators are used on string types.&lt;br&gt;&lt;br&gt;If you actually do want to compare references, it can be done as follows:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  if ((object) str1 == (object) str2) { ... }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Here&amp;#39;s an example showing how string compares work:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;  public class StringTest  {     public static void Main(string[] args)     {        Object nullObj = null;        Object realObj = new StringTest();        int i = 10;  	        Console.WriteLine(&amp;quot;Null Object is [&amp;quot; + nullObj + &amp;quot;]\n&amp;quot; +                          &amp;quot;Real Object is [&amp;quot; + realObj + &amp;quot;]\n&amp;quot; +                          &amp;quot;i is [&amp;quot; + i + &amp;quot;]\n&amp;quot;);		                // Show string equality operators        string str1 = &amp;quot;foo&amp;quot;;        string str2 = &amp;quot;bar&amp;quot;;        string str3 = &amp;quot;bar&amp;quot;;          Console.WriteLine(&amp;quot;{0} == {1} ? {2}&amp;quot;, str1, str2, str1 == str2 );        Console.WriteLine(&amp;quot;{0} == {1} ? {2}&amp;quot;, str2, str3, str2 == str3 );     }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Output:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;Null Object is []  Real Object is [StringTest]  i is [10]    foo == bar ? False  bar == bar ? True  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Can I define a type that is an alias of another type (like typedef in C++)?   &lt;br&gt;A: Not exactly. You can create an alias within a single file with the &amp;quot;using&amp;quot; directive:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  using System;    using Integer = System.Int32; // alias  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  But you can&amp;#39;t create a true alias, one that extends beyond the file it is declared in. Refer to the C# spec for more info on the &amp;#39;using&amp;#39; statement&amp;#39;s scope. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;What is the difference between a struct and a class in C#?   &lt;br&gt;A: From language spec:&lt;br&gt;The list of similarities between classes and structs is longstructs can implement interfaces, and can have the same kinds of members as classes. Structs differ from classes in several important ways, however: structs are value types rather than reference types, and inheritance is not supported for structs. Struct values are stored on the stack or in-line. Careful programmers can sometimes enhance performance through judicious use of structs. For example, the use of a struct rather than a class for a Point can make a large difference in the number of memory allocations performed at runtime. The program below creates and initializes an array of 100 points. With Point implemented as a class, 101 separate objects are instantiatedone for the array and one each for the 100 elements. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How can I get the ASCII code for a character in C#?   &lt;br&gt;A: Casting the char to an int will give you the ASCII value:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  char c = &amp;#39;f&amp;#39;;    System.Console.WriteLine((int)c);  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;or for a character in a string:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  System.Console.WriteLine((int)s[3]);  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  The base class libraries also offer ways to do this with the Convert class or Encoding classes if you need a particular encoding. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?   &lt;br&gt;A: With regards to versioning, interfaces are less flexible than classes. &lt;br&gt;&lt;br&gt;With a class, you can ship version 1 and then in version 2 decide to add another method. As long as the method is not abstract (i.e. as long as you provide a default implementation of the method), any existing derived classes continue to function with no changes. &lt;br&gt;&lt;br&gt;Because interfaces do not support implementation inheritance, this same pattern does not hold for interfaces. Adding a method to an interface is like adding an abstract method to a base class--any class that implements the interface will break because the class doesn&amp;#39;t implement the new interface method. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is it possible to inline assembly or IL in C# code?   &lt;br&gt;A: No.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?   &lt;br&gt;A: There is no way to restrict to a namespace. Namespaces are never units of protection. But if you&amp;#39;re using assemblies, you can use the &amp;#39;internal&amp;#39; access modifier to restrict access to only within the assembly. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;If I return out of a try/finally in C#, does the code in the finally-clause run?   &lt;br&gt;A: Yes. The code in the finally always runs. Whether you return out of the try block or even if you do a &amp;quot;goto&amp;quot; out of the try, the finally block always runs. For example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;  class main   {      public static void Main()       {          try           {              Console.WriteLine(&amp;quot;In Try block&amp;quot;);              return;          }          finally           {              Console.WriteLine(&amp;quot;In Finally block&amp;quot;);          }      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Both &amp;quot;In Try block&amp;quot; and &amp;quot;In Finally block&amp;quot; will be displayed. Performance-wise, having the return in the try block or after the try-finally block, it is not affected either way. The compiler treats it as if the return was outside the try block anyway. If it&amp;#39;s a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there&amp;#39;s an extra store/load of the value of the expression (since it has to be computed within the try block). &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Does C# support try-catch-finally blocks?   &lt;br&gt;A: Yes. Try-catch-finally blocks are supported by the C# compiler. Here&amp;#39;s an example of a try-catch-finally block:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;  public class TryTest  {     static void Main()     {        try        {           Console.WriteLine(&amp;quot;In Try block&amp;quot;);  	 throw new ArgumentException();        }        catch(ArgumentException n1)        {  	 Console.WriteLine(&amp;quot;Catch Block&amp;quot;);        }        finally        {  	 Console.WriteLine(&amp;quot;Finally Block&amp;quot;);        }     }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Output:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;  In Try Block    Catch Block    Finally Block  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is it possible to have a static indexer in C#?   &lt;br&gt;A: No. Static indexers are not allowed in C#.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;What optimizations does the C# compiler perform when you use /optimize+ compiler option?   &lt;br&gt;A: Here&amp;#39;s the response from a developer on the C# compiler team: &lt;br&gt;&lt;br&gt;We get rid of unused locals (ie, locals which are never read, even if assigned).&lt;br&gt;We get rid of unreachable code.&lt;br&gt;We get rid of try-catch w/ an empty try.&lt;br&gt;We get rid of try-finally w/ an empty try (convert to normal code...).&lt;br&gt;We get rid of try-finally w/ an empty finally (convert to normal code...).&lt;br&gt;We optimize branches over branches:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt; gotoif A, lab1   goto lab2:   lab1:  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;turns into:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt; gotoif !A, lab2   lab1:  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  We optimize branches to ret, branches to next instruction, branches to branches. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How can I access the registry from C# code?   &lt;br&gt;A: By using the Registry and RegistryKey classes in Microsoft.Win32, you can easily access the registry. The following is a sample that reads a key and displays it&amp;#39;s value:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;  using Microsoft.Win32;    class regTest  {      public static void Main(String[] args)      {          RegistryKey regKey;          Object value;          regKey = Registry.LocalMachine;          regKey = regKey.OpenSubKey(&amp;quot;HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0&amp;quot;);          value = regKey.GetValue(&amp;quot;VendorIdentifier&amp;quot;);          Console.WriteLine(&amp;quot;The central processor of this machine is: {0}.&amp;quot;, value);      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Does C# support #define for defining global constants?   &lt;br&gt;A: No. If you want to get something that works like the following C code:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;    #define A 1  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;can be the following C# code:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;    class MyConstants      {          public const int A = 1;      }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Then you use MyConstants.A where you would otherwise use the A macro. &lt;br&gt;&lt;br&gt;Using MyConstants.A has the same generated code as using the literal 1. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How can I create a process that is running a supplied native executable (e.g. cmd.exe)?   &lt;h3&gt;&lt;/h3&gt;&lt;br&gt;A: The following code should run the executable and wait for it to exit before continuing:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;  using System.Diagnostics;    public class ProcessTest {      public static void Main(string[] args) {          Process p = Process.Start(args[0]);          p.WaitForExit();          Console.WriteLine(args[0] + &amp;quot; exited.&amp;quot;);      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Remember to add a reference to System.Diagnostics.dll when you compile. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do you mark a method obsolete?   &lt;br&gt;A: Assuming you&amp;#39;ve done a &amp;quot;using System;&amp;quot;:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;[Obsolete]  public int Foo() {...}  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;or   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;[Obsolete(&amp;quot;This is a message describing why this method is obsolete&amp;quot;)]  public int Foo() {...}  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  Note: The O in Obsolete is capitalized. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;I&amp;#39;ve added a using to my C# source file, but its still telling me that I have undefined types. What am I doing wrong?   &lt;br&gt;A: It&amp;#39;s likely that youre missing the reference to that assembly in which the namespace is located. Using is simply a syntax convenience, in order to add a dependency to another assembly, you must reference it in the IDE you right click your project and select add reference, from the command line you use the /reference switch.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;&lt;a&gt;&lt;/a&gt;Is there any sample C# code for simple threading?   &lt;br&gt;A: Here&amp;#39;s some:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;using System;  using System.Threading;     class ThreadTest   {      public void  runme()       {          Console.WriteLine(&amp;quot;Runme Called&amp;quot;);      }           public static void Main(String[] args)       {          ThreadTest b = new ThreadTest();          Thread t = new Thread(new ThreadStart(b.runme));          t.Start();      }  }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How do I call the base class&amp;#39; implementation of an overrided method?   &lt;br&gt;A: You can call it using &amp;#39;base.methodname()&amp;#39;. For example:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;public class MyBase  {      public virtual void meth()      {          System.Console.WriteLine(&amp;quot;Test&amp;quot;);      }  }    public class MyDerived : MyBase  {      public override void meth()      {          System.Console.WriteLine(&amp;quot;Test2&amp;quot;);          base.meth();      }        public static void Main()      {          MyDerived md = new MyDerived();          md.meth();      }  }&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Is there regular expression (regex) support available to C# developers?   &lt;br&gt;A: Yes. The .NET class libraries provide support for regular expressions. Look at the documentation for the System.Text.RegularExpressions namespace. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Why do I get a security exception when I try to run my C# app?   &lt;br&gt;A: Some security exceptions are thrown if you are working on a network share. There are some parts of the frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is what&amp;#39;s happening, just move the executable over to your local drive and see if it runs without the exceptions. &lt;br&gt;&lt;br&gt;One of the common exceptions thrown under these conditions is System.Security.SecurityException.&lt;br&gt;&lt;br&gt;To get around this, you can change your security policy for the intranet zone, code group 1.2, (the zone that running off shared folders falls into) using the caspol.exe tool.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;How can I get around scope problems in a try/catch?   &lt;br&gt;A: If you try to instantiate the class inside the try, it&amp;#39;ll be out of scope when you try to access it from the catch block. A way to get around this is to do the following:   &lt;table class=&quot;CodeSample&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;100%&quot;&gt;    Connection conn = null;      try       {          conn = new Connection();          conn.Open();      }      finally      {           if (conn != null) conn.Close();       }  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;  By setting it to null before the try block, you avoid getting the CS0165 error (Use of possibly unassigned local variable &amp;#39;conn&amp;#39;). &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;What is the equivalent to regsvr32 and regsvr32 /u a file in .NET development?   &lt;br&gt;A: Try using RegAsm.exe. The general syntax would be: RegAsm there&amp;#39;s a pretty good description of it and it&amp;#39;s associated switches in the .NET SDK docs. Just search on &amp;quot;Assembly Registration Tool&amp;quot;. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt; &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;Q: &lt;a&gt;&lt;/a&gt;Does C# support parameterized properties?   &lt;br&gt;A: No; however, C# supports the concept of an indexer from language spec: &lt;br&gt;&lt;br&gt;An indexer is a member that enables an object to be indexed in the same way as an array. Whereas properties enable field-like access, indexers enable array-like access. &lt;br&gt;&lt;br&gt;As an example, consider the Stack class presented earlier. The designer of this class might want to expose array-like access so that it is possible to inspect or alter the items on the stack without performing unnecessary Push and Pop operations. That is, Stack is implemented as a linked list, but it also provides the convenience of array access. &lt;br&gt;&lt;br&gt;Indexer declarations are similar to property declarations, with the main differences being that indexers are nameless (the name used in the declaration is this, since this is being indexed) and that indexers include indexing parameters. The indexing parameters are provided between square brackets. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>.NET FAQ</title><link>http://faqworldofrastogi.wetpaint.com/page/.NET+FAQ</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/.NET+FAQ</guid><pubDate>Wed, 22 Nov 2006 00:23:50 CST</pubDate><description>&lt;br&gt;&lt;div&gt;  &lt;blockquote&gt;  &lt;blockquote&gt;  &lt;blockquote&gt;  &lt;div&gt;&lt;b&gt;&lt;u&gt;.NET FRAMEWORK FAQ&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;br&gt;&lt;h2&gt;&lt;a&gt;1. Introduction&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.1 What is .NET?&lt;/a&gt;&lt;/h3&gt;  .NET is a general-purpose software development platform, similar to Java. At its core is a virtual machine that turns intermediate language (IL) into machine code. High-level language compilers for C#, VB.NET and C++ are provided to turn source code into IL. C# is a new programming language, very similar to Java. An extensive class library is included, featuring all the functionality one might expect from a contempory development platform - windows GUI development (Windows Forms), database access (ADO.NET), web development (ASP.NET), web services, XML etc.&lt;br&gt;See also Microsoft&amp;#39;s &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/netframework/gettingstarted/default.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;definition&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.2 When was .NET announced?&lt;/a&gt;&lt;/h3&gt;  Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET &amp;#39;vision&amp;#39;. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET.&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.3 What versions of .NET are there?&lt;/a&gt;&lt;/h3&gt;  The final versions of the 1.0 SDK and runtime were made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers.&lt;br&gt;.NET 1.1 was released in April 2003, and was mostly bug fixes for 1.0.&lt;br&gt;.NET 2.0 was released to MSDN subscribers in late October 2005, and was officially launched in early November.&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.4 What operating systems does the .NET Framework run on?&lt;/a&gt;&lt;/h3&gt;  The runtime supports Windows Server 2003, Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on XP and Windows 2000/2003. Windows 98/ME cannot be used for development.&lt;br&gt;IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.asp.net/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;ASP.NET Web Matrix&lt;/a&gt; web server does run on XP Home.&lt;br&gt;The &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/mobility/netcf/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;.NET Compact Framework&lt;/a&gt; is a version of the .NET Framework for mobile devices, running Windows CE or Windows Mobile.&lt;br&gt;The &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.mono-project.com/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Mono&lt;/a&gt; project has a version of the .NET Framework that runs on Linux.&lt;br&gt;&lt;h3&gt;&lt;a&gt;1.5 What tools can I use to develop .NET applications?&lt;/a&gt;&lt;/h3&gt;  There are a number of tools, described here in ascending order of cost:&lt;br&gt;&lt;ul&gt;  &lt;li&gt;The &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/netframework/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;.NET Framework SDK&lt;/a&gt; is free and includes command-line compilers for C++, C#, and VB.NET and various other utilities to aid development.   &lt;/li&gt;&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.icsharpcode.net/OpenSource/SD/Default.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;SharpDevelop&lt;/a&gt; is a free IDE for C# and VB.NET.   &lt;/li&gt;&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/vstudio/express/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Microsoft Visual Studio Express&lt;/a&gt; editions are cut-down versions of Visual Studio, for hobbyist or novice developers.There are different versions for C#, VB, web development etc. Originally the plan was to charge $49, but MS has decided to offer them as free downloads instead, at least until November 2006.   &lt;/li&gt;&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/B000BT8TRQ/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Microsoft Visual Studio Standard 2005&lt;/a&gt; is around $300, or $200 for the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/B000BT8TS0/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;upgrade&lt;/a&gt;.   &lt;/li&gt;&lt;li&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/B000BTA4LU/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Microsoft VIsual Studio Professional 2005&lt;/a&gt; is around $800, or $550 for the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/B000BT8TRG/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;upgrade&lt;/a&gt;.   &lt;/li&gt;&lt;li&gt;At the top end of the price range are the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/B000BAWKPM/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Microsoft Visual Studio Team Edition for Software Developers 2005 with MSDN Premium&lt;/a&gt; and &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.amazon.com/exec/obidos/ASIN/B000BARBAQ/ref=nosim/andymcmullsho-20&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Team Suite&lt;/a&gt; editions. &lt;/li&gt;&lt;/ul&gt;  You can see the differences between the various Visual Studio versions &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://lab.msdn.microsoft.com/vs2005/productinfo/productline/default.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;. &lt;br&gt;&lt;h3&gt;&lt;a&gt;1.6 Why did they call it .NET?&lt;/a&gt;&lt;/h3&gt;  I don&amp;#39;t know what they were thinking. They certainly weren&amp;#39;t thinking of people using search tools. It&amp;#39;s meaningless marketing nonsense.&lt;br&gt;&lt;h2&gt;&lt;a&gt;2. Terminology&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;2.1 What is the CLI? Is it the same as the CLR?&lt;/a&gt;&lt;/h3&gt;  The CLI (Common Language Infrastructure) is the definiton of the fundamentals of the .NET framework - the Common Type System (CTS), metadata, the Virtual Execution Environment (VES) and its use of intermediate language (IL), and the support of multiple programming languages via the Common Language Specification (CLS). The CLI is documented through ECMA - see &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/net/ecma/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://msdn.microsoft.com/net/ecma/&lt;/a&gt; for more details.&lt;br&gt;The CLR (Common Language Runtime) is Microsoft&amp;#39;s primary &lt;i&gt;implementation&lt;/i&gt; of the CLI. Microsoft also have a shared source implementation known as &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/net/sscli/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;ROTOR&lt;/a&gt;, for educational purposes, as well as the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/mobility/netcf/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;.NET Compact Framework&lt;/a&gt; for mobile devices. Non-Microsoft CLI implementations include &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.mono-project.com/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Mono&lt;/a&gt; and &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.dotgnu.org/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;DotGNU Portable.NET&lt;/a&gt;.&lt;br&gt;&lt;h3&gt;&lt;a&gt;2.2 What is IL?&lt;/a&gt;&lt;/h3&gt;  IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL during development. The IL is then converted to machine code at the point where the software is installed, or (more commonly) at run-time by a Just-In-Time (JIT) compiler.&lt;br&gt;&lt;h3&gt;&lt;a&gt;2.3 What is C#?&lt;/a&gt;&lt;/h3&gt;  C# is a new language designed by Microsoft to work with the .NET framework. In their &amp;quot;Introduction to C#&amp;quot; whitepaper, Microsoft describe C# as follows:&lt;br&gt;&amp;quot;C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced &amp;ldquo;C sharp&amp;rdquo;) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++.&amp;quot;&lt;br&gt;Substitute &amp;#39;Java&amp;#39; for &amp;#39;C#&amp;#39; in the quote above, and you&amp;#39;ll see that the statement still works pretty well :-).&lt;br&gt;If you are a C++ programmer, you might like to check out my &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.andymcm.com/csharpfaq.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;C# FAQ&lt;/a&gt;.&lt;br&gt;&lt;h3&gt;&lt;a&gt;2.4 What does &amp;#39;managed&amp;#39; mean in the .NET context?&lt;/a&gt;&lt;/h3&gt;  The term &amp;#39;managed&amp;#39; is the cause of much confusion. It is used in various places within .NET, meaning slightly different things.&lt;br&gt;Managed &lt;i&gt;code&lt;/i&gt;: The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. &lt;br&gt;Managed &lt;i&gt;data&lt;/i&gt;: This is data that is allocated and freed by the .NET runtime&amp;#39;s garbage collector.&lt;br&gt;Managed &lt;i&gt;classes&lt;/i&gt;: This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class.&lt;br&gt;&lt;h2&gt;&lt;a&gt;3. Assemblies&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.1 What is an assembly?&lt;/a&gt;&lt;/h3&gt;  An assembly is sometimes described as a logical .EXE or .DLL, and can be an &lt;i&gt;application&lt;/i&gt; (with a main entry point) or a &lt;i&gt;library&lt;/i&gt;. An assembly consists of one or more files (dlls, exes, html files etc), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a &lt;i&gt;manifest&lt;/i&gt;. The manifest is part of the assembly, thus making the assembly self-describing.&lt;br&gt;An important aspect of assemblies is that they are part of the identity of a type. The identity of a type is the assembly that houses it combined with the type name. This means, for example, that if assembly A exports a type called T, and assembly B exports a type called T, the .NET runtime sees these as two completely different types. Furthermore, don&amp;#39;t get confused between assemblies and namespaces - namespaces are merely a hierarchical way of organising type names. To the runtime, type names are type names, regardless of whether namespaces are used to organise the names. It&amp;#39;s the assembly plus the typename (regardless of whether the type name belongs to a namespace) that uniquely indentifies a type to the runtime.&lt;br&gt;Assemblies are also important in .NET with respect to security - many of the security restrictions are enforced at the assembly boundary.&lt;br&gt;Finally, assemblies are the unit of versioning in .NET - more on this below. &lt;br&gt;&lt;h3&gt;&lt;a&gt;3.2 How can I produce an assembly?&lt;/a&gt;&lt;/h3&gt;  The simplest way to produce an assembly is directly from a .NET compiler. For example, the following C# program:    public class CTest      {          public CTest() { System.Console.WriteLine( &amp;quot;Hello from CTest&amp;quot; ); }      }  can be compiled into a library assembly (dll) like this:    csc /t:library ctest.cs  You can then view the contents of the assembly by running the &amp;quot;IL Disassembler&amp;quot; tool that comes with the .NET SDK.&lt;br&gt;Alternatively you can compile your source into modules, and then combine the modules into an assembly using the assembly linker (al.exe). For the C# compiler, the /target:module switch is used to generate a module instead of an assembly.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.3 What is the difference between a private assembly and a shared assembly?&lt;/a&gt;&lt;/h3&gt;  The terms &amp;#39;private&amp;#39; and &amp;#39;shared&amp;#39; refer to how an assembly is deployed, not any intrinsic attributes of the assembly. &lt;br&gt;A private assembly is normally used by a single application, and is stored in the application&amp;#39;s directory, or a sub-directory beneath. A shared assembly is intended to be used by multiple applications, and is normally stored in the global assembly cache (GAC), which is a central repository for assemblies. (A shared assembly can also be stored outside the GAC, in which case each application must be pointed to its location via a codebase entry in the application&amp;#39;s configuration file.) The main advantage of deploying assemblies to the GAC is that the GAC can support multiple versions of the same assembly side-by-side. &lt;br&gt;Assemblies deployed to the GAC must be strong-named. Outside the GAC, strong-naming is optional.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.4 How do assemblies find each other?&lt;/a&gt;&lt;/h3&gt;  By searching directory paths. There are several factors that can affect the path (such as the AppDomain host, and application configuration files), but for weakly named assemblies the search path is normally the application&amp;#39;s directory and its sub-directories. For strongly named assemblies, the search path is the GAC followed by the private assembly path.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.5 How does assembly versioning work?&lt;/a&gt;&lt;/h3&gt;  An assembly has a version number consisting of four parts, e.g. 1.0.350.1. These are typically interpreted as Major.Minor.Build.Revision, but this is just a convention.&lt;br&gt;The CLR applies no version constraints on weakly named assemblies, so the assembly version has no real significance.&lt;br&gt;For strongly named assemblies, the version of a referenced assembly is stored in the referring assembly, and by default only this exact version will be loaded at run-time. If the exact version is not available, the referring assembly will fail to load. It is possible to override this behaviour in the config file for the referring assembly - references to a single version or a range of versions of the referenced assembly can be redirected to a specific version. For example, versions 1.0.0.0 to 2.0.0.0 can be redirected to version 3.0.125.3. However note that there is no way to specify a range of versions to be redirected &lt;i&gt;to&lt;/i&gt;. Publisher policy files offer an alternative mechanism for redirecting to a different version for assemblies deployed to the GAC - a publisher policy file allows the publisher of the assembly to redirect &lt;i&gt;all&lt;/i&gt; applications to a new version of an assembly in one operation, rather than having to modify all of the application configuration files.&lt;br&gt;The restrictions on version policy for strongly named assemblies can cause problems when providing patches or &amp;#39;hot fixes&amp;#39; for individual assemblies within an application. To avoid having to deploy config file changes or publisher policy files along with the hot fix, it makes sense to reuse the same assembly version for the hot fix. If desired, the assemblies can be distinguised by altering the assembly &lt;i&gt;file&lt;/i&gt; version, which is not used at all by the CLR for applying version policy. For more discussion, see Suzanne Cook&amp;#39;s &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blogs.msdn.com/suzcook/archive/2003/05/29/57148.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;When to Change File/Assembly Versions&lt;/a&gt; blog entry.&lt;br&gt;Note that the versioning of strongly named assemblies applies whether the assemblies are deployed privately or to the GAC.&lt;br&gt;&lt;h3&gt;&lt;a&gt;3.6 How can I develop an application that automatically updates itself from the web?&lt;/a&gt;&lt;/h3&gt;  For .NET 1.x, use the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/updater.asp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Updater Application Block&lt;/a&gt;. For .NET 2.x, use &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/longhorn/understanding/pillars/fundamentals/default.aspx?pull=/library/en-us/dnwinforms/html/clickonce.asp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;ClickOnce&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;h2&gt;&lt;a&gt;4. Application Domains&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;4.1 What is an application domain?&lt;/a&gt;&lt;/h3&gt;  An AppDomain can be thought of as a lightweight process. Multiple AppDomains can exist inside a Win32 process. The primary purpose of the AppDomain is to isolate applications from each other, and so it is particularly useful in hosting scenarios such as ASP.NET. An AppDomain can be destroyed by the host without affecting other AppDomains in the process.&lt;br&gt;Win32 processes provide isolation by having distinct memory address spaces. This is effective, but expensive. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other&amp;#39;s memory.&lt;br&gt;One non-obvious use of AppDomains is for unloading types. Currently the only way to unload a .NET type is to destroy the AppDomain it is loaded into. This is particularly useful if you create and destroy types on-the-fly via reflection.&lt;br&gt;Microsoft have an &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.gotdotnet.com/team/clr/AppdomainFAQ.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;AppDomain FAQ&lt;/a&gt;.&lt;br&gt;&lt;h3&gt;&lt;a&gt;4.2 How does an AppDomain get created?&lt;/a&gt;&lt;/h3&gt;  AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application.&lt;br&gt;AppDomains can also be explicitly created by .NET applications. Here is a C# sample which creates an AppDomain, creates an instance of an object inside it, and then executes one of the object&amp;#39;s methods:    using System;      using System.Runtime.Remoting;      using System.Reflection;        public class CAppDomainInfo : MarshalByRefObject      {          public string GetName() { return AppDomain.CurrentDomain.FriendlyName; }      }        public class App      {          public static int Main()          {              AppDomain ad = AppDomain.CreateDomain( &amp;quot;Andy&amp;#39;s new domain&amp;quot; );              CAppDomainInfo adInfo = (CAppDomainInfo)ad.CreateInstanceAndUnwrap(                   Assembly.GetCallingAssembly().GetName().Name, &amp;quot;CAppDomainInfo&amp;quot; );                      Console.WriteLine( &amp;quot;Created AppDomain name = &amp;quot; + adInfo.GetName() );              return 0;          }      }      &lt;br&gt;&lt;h3&gt;&lt;a&gt;4.3 Can I write my own .NET host?&lt;/a&gt;&lt;/h3&gt;  Yes. For an example of how to do this, take a look at the source for the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://staff.develop.com/jasonw/clr/readme.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;dm.net moniker&lt;/a&gt; developed by Jason Whittington and Don Box. There is also a code sample in the .NET SDK called CorHost.&lt;br&gt;&lt;h2&gt;&lt;a&gt;5. Garbage Collection&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.1 What is garbage collection?&lt;/a&gt;&lt;/h3&gt;  Garbage collection is a heap-management strategy where a run-time component takes responsibility for managing the lifetime of the memory used by objects. This concept is not new to .NET - Java and many other languages/runtimes have used garbage collection for some time. &lt;br&gt;&lt;h3&gt;&lt;a&gt;5.2 Is it true that objects don&amp;#39;t always get destroyed immediately when the last reference goes away?&lt;/a&gt;&lt;/h3&gt;  Yes. The garbage collector offers no guarantees about the time when an object will be destroyed and its memory reclaimed.&lt;br&gt;There was an &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;L=DOTNET&amp;P=R24819&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;interesting thread&lt;/a&gt; on the DOTNET list, started by Chris Sells, about the implications of non-deterministic destruction of objects in C#. In October 2000, Microsoft&amp;#39;s Brian Harry posted a &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://discuss.develop.com/archives/wa.exe?A2=ind0010A&amp;L=DOTNET&amp;P=R28572&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;lengthy analysis&lt;/a&gt; of the problem. Chris Sells&amp;#39; &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://discuss.develop.com/archives/wa.exe?A2=ind0010C&amp;L=DOTNET&amp;P=R983&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;response&lt;/a&gt; to Brian&amp;#39;s posting is here.&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.3 Why doesn&amp;#39;t the .NET runtime offer deterministic destruction?&lt;/a&gt;&lt;/h3&gt;  Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn&amp;#39;t find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesn&amp;#39;t get notified immediately when the final reference on an object goes away - it only finds out during the next &amp;#39;sweep&amp;#39; of the heap.&lt;br&gt;Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep.&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.4 Is the lack of deterministic destruction in .NET a problem?&lt;/a&gt;&lt;/h3&gt;  It&amp;#39;s certainly an issue that affects component design. If you have objects that maintain expensive or scarce resources (e.g. database locks), you need to provide some way to tell the object to release the resource when it is done. Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objects - in a distributed system who calls the Dispose() method? Some form of reference-counting or ownership-management mechanism is needed to handle distributed objects - unfortunately the runtime offers no help with this.&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.5 Should I implement Finalize on my class? Should I implement IDisposable?&lt;/a&gt;&lt;/h3&gt;  This issue is a little more complex than it first appears. There are really two categories of class that require deterministic destruction - the first category manipulate unmanaged types directly, whereas the second category manipulate &lt;i&gt;managed&lt;/i&gt; types that require deterministic destruction. An example of the first category is a class with an IntPtr member representing an OS file handle. An example of the second category is a class with a System.IO.FileStream member.&lt;br&gt;For the first category, it makes sense to implement IDisposable &lt;i&gt;and&lt;/i&gt; override Finalize. This allows the object user to &amp;#39;do the right thing&amp;#39; by calling Dispose, but also provides a fallback of freeing the unmanaged resource in the Finalizer, should the calling code fail in its duty. However this logic does not apply to the second category of class, with only managed resources. In this case implementing Finalize is pointless, as managed member objects cannot be accessed in the Finalizer. This is because there is no guarantee about the ordering of Finalizer execution. So only the Dispose method should be implemented. (If you think about it, it doesn&amp;#39;t really make sense to call Dispose on member objects from a Finalizer anyway, as the member object&amp;#39;s Finalizer will do the required cleanup.)&lt;br&gt;For classes that need to implement IDisposable &lt;i&gt;and&lt;/i&gt; override Finalize, see Microsoft&amp;#39;s &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconFinalizeDispose.asp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;documented pattern&lt;/a&gt;. &lt;br&gt;Note that some developers argue that implementing a Finalizer is always a bad idea, as it hides a bug in your code (i.e. the lack of a Dispose call). A less radical approach is to implement Finalize but include a Debug.Assert at the start, thus signalling the problem in developer builds but allowing the cleanup to occur in release builds.&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.6 Do I have any control over the garbage collection algorithm?&lt;/a&gt;&lt;/h3&gt;  A little. For example the System.GC class exposes a Collect method, which forces the garbage collector to collect all unreferenced objects immediately.&lt;br&gt;Also there is a &lt;b&gt;gcConcurrent&lt;/b&gt; setting that can be specified via the application configuration file. This specifies whether or not the garbage collector performs some of its collection activities on a separate thread. The setting only applies on multi-processor machines, and defaults to true.&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.7 How can I find out what the garbage collector is doing?&lt;/a&gt;&lt;/h3&gt;  Lots of interesting statistics are exported from the .NET runtime via the &amp;#39;.NET CLR xxx&amp;#39; performance counters. Use Performance Monitor to view them.&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.8 What is the lapsed listener problem?&lt;/a&gt;&lt;/h3&gt;  The lapsed listener problem is one of the primary causes of leaks in .NET applications. It occurs when a subscriber (or &amp;#39;listener&amp;#39;) signs up for a publisher&amp;#39;s event, but fails to unsubscribe. The failure to unsubscribe means that the publisher maintains a reference to the subscriber as long as the publisher is alive. For some publishers, this may be the duration of the application.&lt;br&gt;This situation causes two problems. The obvious problem is the leakage of the subscriber object. The other problem is the performance degredation due to the publisher sending redundant notifications to &amp;#39;zombie&amp;#39; subscribers. &lt;br&gt;There are at least a couple of solutions to the problem. The simplest is to make sure the subscriber is unsubscribed from the publisher, typically by adding an Unsubscribe() method to the subscriber. Another solution, documented &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.windojitsu.com/blog/weakevent.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; by Shawn Van Ness, is to change the publisher to use weak references in its subscriber list.&lt;br&gt;&lt;h3&gt;&lt;a&gt;5.9 When do I need to use GC.KeepAlive?&lt;/a&gt;&lt;/h3&gt;  It&amp;#39;s very unintuitive, but the runtime can decide that an object is garbage much sooner than you expect. More specifically, an object can become garbage while a method is executing on the object, which is contrary to most developers&amp;#39; expectations. Chris Brumme &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blogs.msdn.com/cbrumme/archive/2003/04/19/51365.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;explains&lt;/a&gt; the issue on his blog. I&amp;#39;ve taken Chris&amp;#39;s code and expanded it into a full app that you can play with if you want to prove to yourself that this is a real problem:    using System;      using System.Runtime.InteropServices;        class Win32      {          [DllImport(&amp;quot;kernel32.dll&amp;quot;)]           public static extern IntPtr CreateEvent( IntPtr lpEventAttributes,               bool bManualReset,bool bInitialState, string lpName);            [DllImport(&amp;quot;kernel32.dll&amp;quot;, SetLastError=true)]           public static extern bool CloseHandle(IntPtr hObject);            [DllImport(&amp;quot;kernel32.dll&amp;quot;)]           public static extern bool SetEvent(IntPtr hEvent);      }        class EventUser      {          public EventUser()           {               hEvent = Win32.CreateEvent( IntPtr.Zero, false, false, null );           }                    ~EventUser()           {               Win32.CloseHandle( hEvent );               Console.WriteLine(&amp;quot;EventUser finalized&amp;quot;);          }            public void UseEvent()           {               UseEventInStatic( this.hEvent );           }            static void UseEventInStatic( IntPtr hEvent )          {              //GC.Collect();              bool bSuccess = Win32.SetEvent( hEvent );              Console.WriteLine( &amp;quot;SetEvent &amp;quot; + (bSuccess ? &amp;quot;succeeded&amp;quot; : &amp;quot;FAILED!&amp;quot;) );          }            IntPtr hEvent;      }        class App      {          static void Main(string[] args)          {              EventUser eventUser = new EventUser();              eventUser.UseEvent();          }      }  If you run this code, it&amp;#39;ll probably work fine, and you&amp;#39;ll get the following output:    SetEvent succeeded      EventDemo finalized  However, if you uncomment the GC.Collect() call in the UseEventInStatic() method, you&amp;#39;ll get this output:    EventDemo finalized      SetEvent FAILED!  (Note that you need to use a release build to reproduce this problem.)&lt;br&gt;So what&amp;#39;s happening here? Well, at the point where UseEvent() calls UseEventInStatic(), a copy is taken of the hEvent field, and there are no further references to the EventUser object anywhere in the code. So as far as the runtime is concerned, the EventUser object is garbage and can be collected. Normally of course the collection won&amp;#39;t happen immediately, so you&amp;#39;ll get away with it, but sooner or later a collection will occur at the wrong time, and your app will fail. &lt;br&gt;A solution to this problem is to add a call to GC.KeepAlive(this) to the end of the UseEvent method, as &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blogs.msdn.com/cbrumme/archive/2003/04/19/51365.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Chris explains&lt;/a&gt;.&lt;br&gt;&lt;h2&gt;&lt;a&gt;6. Serialization&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.1 What is serialization?&lt;/a&gt;&lt;/h3&gt;  Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process, i.e. creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.2 Does the .NET Framework have in-built support for serialization?&lt;/a&gt;&lt;/h3&gt;  There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.3 I want to serialize instances of my class. Should I use XmlSerializer, SoapFormatter or BinaryFormatter?&lt;/a&gt;&lt;/h3&gt;  It depends. XmlSerializer has severe limitations such as the requirement that the target class has a parameterless constructor, and only public read/write properties and fields can be serialized. However, on the plus side, XmlSerializer has good support for customising the XML document that is produced or consumed. XmlSerializer&amp;#39;s features mean that it is most suitable for cross-platform work, or for constructing objects from existing XML documents.&lt;br&gt;SoapFormatter and BinaryFormatter have fewer limitations than XmlSerializer. They can serialize private fields, for example. However they both require that the target class be marked with the [Serializable] attribute, so like XmlSerializer the class needs to be written with serialization in mind. Also there are some quirks to watch out for - for example on deserialization the constructor of the new object is not invoked.&lt;br&gt;The choice between SoapFormatter and BinaryFormatter depends on the application. BinaryFormatter makes sense where both serialization and deserialization will be performed on the .NET platform and where performance is important. SoapFormatter generally makes more sense in all other cases, for ease of debugging if nothing else.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.4 Can I customise the serialization process?&lt;/a&gt;&lt;/h3&gt;  Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a particular class. For example, a field or property can be marked with the [XmlIgnore] attribute to exclude it from serialization. Another example is the [XmlElement] attribute, which can be used to specify the XML element name to be used for a particular property or field.&lt;br&gt;Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializer&amp;#39;s [XmlIgnore] attribute. Ultimate control of the serialization process can be acheived by implementing the the ISerializable interface on the class whose instances are to be serialized.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.5 Why is XmlSerializer so slow?&lt;/a&gt;&lt;/h3&gt;  There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn&amp;#39;t matter, but it may mean, for example, that XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.6 Why do I get errors when I try to serialize a Hashtable?&lt;/a&gt;&lt;/h3&gt;  XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hashtable. SoapFormatter and BinaryFormatter do not have this restriction.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.7 XmlSerializer is throwing a generic &amp;quot;There was an error reflecting MyClass&amp;quot; error. How do I find out what the problem is?&lt;/a&gt;&lt;/h3&gt;  Look at the InnerException property of the exception that is thrown to get a more specific error message.&lt;br&gt;&lt;h3&gt;&lt;a&gt;6.8 Why am I getting an InvalidOperationException when I serialize an ArrayList?&lt;/a&gt;&lt;/h3&gt;  XmlSerializer needs to know in advance what type of objects it will find in an ArrayList. To specify the type, use the XmlArrayItem attibute like this:    public class Person      {          public string Name;          public int Age;      }        public class Population      {          [XmlArrayItem(typeof(Person))] public ArrayList People;      }  &lt;br&gt;&lt;h2&gt;&lt;a&gt;7. Attributes&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;7.1 What are attributes?&lt;/a&gt;&lt;/h3&gt;  There are at least two types of .NET attribute. The first type I will refer to as a &lt;i&gt;metadata&lt;/i&gt; attribute - it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and (like other class metadata) can be accessed via reflection. An example of a metadata attribute is [serializable], which can be attached to a class and means that instances of the class can be serialized.    [serializable] public class CTest {}  The other type of attribute is a &lt;i&gt;context&lt;/i&gt; attribute. Context attributes use a similar syntax to metadata attributes but they are fundamentally different. Context attributes provide an interception mechanism whereby instance activation and method calls can be pre- and/or post-processed. If you have encountered Keith Brown&amp;#39;s universal delegator you&amp;#39;ll be familiar with this idea. &lt;br&gt;&lt;h3&gt;&lt;a&gt;7.2 Can I create my own metadata attributes?&lt;/a&gt;&lt;/h3&gt;  Yes. Simply derive a class from System.Attribute and mark it with the AttributeUsage attribute. For example:    [AttributeUsage(AttributeTargets.Class)]      public class InspiredByAttribute : System.Attribute       {           public string InspiredBy;                public InspiredByAttribute( string inspiredBy )          {              InspiredBy = inspiredBy;          }      }          [InspiredBy(&amp;quot;Andy Mc&amp;#39;s brilliant .NET FAQ&amp;quot;)]      class CTest      {      }          class CApp      {          public static void Main()          {                      object[] atts = typeof(CTest).GetCustomAttributes(true);                foreach( object att in atts )                  if( att is InspiredByAttribute )                      Console.WriteLine( &amp;quot;Class CTest was inspired by {0}&amp;quot;, ((InspiredByAttribute)att).InspiredBy  );          }      }    &lt;br&gt;&lt;h3&gt;&lt;a&gt;7.3 Can I create my own context attibutes?&lt;/a&gt;&lt;/h3&gt;  Yes. Take a look at Peter Drayton&amp;#39;s &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.razorsoft.net/TraceHook.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Tracehook.NET&lt;/a&gt;.&lt;br&gt;&lt;h2&gt;&lt;a&gt;8. Code Access Security&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;8.1 What is Code Access Security (CAS)?&lt;/a&gt;&lt;/h3&gt;  CAS is the part of the .NET security model that determines whether or not code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk.&lt;br&gt;&lt;h3&gt;&lt;a&gt;8.2 How does CAS work?&lt;/a&gt;&lt;/h3&gt;  The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a &lt;b&gt;named permission set&lt;/b&gt;.&lt;br&gt;For example, using the default security policy, a control downloaded from a web site belongs to the &amp;#39;Zone - Internet&amp;#39; code group, which adheres to the permissions defined by the &amp;#39;Internet&amp;#39; named permission set. (Naturally the &amp;#39;Internet&amp;#39; named permission set represents a very restrictive range of permissions.) &lt;br&gt;&lt;h3&gt;&lt;a&gt;8.3 Who defines the CAS code groups?&lt;/a&gt;&lt;/h3&gt;  Microsoft defines some default ones, but you can modify these and even create your own. To see the code groups defined on your system, run &amp;#39;caspol -lg&amp;#39; from the command-line. On my system it looks like this:   Level = Machine       Code Groups:       1.  All code: Nothing     1.1.  Zone - MyComputer: FullTrust        1.1.1.  Honor SkipVerification requests: SkipVerification     1.2.  Zone - Intranet: LocalIntranet     1.3.  Zone - Internet: Internet     1.4.  Zone - Untrusted: Nothing     1.5.  Zone - Trusted: Internet     1.6.  StrongName -   0024000004800000940000000602000000240000525341310004000003   000000CFCB3291AA715FE99D40D49040336F9056D7886FED46775BC7BB5430BA4444FEF8348EBD06   F962F39776AE4DC3B7B04A7FE6F49F25F740423EBF2C0B89698D8D08AC48D69CED0FC8F83B465E08   07AC11EC1DCC7D054E807A43336DDE408A5393A48556123272CEEEE72F1660B71927D38561AABF5C   AC1DF1734633C602F8F2D5: Everything  Note the hierarchy of code groups - the top of the hierarchy is the most general (&amp;#39;All code&amp;#39;), which is then sub-divided into several groups, each of which in turn can be sub-divided. Also note that (somewhat counter-intuitively) a sub-group can be associated with a more permissive permission set than its parent.&lt;br&gt;&lt;h3&gt;&lt;a&gt;8.4 How do I define my own code group?&lt;/a&gt;&lt;/h3&gt;  Use caspol. For example, suppose you trust code from www.mydomain.com and you want it have full access to your system, but you want to keep the default restrictions for all other internet sites. To achieve this, you would add a new code group as a sub-group of the &amp;#39;Zone - Internet&amp;#39; group, like this: caspol -ag 1.3 -site www.mydomain.com FullTrust   Now if you run caspol -lg you will see that the new group has been added as group 1.3.1: ...      1.3.  Zone - Internet: Internet         1.3.1.  Site - www.mydomain.com: FullTrust   ...  Note that the numeric label (1.3.1) is just a caspol invention to make the code groups easy to manipulate from the command-line. The underlying runtime never sees it. &lt;br&gt;&lt;h3&gt;&lt;a&gt;8.5 How do I change the permission set for a code group?&lt;/a&gt;&lt;/h3&gt;  Use caspol. If you are the machine administrator, you can operate at the &amp;#39;machine&amp;#39; level - which means not only that the changes you make become the default for the machine, but also that users cannot change the permissions to be more permissive. If you are a normal (non-admin) user you can still modify the permissions, but only to make them more restrictive. For example, to allow intranet code to do what it likes you might do this: caspol -cg 1.2 FullTrust  Note that because this is more permissive than the default policy (on a standard system), you should only do this at the machine level - doing it at the user level will have no effect.&lt;br&gt;&lt;h3&gt;&lt;a&gt;8.6 Can I create my own permission set?&lt;/a&gt;&lt;/h3&gt;  Yes. Use caspol -ap, specifying an XML file containing the permissions in the permission set. To save you some time, &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.andymcm.com/samplepermset.xml&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; is a sample file corresponding to the &amp;#39;Everything&amp;#39; permission set - just edit to suit your needs. When you have edited the sample, add it to the range of available permission sets like this: caspol -ap samplepermset.xml  Then, to apply the permission set to a code group, do something like this: caspol -cg 1.3 SamplePermSet  (By default, 1.3 is the &amp;#39;Internet&amp;#39; code group)&lt;br&gt;&lt;h3&gt;&lt;a&gt;8.7 I&amp;#39;m having some trouble with CAS. How can I troubleshoot the problem?&lt;/a&gt;&lt;/h3&gt;  Caspol has a couple of options that might help. First, you can ask caspol to tell you what code group an assembly belongs to, using caspol -rsg. Similarly, you can ask what permissions are being applied to a particular assembly using caspol -rsp.&lt;br&gt;&lt;h3&gt;&lt;a&gt;8.8 I can&amp;#39;t be bothered with CAS. Can I turn it off?&lt;/a&gt;&lt;/h3&gt;  Yes, as long as you are an administrator. Just run: caspol -s off    &lt;br&gt;&lt;h2&gt;&lt;a&gt;9. Intermediate Language (IL)&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;9.1 Can I look at the IL for an assembly?&lt;/a&gt;&lt;/h3&gt;  Yes. MS supply a tool called Ildasm that can be used to view the metadata and IL for an assembly. &lt;br&gt;&lt;h3&gt;&lt;a&gt;9.2 Can source code be reverse-engineered from IL?&lt;/a&gt;&lt;/h3&gt;  Yes, it is often relatively straightforward to regenerate high-level source from IL. Lutz Roeder&amp;#39;s &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.aisto.com/roeder/dotnet/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Reflector&lt;/a&gt; does a very good job of turning IL into C# or VB.NET.&lt;br&gt;&lt;h3&gt;&lt;a&gt;9.3 How can I stop my code being reverse-engineered from IL?&lt;/a&gt;&lt;/h3&gt;  You can buy an IL obfuscation tool. These tools work by &amp;#39;optimising&amp;#39; the IL in such a way that reverse-engineering becomes much more difficult.&lt;br&gt;Of course if you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL.&lt;br&gt;&lt;h3&gt;&lt;a&gt;9.4 Can I write IL programs directly?&lt;/a&gt;&lt;/h3&gt;  Yes. &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.razorsoft.net/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Peter Drayton&lt;/a&gt; posted this simple example to the DOTNET mailing list:    .assembly MyAssembly {}      .class MyApp {        .method static void Main() {          .entrypoint          ldstr      &amp;quot;Hello, IL!&amp;quot;          call       void System.Console::WriteLine(class System.Object)          ret        }      }  Just put this into a file called hello.il, and then run ilasm hello.il. An exe assembly will be generated.&lt;br&gt;&lt;h3&gt;&lt;a&gt;9.5 Can I do things in IL that I can&amp;#39;t do in C#?&lt;/a&gt;&lt;/h3&gt;  Yes. A couple of simple examples are that you can throw exceptions that are not derived from System.Exception, and you can have non-zero-based arrays.&lt;br&gt;&lt;h2&gt;&lt;a&gt;10. Implications for COM&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;10.1 Does .NET replace COM?&lt;/a&gt;&lt;/h3&gt;  This subject causes a lot of controversy, as you&amp;#39;ll see if you read the mailing list archives. Take a look at the following two threads:&lt;br&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;L=DOTNET&amp;D=0&amp;P=68241&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;amp;L=DOTNET&amp;amp;D=0&amp;amp;P=68241&lt;/a&gt;&lt;br&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;L=DOTNET&amp;P=R60761&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;amp;L=DOTNET&amp;amp;P=R60761&lt;/a&gt;&lt;br&gt;The bottom line is that .NET has its own mechanisms for type interaction, and they don&amp;#39;t use COM. No IUnknown, no IDL, no typelibs, no registry-based activation. This is mostly good, as a lot of COM was ugly. Generally speaking, .NET allows you to package and use components in a similar way to COM, but makes the whole thing a bit easier.&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;10.2 Is DCOM dead?&lt;/a&gt;&lt;/h3&gt;  Pretty much, for .NET developers. The .NET Framework has a new remoting model which is not based on DCOM. DCOM was pretty much dead anyway, once firewalls became widespread and Microsoft got &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.w3.org/TR/soap/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;SOAP&lt;/a&gt; fever. Of course DCOM will still be used in interop scenarios. &lt;br&gt;&lt;h3&gt;&lt;a&gt;10.3 Is COM+ dead?&lt;/a&gt;&lt;/h3&gt;  Not immediately. The approach for .NET 1.0 was to provide access to the existing COM+ services (through an interop layer) rather than replace the services with native .NET ones. Various tools and attributes were provided to make this as painless as possible. Over time it is expected that interop will become more seamless - this may mean that some services become a core part of the CLR, and/or it may mean that some services will be rewritten as managed code which runs on top of the CLR.&lt;br&gt;For more on this topic, search for postings by Joe Long in the archives - Joe is the MS group manager for COM+. Start with this message:&lt;br&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;L=DOTNET&amp;P=R68370&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;amp;L=DOTNET&amp;amp;P=R68370&lt;/a&gt; &lt;br&gt;&lt;h3&gt;&lt;a&gt;10.4 Can I use COM components from .NET programs?&lt;/a&gt;&lt;/h3&gt;  Yes. COM components are accessed from the .NET runtime via a Runtime Callable Wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NET-compatible interfaces. For oleautomation interfaces, the RCW can be generated automatically from a type library. For non-oleautomation interfaces, it may be necessary to develop a custom RCW which manually maps the types exposed by the COM interface to .NET-compatible types.&lt;br&gt;Here&amp;#39;s a simple example for those familiar with ATL. First, create an ATL component which implements the following IDL:    import &amp;quot;oaidl.idl&amp;quot;;       import &amp;quot;ocidl.idl&amp;quot;;         [          object,          uuid(EA013F93-487A-4403-86EC-FD9FEE5E6206),          helpstring(&amp;quot;ICppName Interface&amp;quot;),           pointer_default(unique),           oleautomation      ]         interface ICppName : IUnknown      {           [helpstring(&amp;quot;method SetName&amp;quot;)] HRESULT SetName([in] BSTR name);           [helpstring(&amp;quot;method GetName&amp;quot;)] HRESULT GetName([out,retval] BSTR *pName );       };         [           uuid(F5E4C61D-D93A-4295-A4B4-2453D4A4484D),           version(1.0),          helpstring(&amp;quot;cppcomserver 1.0 Type Library&amp;quot;)      ]       library CPPCOMSERVERLib       {          importlib(&amp;quot;stdole32.tlb&amp;quot;);          importlib(&amp;quot;stdole2.tlb&amp;quot;);           [              uuid(600CE6D9-5ED7-4B4D-BB49-E8D5D5096F70),                helpstring(&amp;quot;CppName Class&amp;quot;)           ]          coclass CppName          {               [default] interface ICppName;           };      };  When you&amp;#39;ve built the component, you should get a typelibrary. Run the TLBIMP utility on the typelibary, like this:    tlbimp cppcomserver.tlb  If successful, you will get a message like this:    Typelib imported successfully to CPPCOMSERVERLib.dll  You now need a .NET client - let&amp;#39;s use C#. Create a .cs file containing the following code:    using System;      using CPPCOMSERVERLib;         public class MainApp       {           static public void Main()           {               CppName cppname = new CppName();              cppname.SetName( &amp;quot;bob&amp;quot; );               Console.WriteLine( &amp;quot;Name is &amp;quot; + cppname.GetName() );           }      }  Compile the C# code like this:    csc /r:cppcomserverlib.dll csharpcomclient.cs  Note that the compiler is being told to reference the DLL we previously generated from the typelibrary using TLBIMP. You should now be able to run csharpcomclient.exe, and get the following output on the console:    Name is bob    &lt;br&gt;&lt;h3&gt;&lt;a&gt;10.5 Can I use .NET components from COM programs?&lt;/a&gt;&lt;/h3&gt;  Yes. .NET components are accessed from COM via a COM Callable Wrapper (CCW). This is similar to a RCW (see previous question), but works in the opposite direction. Again, if the wrapper cannot be automatically generated by the .NET development tools, or if the automatic behaviour is not desirable, a custom CCW can be developed. Also, for COM to &amp;#39;see&amp;#39; the .NET component, the .NET component must be registered in the registry.&lt;br&gt;Here&amp;#39;s a simple example. Create a C# file called testcomserver.cs and put the following in it:    using System;       using System.Runtime.InteropServices;        namespace AndyMc       {           [ClassInterface(ClassInterfaceType.AutoDual)]          public class CSharpCOMServer          {               public CSharpCOMServer() {}               public void SetName( string name ) { m_name = name; }               public string GetName() { return m_name; }                private string m_name;           }                }  Then compile the .cs file as follows:    csc /target:library testcomserver.cs  You should get a dll, which you register like this:    regasm testcomserver.dll /tlb:testcomserver.tlb /codebase  Now you need to create a client to test your .NET COM component. VBScript will do - put the following in a file called comclient.vbs:    Dim dotNetObj       Set dotNetObj = CreateObject(&amp;quot;AndyMc.CSharpCOMServer&amp;quot;)       dotNetObj.SetName (&amp;quot;bob&amp;quot;)       MsgBox &amp;quot;Name is &amp;quot; &amp;amp; dotNetObj.GetName()  and run the script like this:    wscript comclient.vbs  And hey presto you should get a message box displayed with the text &amp;quot;Name is bob&amp;quot;.&lt;br&gt;An alternative to the approach above it to use the &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://staff.develop.com/jasonw/clr/readme.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;dm.net moniker&lt;/a&gt; developed by Jason Whittington and Don Box.&lt;br&gt;&lt;h3&gt;&lt;a&gt;10.6 Is ATL redundant in the .NET world?&lt;/a&gt;&lt;/h3&gt;  Yes. ATL will continue to be valuable for writing COM components for some time, but it has no place in the .NET world.&lt;br&gt;&lt;h2&gt;&lt;a&gt;11. Threads&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;11.1 How do I spawn a thread?&lt;/a&gt;&lt;/h3&gt;  Create an instance of a System.Threading.Thread object, passing it an instance of a ThreadStart delegate that will be executed on the new thread. For example:    class MyThread      {          public MyThread( string initData )          {              m_data = initData;              m_thread = new Thread( new ThreadStart(ThreadMain) );                  m_thread.Start();              }            // ThreadMain() is executed on the new thread.          private void ThreadMain()          {                  Console.WriteLine( m_data );          }            public void WaitUntilFinished()          {              m_thread.Join();          }                private Thread m_thread;          private string m_data;      }  In this case creating an instance of the MyThread class is sufficient to spawn the thread and execute the MyThread.ThreadMain() method:    MyThread t = new MyThread( &amp;quot;Hello, world.&amp;quot; );      t.WaitUntilFinished();    &lt;br&gt;&lt;h3&gt;&lt;a&gt;11.2 How do I stop a thread?&lt;/a&gt;&lt;/h3&gt;  There are several options. First, you can use your own communication mechanism to tell the ThreadStart method to finish. Alternatively the Thread class has in-built support for instructing the thread to stop. The two principle methods are Thread.Interrupt() and Thread.Abort(). The former will cause a ThreadInterruptedException to be thrown on the thread when it next goes into a WaitJoinSleep state. In other words, Thread.Interrupt is a polite way of asking the thread to stop when it is no longer doing any useful work. In contrast, Thread.Abort() throws a ThreadAbortException regardless of what the thread is doing. Furthermore, the ThreadAbortException cannot normally be caught (though the ThreadStart&amp;#39;s finally method will be executed). Thread.Abort() is a heavy-handed mechanism which should not normally be required.&lt;br&gt;&lt;h3&gt;&lt;a&gt;11.3 How do I use the thread pool?&lt;/a&gt;&lt;/h3&gt;  By passing an instance of a WaitCallback delegate to the ThreadPool.QueueUserWorkItem() method    class CApp      {          static void Main()          {              string s = &amp;quot;Hello, World&amp;quot;;              ThreadPool.QueueUserWorkItem( new WaitCallback( DoWork ), s );                        Thread.Sleep( 1000 );    // Give time for work item to be executed          }            // DoWork is executed on a thread from the thread pool.          static void DoWork( object state )          {              Console.WriteLine( state );          }      }    &lt;br&gt;&lt;h3&gt;&lt;a&gt;11.4 How do I know when my thread pool work item has completed?&lt;/a&gt;&lt;/h3&gt;  There is no way to query the thread pool for this information. You must put code into the WaitCallback method to signal that it has completed. Events are useful for this.&lt;br&gt;&lt;h3&gt;&lt;a&gt;11.5 How do I prevent concurrent access to my data?&lt;/a&gt;&lt;/h3&gt;  Each object has a concurrency lock (critical section) associated with it. The System.Threading.Monitor.Enter/Exit methods are used to acquire and release this lock. For example, instances of the following class only allow one thread at a time to enter method f():    class C      {          public void f()          {              try              {                  Monitor.Enter(this);                  ...              }              finally              {                  Monitor.Exit(this);              }          }      }  C# has a &amp;#39;lock&amp;#39; keyword which provides a convenient shorthand for the code above:    class C      {          public void f()          {              lock(this)              {                  ...              }          }      }  Note that calling Monitor.Enter(myObject) does NOT mean that all access to myObject is serialized. It means that the synchronisation lock associated with myObject has been acquired, and no other thread can acquire that lock until Monitor.Exit(o) is called. In other words, this class is functionally equivalent to the classes above:    class C      {          public void f()          {              lock( m_object )              {                  ...              }          }                    private m_object = new object();      }  Actually, it could be argued that this version of the code is superior, as the lock is totally encapsulated within the class, and not accessible to the user of the object. &lt;br&gt;&lt;h3&gt;&lt;a&gt;11.6 Should I use ReaderWriterLock instead of Monitor.Enter/Exit?&lt;/a&gt;&lt;/h3&gt;  Maybe, but be careful. ReaderWriterLock is used to allow multiple threads to read from a data source, while still granting exclusive access to a single writer thread. This makes sense for data access that is mostly read-only, but there are some caveats. First, ReaderWriterLock is relatively poor performing compared to Monitor.Enter/Exit, which offsets some of the benefits. Second, you need to be very sure that the data structures you are accessing fully support multithreaded read access. Finally, there is apparently a bug in the v1.1 ReaderWriterLock that can cause starvation for writers when there are a large number of readers. &lt;br&gt;Ian Griffiths has some interesting discussion on ReaderWriterLock &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.interact-sw.co.uk/iangblog/2004/04/26/rwlockvsmonitor&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; and &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.interact-sw.co.uk/iangblog/2004/05/12/rwlock&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;h2&gt;&lt;a&gt;12. Tracing&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;12.1 Is there built-in support for tracing/logging?&lt;/a&gt;&lt;/h3&gt;  Yes, in the System.Diagnostics namespace. There are two main classes that deal with tracing - Debug and Trace. They both work in a similar way - the difference is that tracing from the Debug class only works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class only works in builds that have the TRACE symbol defined. Typically this means that you should use System.Diagnostics.Trace.WriteLine for tracing that you want to work in debug and release builds, and System.Diagnostics.Debug.WriteLine for tracing that you want to work only in debug builds.&lt;br&gt;&lt;h3&gt;&lt;a&gt;12.2 Can I redirect tracing to a file?&lt;/a&gt;&lt;/h3&gt;  Yes. The Debug and Trace classes both have a Listeners property, which is a collection of sinks that receive the tracing that you send via Debug.WriteLine and Trace.WriteLine respectively. By default the Listeners collection contains a single sink, which is an instance of the DefaultTraceListener class. This sends output to the Win32 OutputDebugString() function and also the System.Diagnostics.Debugger.Log() method. This is useful when debugging, but if you&amp;#39;re trying to trace a problem at a customer site, redirecting the output to a file is more appropriate. Fortunately, the TextWriterTraceListener class is provided for this purpose.&lt;br&gt;Here&amp;#39;s how to use the TextWriterTraceListener class to redirect Trace output to a file:    Trace.Listeners.Clear();      FileStream fs = new FileStream( @&amp;quot;c:\log.txt&amp;quot;, FileMode.Create, FileAccess.Write );      Trace.Listeners.Add( new TextWriterTraceListener( fs ) );        Trace.WriteLine( @&amp;quot;This will be writen to c:\log.txt!&amp;quot; );      Trace.Flush();  Note the use of Trace.Listeners.Clear() to remove the default listener. If you don&amp;#39;t do this, the output will go to the file &lt;i&gt;and&lt;/i&gt; OutputDebugString(). Typically this is not what you want, because OutputDebugString() imposes a big performance hit.&lt;br&gt;&lt;h3&gt;&lt;a&gt;12.3 Can I customise the trace output?&lt;/a&gt;&lt;/h3&gt;  Yes. You can write your own TraceListener-derived class, and direct all output through it. Here&amp;#39;s a simple example, which derives from TextWriterTraceListener (and therefore has in-built support for writing to files, as shown above) and adds timing information and the thread ID for each trace line:    class MyListener : TextWriterTraceListener      {          public MyListener( Stream s ) : base(s)          {          }            public override void WriteLine( string s )          {              Writer.WriteLine( &amp;quot;{0:D8} [{1:D4}] {2}&amp;quot;,                   Environment.TickCount - m_startTickCount,                   AppDomain.GetCurrentThreadId(),                  s );          }            protected int m_startTickCount = Environment.TickCount;      }  (Note that this implementation is not complete - the TraceListener.Write method is not overridden for example.)&lt;br&gt;The beauty of this approach is that when an instance of MyListener is added to the Trace.Listeners collection, all calls to Trace.WriteLine() go through MyListener, including calls made by referenced assemblies that know nothing about the MyListener class.&lt;br&gt;&lt;h3&gt;&lt;a&gt;12.4 Are there any third party logging components available?&lt;/a&gt;&lt;/h3&gt;  &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://logging.apache.org/log4net/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Log4net&lt;/a&gt; is a port of the established log4j Java logging component.&lt;br&gt;&lt;h2&gt;&lt;a&gt;13. Miscellaneous&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;13.1 How does .NET remoting work?&lt;/a&gt;&lt;/h3&gt;  .NET remoting involves sending messages along channels. Two of the standard channels are HTTP and TCP. TCP is intended for LANs only - HTTP can be used for LANs or WANs (internet).&lt;br&gt;Support is provided for multiple message serializarion formats. Examples are SOAP (XML-based) and binary. By default, the HTTP channel uses SOAP (via the .NET runtime Serialization SOAP Formatter), and the TCP channel uses binary (via the .NET runtime Serialization Binary Formatter). But either channel can use either serialization format.&lt;br&gt;There are a number of styles of remote access:&lt;br&gt;&lt;ul&gt;  &lt;li&gt;&lt;b&gt;SingleCall&lt;/b&gt;. Each incoming request from a client is serviced by a new object. The object is thrown away when the request has finished.   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Singleton&lt;/b&gt;. All incoming requests from clients are processed by a single server object.   &lt;/li&gt;&lt;li&gt;&lt;b&gt;Client-activated object&lt;/b&gt;. This is the old stateful (D)COM model whereby the client receives a reference to the remote object and holds that reference (thus keeping the remote object alive) until it is finished with it.&lt;/li&gt;&lt;/ul&gt;  Distributed garbage collection of objects is managed by a system called &amp;#39;leased based lifetime&amp;#39;. Each object has a lease time, and when that time expires the object is disconnected from the .NET runtime remoting infrastructure. Objects have a default renew time - the lease is renewed when a successful call is made from the client to the object. The client can also explicitly renew the lease.&lt;br&gt;If you&amp;#39;re interested in using XML-RPC as an alternative to SOAP, take a look at Charles Cook&amp;#39;s &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.cookcomputing.com/xmlrpc/xmlrpc.shtml&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;XML-RPC.Net&lt;/a&gt;.&lt;br&gt;&lt;h3&gt;&lt;a&gt;13.2 How can I get at the Win32 API from a .NET program?&lt;/a&gt;&lt;/h3&gt;  Use P/Invoke. This uses similar technology to COM Interop, but is used to access static DLL entry points instead of COM objects. Here is an example of C# calling the Win32 MessageBox function:    using System;       using System.Runtime.InteropServices;         class MainApp       {           [DllImport(&amp;quot;user32.dll&amp;quot;, EntryPoint=&amp;quot;MessageBox&amp;quot;, SetLastError=true, CharSet=CharSet.Auto)]               public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);                public static void Main()           {              MessageBox( 0, &amp;quot;Hello, this is PInvoke in operation!&amp;quot;, &amp;quot;.NET&amp;quot;, 0 );           }      }          &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www,pinvoke.net/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Pinvoke.net&lt;/a&gt; is a great resource for off-the-shelf P/Invoke signatures.&lt;br&gt;&lt;h3&gt;&lt;a&gt;13.3 How do I write to the application configuration file at runtime?&lt;/a&gt;&lt;/h3&gt;  You don&amp;#39;t. See &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.interact-sw.co.uk/iangblog/2004/11/25/savingconfig&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://www.interact-sw.co.uk/iangblog/2004/11/25/savingconfig&lt;/a&gt;.&lt;br&gt;&lt;h3&gt;&lt;a&gt;13.4 What is the difference between an event and a delegate?&lt;/a&gt;&lt;/h3&gt;  An event is just a wrapper for a multicast delegate. Adding a public event to a class is almost the same as adding a public multicast delegate field. In both cases, subscriber objects can register for notifications, and in both cases the publisher object can send notifications to the subscribers. However, a public multicast delegate has the undesirable property that external objects can &lt;i&gt;invoke&lt;/i&gt; the delegate, something we&amp;#39;d normally want to restrict to the publisher. Hence events - an event adds public methods to the containing class to add and remove receivers, but does not make the invocation mechanism public. &lt;br&gt;See this &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blog.monstuff.com/archives/000040.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt; by Julien Couvreur for more discussion.&lt;br&gt;&lt;h3&gt;&lt;a&gt;13.5 What size is a .NET object?&lt;/a&gt;&lt;/h3&gt;  Each instance of a reference type has two fields maintained by the runtime - a method table pointer and a sync block. These are 4 bytes each on a 32-bit system, making a total of 8 bytes per object overhead. Obviously the instance data for the type must be added to this to get the overall size of the object. So, for example, instances of the following class are 12 bytes each:    class MyInt      {          ...          private int x;      }  However, note that with the current implementation of the CLR there seems to be a minimum object size of 12 bytes, even for classes with no data (e.g. System.Object).&lt;br&gt;Values types have no equivalent overhead.&lt;br&gt;&lt;h3&gt;&lt;a&gt;13.6 Will my .NET app run on 64-bit Windows?&lt;/a&gt;&lt;/h3&gt;  64-bit (x64) versions of Windows support both 32-bit and 64-bit processes, and corresponding 32-bit and 64-bit versions of .NET 2.0. (.NET 1.1 is 32-bit only).&lt;br&gt;.NET 1.x apps automatically run as 32-bit processes on 64-bit Windows.&lt;br&gt;.NET 2.0 apps can either run as 32-bit processes or as 64-bit processes. The OS decides which to use based on the PE header of the executable. The flags in the PE header are controlled via the compiler /platform switch, which allows the target of the app to be specified as &amp;#39;x86&amp;#39;, &amp;#39;x64&amp;#39; or &amp;#39;any cpu&amp;#39;. Normally you specify &amp;#39;any cpu&amp;#39;, and your app will run as 32-bit on 32-bit Windows and 64-bit on 64-bit Windows. However if you have some 32-bit native code in your app (loaded via COM interop, for example), you will need to specify &amp;#39;x86&amp;#39;, which will force 64-bit Windows to load your app in a 32-bit process. You can also tweak the 32-bit flag in the PE header using the SDK corflags utility. &lt;br&gt;Some more explanation here:&lt;br&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blogs.msdn.com/gauravseth/archive/2006/03/07/545104.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://blogs.msdn.com/gauravseth/archive/2006/03/07/545104.aspx&lt;/a&gt;&lt;br&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://blogs.msdn.com/joshwil/archive/2005/04/08/406567.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://blogs.msdn.com/joshwil/archive/2005/04/08/406567.aspx&lt;/a&gt;&lt;br&gt;&lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/netframework/programming/64bit/gettingstarted/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://msdn.microsoft.com/netframework/programming/64bit/gettingstarted/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;13.7 What is reflection?&lt;/a&gt;&lt;/h3&gt;  All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called &lt;b&gt;reflection&lt;/b&gt;. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.&lt;br&gt;Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.&lt;br&gt;Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder). &lt;br&gt;&lt;h2&gt;&lt;a&gt;14. .NET 2.0&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;14.1 What are the new features of .NET 2.0?&lt;/a&gt;&lt;/h3&gt;  Generics, anonymous methods, partial classes, iterators, property visibility (separate visibility for get and set) and static classes. See &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/msdnmag/issues/04/05/C20/default.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://msdn.microsoft.com/msdnmag/issues/04/05/C20/default.aspx&lt;/a&gt; for more information about these features.&lt;br&gt;&lt;h3&gt;&lt;a&gt;14.2 What are the new 2.0 features useful for?&lt;/a&gt;&lt;/h3&gt;  Generics are useful for writing efficient type-independent code, particularly where the types might include value types. The obvious application is container classes, and the .NET 2.0 class library includes a suite of generic container classes in the System.Collections.Generic namespace. Here&amp;#39;s a simple example of a generic container class being used:    List&amp;lt;int&amp;gt; myList = new List&amp;lt;int&amp;gt;();      myList.Add( 10 );  Anonymous methods reduce the amount of code you have to write when using delegates, and are therefore especially useful for GUI programming. Here&amp;#39;s an example    AppDomain.CurrentDomain.ProcessExit += delegate { Console.WriteLine(&amp;quot;Process ending ...&amp;quot;); };  Partial classes is a useful feature for separating machine-generated code from hand-written code in the same class, and will therefore be heavily used by development tools such as Visual Studio. &lt;br&gt;Iterators reduce the amount of code you need to write to implement IEnumerable/IEnumerator. Here&amp;#39;s some sample code:    static void Main()      {          RandomEnumerator re = new RandomEnumerator( 5 );          foreach( double r in re )              Console.WriteLine( r );          Console.Read();      }        class RandomEnumerator : IEnumerable&amp;lt;double&amp;gt;      {          public RandomEnumerator(int size) { m_size = size; }            public IEnumerator&amp;lt;double&amp;gt; GetEnumerator()          {              Random rand = new Random();              for( int i=0; i &amp;lt; m_size; i++ )                  yield return rand.NextDouble();          }            int m_size = 0;      }  The use of &amp;#39;yield return&amp;#39; is rather strange at first sight. It effectively synthethises an implementation of IEnumerator, something we had to do manually in .NET 1.x.&lt;br&gt;&lt;h3&gt;&lt;a&gt;14.3 What&amp;#39;s the problem with .NET generics?&lt;/a&gt;&lt;/h3&gt;  .NET generics work great for container classes. But what about other uses? Well, it turns out that .NET generics have a major limitation - they require the type parameter to be &lt;i&gt;constrained&lt;/i&gt;. For example, you cannot do this:    static class Disposer&amp;lt;T&amp;gt;      {          public static void Dispose(T obj) { obj.Dispose(); }      }  The C# compiler will refuse to compile this code, as the type T has not been constrained, and therefore only supports the methods of System.Object. Dispose is not a method on System.Object, so the compilation fails. To fix this code, we need to add a &lt;b&gt;where&lt;/b&gt; clause, to reassure the compiler that our type T does indeed have a Dispose method    static class Disposer&amp;lt;T&amp;gt; where T : IDisposable      {          public static void Dispose(T obj) { obj.Dispose(); }      }  The problem is that the requirement for explicit contraints is very limiting. We can use constraints to say that T implements a particular &lt;i&gt;interface&lt;/i&gt;, but we can&amp;#39;t dilute that to simply say that T implements a particular &lt;i&gt;method&lt;/i&gt;. Contrast this with C++ templates (for example), where no constraint at all is required - it is &lt;i&gt;assumed&lt;/i&gt; (and verified at compile time) that if the code invokes the Dispose() method on a type, then the type will support the method. &lt;br&gt;In fact, after writing generic code with interface constraints, we quickly see that we haven&amp;#39;t gained much over non-generic interface-based programming. For example, we can easily rewrite the Disposer class without generics:    static class Disposer      {          public static void Dispose( IDisposable obj ) { obj.Dispose(); }      }  For more on this topic, start by reading the following articles:&lt;br&gt;Bruce Eckel: &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.mindview.net/WebLog/log-0050&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://www.mindview.net/WebLog/log-0050&lt;/a&gt;&lt;br&gt;Ian Griffiths: &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.interact-sw.co.uk/iangblog/2004/03/14/generics&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://www.interact-sw.co.uk/iangblog/2004/03/14/generics&lt;/a&gt;&lt;br&gt;Charles Cook: &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.cookcomputing.com/blog/archives/000425.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://www.cookcomputing.com/blog/archives/000425.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;h3&gt;&lt;a&gt;14.4 What&amp;#39;s new in the .NET 2.0 class library?&lt;/a&gt;&lt;/h3&gt;  Here is a selection of new features in the .NET 2.0 class library:&lt;br&gt;&lt;ul&gt;  &lt;li&gt;Generic collections in the System.Collections.Generic namespace.   &lt;/li&gt;&lt;li&gt;The &lt;b&gt;System.Nullable&amp;lt;T&amp;gt;&lt;/b&gt; type. (Note that C# has special syntax for this type, e.g. int? is equivalent to Nullable&amp;lt;int&amp;gt;)   &lt;/li&gt;&lt;li&gt;The &lt;b&gt;GZipStream&lt;/b&gt; and &lt;b&gt;DeflateStream&lt;/b&gt; classes in the System.IO.Compression namespace.   &lt;/li&gt;&lt;li&gt;The &lt;b&gt;Semaphore&lt;/b&gt; class in the System.Threading namespace.   &lt;/li&gt;&lt;li&gt;Wrappers for DPAPI in the form of the &lt;b&gt;ProtectedData&lt;/b&gt; and &lt;b&gt;ProtectedMemory&lt;/b&gt; classes in the System.Security.Cryptography namespace.   &lt;/li&gt;&lt;li&gt;The IPC remoting channel in the System.Runtime.Remoting.Channels.Ipc namespace, for optimised intra-machine communication.&lt;/li&gt;&lt;/ul&gt;  and many, many more. See &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn2.microsoft.com/en-us/library/t357fb32(en-US,VS.80).aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://msdn2.microsoft.com/en-us/library/t357fb32(en-US,VS.80).aspx&lt;/a&gt; for a comprehensive list of changes.&lt;/div&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>C# FAQ</title><link>http://faqworldofrastogi.wetpaint.com/page/C%23+FAQ</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/C%23+FAQ</guid><pubDate>Wed, 22 Nov 2006 00:07:28 CST</pubDate><description>&lt;table class=&quot;MsoNormalTable&quot; width=&quot;612&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;612&quot;&gt;  &lt;b&gt;C# FAQ&lt;/b&gt; &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;97%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;Delegates&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;table class=&quot;MsoTableGrid&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td width=&quot;590&quot;&gt;  &lt;b&gt;Q: What do delegates buy you?&lt;/b&gt;&lt;br&gt;A: Delegates enable scenarios that some other languages have addressed with function pointers. However, unlike function pointers, delegates are object-oriented and type-safe. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;590&quot;&gt;  &lt;b&gt;Q: Are delegates really type-safe?&lt;/b&gt;&lt;br&gt;Not really. A delegate instance does not know or care about the classes of the methods it encapsulates; all that matters is that those methods be compatible with the delegate&amp;#39;s type. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;590&quot;&gt;  &lt;b&gt;Q: What does that mean?&lt;/b&gt;&lt;br&gt;The problem is best illustrated with an example: &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  using System;&lt;br&gt;&lt;br&gt;class Department {&lt;br&gt;public delegate void Fireable();&lt;br&gt;&lt;br&gt;public static void FireEmployee(Fireable fireable) {&lt;br&gt;fireable();&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Military {&lt;br&gt;public delegate void Fireable();&lt;br&gt;&lt;br&gt;public static void FireMissile(Fireable fireable) {&lt;br&gt;fireable();&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Missile {&lt;br&gt;public void Fire() {&lt;br&gt;Console.WriteLine(&amp;quot;missile fired&amp;quot;);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Employee {&lt;br&gt;public void Fire() {&lt;br&gt;Console.WriteLine(&amp;quot;employee fired&amp;quot;);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Test {&lt;br&gt;static Employee e1 = new Employee();&lt;br&gt;static Missile e2 = new Missile();&lt;br&gt;&lt;br&gt;static void Main(string[] args) {&lt;br&gt;Department.Fireable e = new Department.Fireable(e2.Fire);&lt;br&gt;Department.FireEmployee(e);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;In this program, the programmer has made an error. The line   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Department.Fireable e = new Department.Fireable(e2.Fire);&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;really should be   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Department.Fireable e = new Department.Fireable(e1.Fire);&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;However the compiler does not detect this coding error. The program compiles fine and you get this output when you run it:   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  missile fired&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Uh oh! The programmer intended to fire an employee, but he has launched a missile instead!   &lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;590&quot;&gt;  &lt;b&gt;Q: Is there a better way to do this?&lt;/b&gt;&lt;br&gt;A: Yes. You can get type safety by using interfaces instead of delegates. &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  using System;&lt;br&gt;&lt;br&gt;class Department {&lt;br&gt;public interface Fireable {&lt;br&gt;void Fire();&lt;br&gt;}&lt;br&gt;public static void FireEmployee(Fireable fireable) {&lt;br&gt;fireable.Fire();&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Military {&lt;br&gt;public interface Fireable {&lt;br&gt;void Fire();&lt;br&gt;}&lt;br&gt;public static void FireMissile(Fireable fireable) {&lt;br&gt;fireable.Fire();&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Missile : Military.Fireable {&lt;br&gt;public void Fire() {&lt;br&gt;Console.WriteLine(&amp;quot;missile fired&amp;quot;);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Employee : Department.Fireable {&lt;br&gt;public void Fire() {&lt;br&gt;Console.WriteLine(&amp;quot;employee fired&amp;quot;);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;class Test {&lt;br&gt;static Employee e1 = new Employee();&lt;br&gt;static Missile e2 = new Missile();&lt;br&gt;&lt;br&gt;static void Main(string[] args) {&lt;br&gt;Department.Fireable e = e1;&lt;br&gt;Department.FireEmployee(e);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Try changing the line   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Department.Fireable e = e1;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;to this:   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Department.Fireable e = e2;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;When you try to compile the program the compiler tells you:   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  test.cs(38,33): error CS0029: Cannot implicitly convert type &amp;#39;Missile&amp;#39; to&lt;br&gt;&amp;#39;Department.Fireable&amp;#39;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;The compiler has detected your coding error!   &lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;590&quot;&gt;  &lt;b&gt;Q: What is &lt;i&gt;type safety&lt;/i&gt; all about?&lt;/b&gt;&lt;br&gt;A: Type safety is about increasing the opportunities for the compiler to detect your coding errors. If you use interfaces instead of delegates the compiler will have more opportunities to detect your coding errors. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;590&quot;&gt;  &lt;b&gt;Q: What other differences exist between delegates and interfaces?&lt;/b&gt;&lt;br&gt;A: Interfaces carry semantics, and when a programmer implements an interface, he is typically well aware of that semantics. When you try to invoke a particular method via an interface, you can be fairly certain that if you succeed, the semantics of that method is what you expect. For that reason, using interfaces is essentially doing a check for semantic correctness on some level. Delegates, on the other hand, by only verifying the method signature, make the programmer responsible for ensuring that the semantics of the method is compatible. The semantics may cover not only the meaning of the arguments and return value (some times even the order of the arguments if they are of the same type), the ranges of the arguments, but also an invocation order when multiple methods are concerned. Hence, in a sufficiently large program there is plenty of margin to make an error when different programmers are not forced to comply with a uniform semantics (as they would be if interfaces were used). &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td width=&quot;590&quot;&gt;  &lt;b&gt;Q: What can we conclude from all this?&lt;/b&gt;&lt;br&gt;A: Use of delegates results in shorter but less reliable code. &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;C# FAQ&lt;/b&gt;   &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot; width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;Boxing and unboxing&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;b&gt;Q: What does boxing and unboxing buy you?&lt;/b&gt;&lt;br&gt;A: Boxing and unboxing enable &lt;i&gt;type system unification&lt;/i&gt;. &lt;br&gt;&lt;b&gt;Q: What is type system unification?&lt;/b&gt;&lt;br&gt;The goal of type system unification is to bridge the gap between value types and reference types that exists in most languages. For example, a Stack class can provide Push and Pop methods that take and return object values. &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  public class Stack&lt;br&gt;{&lt;br&gt;public object Pop() {...}&lt;br&gt;public void Push(object o) {...}&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;Because C# has a unified type system, the Stack class can be used with elements of any type, including value types like int. &lt;br&gt;&lt;b&gt;Q: Does boxing and unboxing really bridge the gap between value types and reference types?&lt;/b&gt;&lt;br&gt;No, not really. Reference types have the concept of identity and equality, while value types only have equality. Boxing and unboxing does not change this fundamental difference. &lt;br&gt;Autoboxing in C# allows value types to go back and forth between being objects, but each time a value type becomes an object it acquires a new identity. Here&amp;#39;s a sample program to illustrate this problem: &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  using System;&lt;br&gt;&lt;br&gt;struct A {&lt;br&gt;}&lt;br&gt;&lt;br&gt;class B {&lt;br&gt;}&lt;br&gt;&lt;br&gt;public class Test {&lt;br&gt;static Object Process(Object o) {&lt;br&gt;if (o is A) {&lt;br&gt;A a = (A)o;&lt;br&gt;// do something with a&lt;br&gt;return a;&lt;br&gt;}&lt;br&gt;else if (o is B) {&lt;br&gt;B b = (B)o;&lt;br&gt;// do something with b&lt;br&gt;return b;&lt;br&gt;}&lt;br&gt;return null;&lt;br&gt;}&lt;br&gt;&lt;br&gt;static void Check(Object o) {&lt;br&gt;Console.WriteLine(o == Process(o));&lt;br&gt;}&lt;br&gt;&lt;br&gt;public static void Main(string[] args) {&lt;br&gt;Check(new A());&lt;br&gt;Check(new B());&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;This program prints &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  False&lt;br&gt;True&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;which may be unexpected if you don&amp;#39;t understand that value types and reference types cannot be treated the same way. This illustrates the fact that C# does not bridge the gap between value types and reference types. &lt;br&gt;The solution to this problem is to use wrapper classes. Pretending there is no difference between reference types and value types is dangerous as it will invariably result in hard-to-detect bugs, as demonstrated by this example. &lt;br&gt;&lt;b&gt;Q: What other pitfalls should I be aware of?&lt;/b&gt;&lt;br&gt;A: A boxing conversion always makes a copy of the value being boxed. This is different from a conversion of a reference-type to type object, in which the value continues to reference the same instance. For example, given the declaration &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  struct Point {&lt;br&gt;public int x, y;&lt;br&gt;public Point(int x, int y) {&lt;br&gt;this.x = x;&lt;br&gt;this.y = y;&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;the following statements &lt;br&gt;&lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  Point p = new Point(10, 10);&lt;br&gt;object box = p;&lt;br&gt;p.x = 20;&lt;br&gt;Console.Write(((Point)box).x);&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;will output the value 10 because the implicit boxing operation that occurs in the assignment of p to box causes the value of p to be copied. Had Point been declared a class instead, the value 20 would be output because p and box would reference the same instance. &lt;br&gt;&lt;b&gt;Q: Isn&amp;#39;t it cool to have collections which can take both ints as well as strings?&lt;/b&gt;&lt;br&gt;A: Yes, but note that if you store a value type in a collection, then in order to update the value you have to unbox, update the value, rebox the updated value and then replace the object in the collection. This has two problems: &lt;br&gt;&lt;ul&gt;  &lt;li&gt;  Performance. As &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://msdn.microsoft.com/library/en-us/dncscol/html/csharp03152001.asp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;this article&lt;/a&gt; shows, you can almost double performance by using wrapper classes (see IntHolderClass) instead of autoboxing. &lt;/li&gt;  &lt;li&gt;  Loss of identity. The updated object is not the same as the old object. This can break code that depends on the identity of the object. Again, this problem can also be solved by using a wrapper class. &lt;/li&gt;&lt;/ul&gt;&lt;b&gt;Q: What can we conclude from all this?&lt;/b&gt;   &lt;br&gt;A: The &amp;#39;Type System Unification&amp;#39; in C# is half-baked and full of pitfalls. &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;C# FAQ&lt;/b&gt;   &lt;br&gt;  &lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td class=&quot;ReverseVideo&quot;&gt;Unchecked Exceptions&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Q: What is the problem with checked exceptions?&lt;br&gt;&lt;/b&gt;A: With checked exceptions, you have to either catch exceptions thrown by the methods you call, or mention the exception in the throws clause of your method. Because of the tedium of mentioning each exception in the throws clause, some programmers may take the shortcut of &lt;i&gt;swallowing&lt;/i&gt; exceptions. &lt;br&gt;&lt;b&gt;Q: What is meant by &lt;i&gt;swallowing&lt;/i&gt; an exception?&lt;br&gt;&lt;/b&gt;A: You should only catch exceptions that you are prepared to handle. Otherwise, if you catch an exception and ignore it (or log it), you are &amp;quot;swallowing&amp;quot; the exception. As a result, code higher up the call chain that may be prepared to handle the exception will never see the exception. &lt;br&gt;&lt;b&gt;Q: Does C# solve the problem of swallowed exceptions?&lt;br&gt;&lt;/b&gt;A: No. In fact, C# requires it! Methods in C# cannot specify the exceptions it may throw. The documentation of the method you wish to call may mention the list of exceptions you can expect. But this list of exceptions is not enforced by the compiler, and is not guaranteed to be exhaustive. Also, since the list of exceptions is not part of the contract, the method can be revised at any time and a new exception that you didn&amp;#39;t know about can be thrown. &lt;br&gt;Since there is no previously agreed upon list of exceptions, you are left with no option but to catch all exceptions if you want to recover from an exception (such as by offering to connect to an alternate database if the primary database is down, etc.) &lt;br&gt;Obviously, if you catch all exceptions, you will end up swallowing some of them. &lt;br&gt;&lt;b&gt;Q: What other problems exist with C# exceptions?&lt;br&gt;&lt;/b&gt;A: Often in C#, if you have multiple implementations of an interface, each of those implementations may have their own disjoint exception hierarchies. (i.e., the exception hierarchies have no common classes other than System.Exception.) Example: ADO.NET. This makes it impossible for generic code (i.e., code that can use any of those implementations) to recover from exceptions generically without catching &lt;i&gt;all&lt;/i&gt; exceptions (i.e., System.Exception.) &lt;br&gt;Again, if you catch all exceptions you will end up swallowing some of them. &lt;br&gt;&lt;b&gt;Q: What can we conclude from all this?&lt;br&gt;&lt;/b&gt;A: Unchecked exceptions results in shorter but less robust code. &lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>PL/SQL FAQ</title><link>http://faqworldofrastogi.wetpaint.com/page/PL%2FSQL+FAQ</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/PL%2FSQL+FAQ</guid><pubDate>Tue, 21 Nov 2006 23:39:22 CST</pubDate><description>  &lt;table align=&quot;bottom&quot; class=&quot;wp-border-all&quot; width=&quot;400&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td class=&quot;wp-border-all&quot; width=&quot;100%&quot;&gt;&lt;b&gt;What is PL/SQL and what is it used for?&lt;/b&gt;    SQL is a declarative language that allows database programmers to write a SQL declaration and hand it to the database for execution. As such, SQL cannot be used to execute procedural code with conditional, iterative and sequential statements. To overcome this limitation, PL/SQL was created.  PL/SQL is Oracle&amp;#39;s Procedural Language extension to SQL. PL/SQL&amp;#39;s language syntax, structure and data types are similar to that of &lt;b&gt;ADA&lt;/b&gt;. Some of the statements provided by PL/SQL:     &lt;b&gt;Conditional Control Statements:&lt;/b&gt;     o                                IF ... THEN ... ELSIF ... ELSE ... END IF;   o                                CASE ... WHEN ... THEN ... ELSE ... END CASE;   o                                   &lt;b&gt;Iterative Statements:&lt;/b&gt;  o                                LOOP ... END LOOP;   o                                WHILE ... LOOP ... END LOOP;   o                                FOR ... IN [REVERSE] ... LOOP ... END LOOP;   &lt;b&gt;Sequential Control Statements:&lt;/b&gt;  o                                GOTO ...;   o                                NULL;   The PL/SQL language includes object oriented programming techniques such as encapsulation, function overloading, information hiding (all but inheritance).   PL/SQL is commonly used to write data-centric programs to manipulate data in an Oracle database.  Example PL/SQL block:   &lt;br&gt;&lt;div&gt;BEGIN  -- A PL/SQL cursor  FOR cursor1 IN (SELECT * FROM table1) -- This is an embedded SQL statement  LOOP    DBMS_OUTPUT.PUT_LINE(&amp;#39;Column1 is: &amp;#39; || TO_CHAR(cursor1.column1) ||                       &amp;#39;, Column2 is: &amp;#39; || cursor1.column2);  END LOOP;END;/&lt;/div&gt;      &lt;b&gt;How can one see if somebody modified any code?&lt;/b&gt;         The source code for stored procedures, functions and packages are stored in the Oracle Data Dictionary. One can detect code changes by looking at the LAST_DDL_TIME column in the USER_OBJECTS dictionary view. Example:   &lt;br&gt;&lt;div&gt;SELECT OBJECT_NAME,       TO_CHAR(CREATED,       &amp;#39;DD-Mon-RR HH24:MI&amp;#39;) CREATE_TIME,       TO_CHAR(LAST_DDL_TIME, &amp;#39;DD-Mon-RR HH24:MI&amp;#39;) MOD_TIME,       STATUSFROM   USER_OBJECTSWHERE  LAST_DDL_TIME &amp;gt; &amp;#39;&amp;amp;CHECK_FROM_DATE&amp;#39;;&lt;/div&gt;      &lt;b&gt;Should one use PL/SQL or Java to code procedures and triggers?&lt;/b&gt;    Both PL/SQL and Java can be used to create Oracle stored procedures and triggers. This often leads to questions like &amp;quot;Which of the two is the best?&amp;quot; and &amp;quot;Will Oracle ever desupport PL/SQL in favour of Java?&amp;quot;.   Many Oracle applications are based on PL/SQL and it would be difficult of Oracle to ever desupport PL/SQL. In fact, all indications are that PL/SQL still has a bright future ahead of it. Many enhancements are still being made to PL/SQL. For example, Oracle 9iDB supports native compilation of Pl/SQL code to binaries. Not to mention the numerous PL/SQL enhancements made in Oracle 10g.  PL/SQL and Java appeal to different people in different job roles. The following table briefly describes the similarities and difference between these two language environments:     &lt;b&gt;PL/SQL:&lt;/b&gt;  o                                Can be used to create Oracle packages, procedures and triggers   o                                Data centric and tightly integrated into the database   o                                Proprietary to Oracle and difficult to port to other database systems   o                                Data manipulation is slightly faster in PL/SQL than in Java   o                                Easier to use than Java (depending on your background)      &lt;b&gt;Java:&lt;/b&gt;  o                                Can be used to create Oracle packages, procedures and triggers   o                                Open standard, not proprietary to Oracle   o                                Incurs some data conversion overhead between the Database and Java type systems   o                                Java is more difficult to use (depending on your background)   PS: Starting with Oracle 10g, .NET procedures can also be stored withing the database (Windows only). Nevertheless, unlike PL/SQL and JAVA, .NET code is not usable on non-Windows systems.      &lt;b&gt;How can one keep a history of PL/SQL code changes?&lt;/b&gt;       One can build a history of PL/SQL code changes by setting up an AFTER CREATE schema (or database) level trigger (available from Oracle 8.1.7). This way one can easily revert to previous code should someone make any catastrophic changes. Look at this example:   &lt;br&gt;&lt;div&gt;CREATE TABLE SOURCE_HIST                     -- Create history table  AS SELECT SYSDATE CHANGE_DATE, USER_SOURCE.*  FROM   USER_SOURCE WHERE 1=2; CREATE OR REPLACE TRIGGER change_hist        -- Store code in hist table  AFTER CREATE ON SCOTT.SCHEMA          -- Change SCOTT to your schema nameDECLAREBEGIN  if DICTIONARY_OBJ_TYPE in (&amp;#39;PROCEDURE&amp;#39;, &amp;#39;FUNCTION&amp;#39;,                             &amp;#39;PACKAGE&amp;#39;, &amp;#39;PACKAGE BODY&amp;#39;, &amp;#39;TYPE&amp;#39;) then     -- Store old code in SOURCE_HIST table     INSERT INTO SOURCE_HIST            SELECT sysdate, user_source.* FROM USER_SOURCE             WHERE  TYPE = DICTIONARY_OBJ_TYPE               AND  NAME = DICTIONARY_OBJ_NAME;  end if;EXCEPTION  WHEN OTHERS THEN       raise_application_error(-20000, SQLERRM);END;/show errors&lt;/div&gt;&lt;b&gt;How can I protect my PL/SQL source code?&lt;/b&gt;     Oracle provides a binary wrapper utility that can be used to scramble PL/SQL source code. This utility was introduced in Oracle7.2 (PL/SQL V2.2) and is located in the ORACLE_HOME/bin directory.  The utility use human-readable PL/SQL source code as input, and writes out portable binary object code (somewhat larger than the original). The binary code can be distributed without fear of exposing your proprietary algorithms and methods. Oracle will still understand and know how to execute the code. Just be careful, there is no &amp;quot;decode&amp;quot; command available. So, don&amp;#39;t lose your source!  The syntax is:  wrap iname=myscript.pls oname=xxxx.plb     Please note: &lt;b&gt;there is no way to unwrap a *.plb binary file&lt;/b&gt;. You are supposed to backup and keep your *.pls source files after wrapping them.      &lt;b&gt;Can one print to the screen from PL/SQL?&lt;/b&gt;         One can use the DBMS_OUTPUT package to write information to an output buffer. This buffer can be displayed on the screen from SQL*Plus if you issue the &lt;i&gt;SET &lt;/i&gt;&lt;i&gt;SERVEROUTPUT&lt;/i&gt;&lt;i&gt;ON&lt;/i&gt;&lt;i&gt;;&lt;/i&gt; command. For example:&lt;br&gt;&lt;div&gt;set serveroutput onbegin   dbms_output.put_line(&amp;#39;Look Ma, I can print from PL/SQL!!!&amp;#39;);end;/&lt;/div&gt;  DBMS_OUTPUT is useful for debugging PL/SQL programs. However, if you print too much, the output buffer will overflow. In that case, set the buffer size to a larger value, eg.: set serveroutput on size 200000  If you forget to set serveroutput on type &lt;i&gt;SET SERVEROUTPUT ON&lt;/i&gt; once you remember, and then &lt;i&gt;EXEC NULL;&lt;/i&gt;. If you haven&amp;#39;t cleared the DBMS_OUTPUT buffer with the disable or enable procedure, SQL*Plus will display the entire contents of the buffer when it executes this dummy PL/SQL block.  Note that DBMS_OUTPUT doesn&amp;#39;t print blank or NULL lines. To overcome this problem, SET SERVEROUTPUT ON FORMAT WRAP; Look at this example with this option first disabled and then enabled:&lt;br&gt;&lt;div&gt;SQL&amp;gt; SET SERVEROUTPUT ONSQL&amp;gt; begin  2    dbms_output.put_line(&amp;#39;The next line is blank&amp;#39;);  3    dbms_output.put_line(&amp;#39;&amp;#39;);  4    dbms_output.put_line(&amp;#39;The above line should be blank&amp;#39;);  5  end;  6  /The next line is blankThe above line should be blank SQL&amp;gt; SET SERVEROUTPUT ON &lt;b&gt;FORMAT WRAP&lt;/b&gt;SQL&amp;gt; begin  2    dbms_output.put_line(&amp;#39;The next line is blank&amp;#39;);  3    dbms_output.put_line(&amp;#39;&amp;#39;);  4    dbms_output.put_line(&amp;#39;The above line should be blank&amp;#39;);  5  end;  6  /The next line is blank The above line should be blank&lt;/div&gt;         &lt;b&gt;Can one read/write files from PL/SQL?&lt;/b&gt;         The UTL_FILE database package can be used to read and write operating system files.      A DBA user needs to grant you access to read from/ write to a specific directory before using this package. Here is an example:    &lt;br&gt;&lt;div&gt;CONNECT / AS SYSDBACREATE OR REPLACE DIRECTORY mydir AS &amp;#39;/tmp&amp;#39;;GRANT read, write ON DIRECTORY mydir TO scott;&lt;/div&gt;        Provide user access to the UTL_FILE package (created by catproc.sql):   &lt;br&gt;&lt;div&gt;GRANT EXECUTE ON UTL_FILE TO scott;&lt;/div&gt;     Copy and paste these examples to get you started:     &lt;b&gt;Write File&lt;/b&gt;   &lt;br&gt;&lt;div&gt;DECLARE  fHandler UTL_FILE.FILE_TYPE;BEGIN  fHandler := UTL_FILE.FOPEN(&amp;#39;MYDIR&amp;#39;, &amp;#39;myfile&amp;#39;, &amp;#39;w&amp;#39;);  UTL_FILE.PUTF(fHandler, &amp;#39;Look ma, I&amp;#39;&amp;#39;m writing to a file!!!\n&amp;#39;);  UTL_FILE.FCLOSE(fHandler);EXCEPTION  WHEN utl_file.invalid_path THEN     raise_application_error(-20000, &amp;#39;Invalid path. Create directory or set UTL_FILE_DIR.&amp;#39;);END;/&lt;/div&gt;     &lt;b&gt;Read File&lt;/b&gt;   &lt;br&gt;&lt;div&gt;DECLARE  fHandler UTL_FILE.FILE_TYPE;  buf      varchar2(4000);BEGIN  fHandler := UTL_FILE.FOPEN(&amp;#39;MYDIR&amp;#39;, &amp;#39;myfile&amp;#39;, &amp;#39;r&amp;#39;);  UTL_FILE.GET_LINE(fHandler, buf);  dbms_output.put_line(&amp;#39;DATA FROM FILE: &amp;#39;||buf);  UTL_FILE.FCLOSE(fHandler);EXCEPTION  WHEN utl_file.invalid_path THEN     raise_application_error(-20000, &amp;#39;Invalid path. Create directory or set UTL_FILE_DIR.&amp;#39;);END;/&lt;/div&gt;     NOTE: UTL_FILE was introduced with Oracle 7.3. Before Oracle 7.3 the only means of writing a file was to use DBMS_OUTPUT with the SQL*Plus SPOOL command.   &lt;b&gt;Can one call DDL statements from PL/SQL?&lt;/b&gt;       One can call DDL statements like CREATE, DROP, TRUNCATE, etc. from PL/SQL by using the &amp;quot;EXECUTE IMMEDATE&amp;quot; statement. Users running Oracle versions below 8i can look at the DBMS_SQL package (see FAQ about Dynamic SQL).   &lt;br&gt;&lt;div&gt;begin   EXECUTE IMMEDIATE &amp;#39;CREATE TABLE X(A DATE)&amp;#39;;end;&lt;/div&gt;     NOTE: The DDL statement in quotes should not be terminated with a semicolon.   &lt;b&gt;Can one use dynamic SQL statements from PL/SQL?&lt;/b&gt;       Starting from Oracle8i one can use the &amp;quot;EXECUTE IMMEDIATE&amp;quot; statement to &lt;br&gt;execute dynamic SQL and PL/SQL statements (statements created at run-time). Look at these examples. Note that the statements within quotes are NOT semicolon terminated:   &lt;br&gt;&lt;div&gt;EXECUTE IMMEDIATE &amp;#39;CREATE TABLE x (a NUMBER)&amp;#39;; -- Using bind variables...sql_stmt := &amp;#39;INSERT INTO dept VALUES (:1, :2, :3)&amp;#39;;EXECUTE IMMEDIATE sql_stmt USING dept_id, dept_name, location; -- Returning a cursor...sql_stmt := &amp;#39;SELECT * FROM emp WHERE empno = :id&amp;#39;;EXECUTE IMMEDIATE sql_stmt INTO emp_rec USING emp_id;&lt;/div&gt;     One can also use the older DBMS_SQL package (V2.1 and above) to execute &lt;br&gt;dynamic statements. Look at these examples:   &lt;br&gt;&lt;div&gt;CREATE OR REPLACE PROCEDURE DYNSQL AS  cur integer;  rc  integer;BEGIN  cur := DBMS_SQL.OPEN_CURSOR;  DBMS_SQL.PARSE(cur, &amp;#39;CREATE TABLE X (Y DATE)&amp;#39;, DBMS_SQL.NATIVE);  rc := DBMS_SQL.EXECUTE(cur);  DBMS_SQL.CLOSE_CURSOR(cur);END;/&lt;/div&gt;     More complex DBMS_SQL example using bind variables:   &lt;br&gt;&lt;div&gt;CREATE OR REPLACE PROCEDURE DEPARTMENTS(NO IN DEPT.DEPTNO%TYPE) AS  v_cursor integer;  v_dname  char(20);  v_rows   integer;BEGIN  v_cursor := DBMS_SQL.OPEN_CURSOR;  DBMS_SQL.PARSE(v_cursor, &amp;#39;select dname from dept where deptno &amp;gt; :x&amp;#39;, DBMS_SQL.V7);  DBMS_SQL.BIND_VARIABLE(v_cursor, &amp;#39;:x&amp;#39;, no);  DBMS_SQL.DEFINE_COLUMN_CHAR(v_cursor, 1, v_dname, 20);  v_rows := DBMS_SQL.EXECUTE(v_cursor);  loop    if DBMS_SQL.FETCH_ROWS(v_cursor) = 0 then       exit;    end if;    DBMS_SQL.COLUMN_VALUE_CHAR(v_cursor, 1, v_dname);    DBMS_OUTPUT.PUT_LINE(&amp;#39;Deptartment name: &amp;#39;||v_dname);  end loop;  DBMS_SQL.CLOSE_CURSOR(v_cursor);EXCEPTION  when others then       DBMS_SQL.CLOSE_CURSOR(v_cursor);       raise_application_error(-20000, &amp;#39;Unknown Exception Raised: &amp;#39;||sqlcode||&amp;#39; &amp;#39;||sqlerrm);END;/&lt;/div&gt;      &lt;b&gt;What is the difference between %TYPE and %ROWTYPE?&lt;/b&gt;       Both %TYPE and %ROWTYPE are used to define variables in PL/SQL as it is defined within the database. If the datatype or precision of a column changes, the program automically picks up the new definition from the database without having to make any code changes.   The %TYPE and %ROWTYPE constructs provide data independence, reduces maintenance costs, and allows programs to adapt as the database changes to meet new business needs.     &lt;b&gt;%TYPE&lt;/b&gt;     %TYPE is used to declare a &lt;b&gt;&lt;i&gt;field&lt;/i&gt;&lt;/b&gt; with the same type as that of a specified table&amp;#39;s column. Example:   &lt;br&gt;&lt;div&gt;DECLARE   v_EmpName  emp.ename%TYPE;BEGIN   SELECT ename INTO v_EmpName FROM emp WHERE ROWNUM = 1;   DBMS_OUTPUT.PUT_LINE(&amp;#39;Name = &amp;#39; || v_EmpName);END;/&lt;/div&gt;     &lt;b&gt;%ROWTYPE&lt;/b&gt;     %ROWTYPE is used to declare a &lt;b&gt;&lt;i&gt;record&lt;/i&gt;&lt;/b&gt; with the same types as found in the specified database table, view or cursor. Examples:   &lt;br&gt;&lt;div&gt;DECLARE  v_emp emp%ROWTYPE;BEGIN  v_emp.empno := 10;  v_emp.ename := &amp;#39;XXXXXXX&amp;#39;;END;/DECLARE  v_EmpRecord  emp%ROWTYPE;BEGIN  SELECT * INTO v_EmpRecord FROM emp WHERE ROWNUM = 1;  DBMS_OUTPUT.PUT_LINE(&amp;#39;Name = &amp;#39; || v_EmpRecord.ename);  DBMS_OUTPUT.PUT_LINE(&amp;#39;Salary = &amp;#39; || v_EmpRecord.sal);END;/&lt;/div&gt;       &lt;b&gt;What is the result of comparing NULL with NULL?&lt;/b&gt;      NULL is neither equal to NULL, nor it is not equal to NULL. Any comparison to &lt;br&gt;NULL is evaluated to NULL. Look at this code example to convince yourself.   &lt;br&gt;&lt;div&gt;declare  a number := NULL;  b number := NULL;begin  if a=b then     dbms_output.put_line(&amp;#39;True, NULL = NULL&amp;#39;);  elsif a&amp;lt;&amp;gt;b then     dbms_output.put_line(&amp;#39;False, NULL &amp;lt;&amp;gt; NULL&amp;#39;);  else     dbms_output.put_line(&amp;#39;Undefined NULL is neither = nor &amp;lt;&amp;gt; to NULL&amp;#39;);  end if;end;&lt;/div&gt;  The output would be:&lt;br&gt;&lt;div&gt;SQL&amp;gt; /Undefined NULL is neither = nor &amp;lt;&amp;gt; to NULL PL/SQL procedure successfully completed.&lt;/div&gt;     &lt;b&gt;Workarounds:&lt;/b&gt;     Use IS NULL or IS NOT NULL:   &lt;br&gt;&lt;div&gt;declare  a number := NULL;  b number := NULL;begin  if a IS NULL and b IS NULL then     dbms_output.put_line(&amp;#39;Both values are NULL.&amp;#39;);  end if;end;&lt;/div&gt;     Use the nvl() or nvl2() function. Example:   &lt;br&gt;&lt;div&gt;declare  a number := NULL;  b number := NULL;begin  if nvl(a, 99999) = nvl(b, 99999) then     dbms_output.put_line(&amp;#39;Both values are NULL.&amp;#39;);  end if;end;&lt;/div&gt;       &lt;b&gt;How does one get the value of a sequence into a PL/SQL variable?&lt;/b&gt;            As you might know, one cannot use sequences directly from PL/SQL. Oracle (for some silly reason) prohibits this:  i := sq_sequence.NEXTVAL;        However, one can use embedded SQL statements to obtain sequence values:   &lt;br&gt;&lt;div&gt;select sq_sequence.NEXTVAL into :i from dual;&lt;/div&gt;      &lt;b&gt;Can one execute an operating system command from PL/SQL?&lt;/b&gt;        There is no direct way to execute operating system commands from PL/SQL. PL/SQL doesn&amp;#39;t have a &amp;quot;HOST&amp;quot; command, like in SQL*Plus, that allows users to call OS commands. Nevertheless, the following workarounds can be used:     &lt;b&gt;Database Pipes&lt;/b&gt;     &lt;br&gt;Write an external program (using one of the precompiler languages, OCI or Perl with Oracle access modules) to act as a listener on a database pipe (SYS.DBMS_PIPE). Your PL/SQL program then put requests to run commands in the pipe, the listener picks it up and run the requests. Results are passed back on a different database pipe. For an Pro*C example, see chapter 8 of the Oracle Application Developers Guide.         &lt;b&gt;External Procedure Listeners:&lt;/b&gt;     &lt;br&gt;From Oracle8 one can call external 3GL code in a dynamically linked library (DLL or shared object). One just write a library in C/ C++ to do whatever is required. Defining this C/C++ function to PL/SQL makes it executable. Look at this &lt;br&gt;&lt;b&gt;External Procedure&lt;/b&gt; example.         &lt;b&gt;Using Java&lt;/b&gt;     &lt;br&gt;&lt;br&gt;  More detail later...      &lt;b&gt;DBMS_SCHEDULER&lt;/b&gt;     &lt;br&gt;In Oracle 10g and above, one can execute OS commands via the DBMS_SCHEDULER package. Look at this example:       &lt;br&gt;&lt;div&gt;BEGIN  dbms_scheduler.create_job(job_name        =&amp;gt; &amp;#39;myjob&amp;#39;,                            job_type        =&amp;gt; &amp;#39;executable&amp;#39;,                            job_action      =&amp;gt; &amp;#39;/app/oracle/x.sh&amp;#39;,                            enabled         =&amp;gt; TRUE,                            auto_drop       =&amp;gt; TRUE);END;/ exec dbms_scheduler.run_job(&amp;#39;myjob&amp;#39;);&lt;/div&gt;    &lt;b&gt;How does one loop through tables in PL/SQL?&lt;/b&gt;         One can make use of cursors to loop through data within tables. Look at the following &lt;b&gt;nested loops&lt;/b&gt; code example.   &lt;br&gt;&lt;div&gt;DECLARE   CURSOR dept_cur IS   SELECT deptno     FROM dept    ORDER BY deptno;    -- Employee cursor all employees for a dept number   CURSOR emp_cur (v_dept_no DEPT.DEPTNO%TYPE) IS   SELECT ename     FROM emp    WHERE deptno = v_dept_no;BEGIN   FOR dept_rec IN dept_cur LOOP      dbms_output.put_line(&amp;#39;Employees in Department &amp;#39;||TO_CHAR(dept_rec.deptno));       FOR emp_rec in emp_cur(dept_rec.deptno) LOOP         dbms_output.put_line(&amp;#39;...Employee is &amp;#39;||emp_rec.ename);      END LOOP;   END LOOP;END;&lt;/div&gt;      &lt;b&gt;How often should one COMMIT in a PL/SQL loop? / What is the best commit strategy?&lt;/b&gt;         Contrary to popular believe, one should &lt;b&gt;COMMIT less frequently&lt;/b&gt; within a PL/SQL loop to prevent ORA-1555 (Snapshot too old) errors. The higher the frequency of commit, the sooner the extents in the undo/ rollback segments will be cleared for new transactions, causing ORA-1555 errors.  To fix this problem one can easily rewrite code like this:      &lt;br&gt;&lt;div&gt;FOR records IN my_cursor LOOP   ...do some stuff...   COMMIT;END LOOP;COMMIT;&lt;/div&gt;     ... to ...   &lt;br&gt;&lt;div&gt;FOR records IN my_cursor LOOP   ...do some stuff...   i := i+1;   IF mod(i, 10000) = 0 THEN    -- Commit every 10000 records      COMMIT;   END IF;END LOOP;COMMIT;&lt;/div&gt;     If you still get ORA-1555 errors, contact your DBA to increase the undo/ rollback &lt;br&gt;segments.     &lt;b&gt;NOTE:&lt;/b&gt; Although fetching across COMMITs work with Oracle, is not supported by the ANSI standard.      &lt;b&gt;I can SELECT from SQL*Plus but not from PL/SQL. What is wrong?&lt;/b&gt;        PL/SQL respect object privileges given directly to the user, but does not observe privileges given through roles. The consequence is that a SQL statement can work in SQL*Plus, but will give an error in PL/SQL. Choose one of the following solutions:  o                                Grant &lt;b&gt;direct&lt;/b&gt; access on the tables to your user. Do not use roles!   GRANT select ON scott.emp TO my_user;  o                                Define your procedures with invoker rights (Oracle 8i and higher);   o                                 &lt;br&gt;&lt;div&gt;            create or replace procedure proc1                authid current_user is             begin&lt;/div&gt;  &lt;div&gt;...Move all the tables to one user/schema. &lt;/div&gt;      &lt;b&gt;What is a mutating and constraining table?&lt;/b&gt;         &amp;quot;Mutating&amp;quot; means &amp;quot;changing&amp;quot;. A mutating table is a table that is currently being modified by an update, delete, or insert statement. When a trigger tries to reference a table that is in state of flux (being changed), it is considered &amp;quot;mutating&amp;quot; and raises an error since Oracle should not return data that has not yet reached its final state.   Another way this error can occur is if the trigger has statements to change the primary, foreign or unique key columns of the table off which it fires. If you must have triggers on tables that have referential constraints, the workaround is to enforce the referential integrity through triggers as well.  There are several restrictions in Oracle regarding triggers:  o                                A row-level trigger cannot query or modify a mutating table. (Of course, NEW and OLD still can be accessed by the trigger).   o                                A statement-level trigger cannot query or modify a mutating table if the trigger is fired as the result of a CASCADE delete.   o                                Etc.    &lt;b&gt;Can one pass an object/table as an argument to a remote procedure?&lt;/b&gt;        The only way to reference an object type between databases is via a database link. Note that it is not enough to just use &amp;quot;similar&amp;quot; type definitions. Look at this example:      &lt;br&gt;&lt;div&gt;-- Database A: receives a PL/SQL table from database BCREATE OR REPLACE PROCEDURE pcalled(TabX DBMS_SQL.VARCHAR2S) ISBEGIN   -- do something with TabX from database B   null;END;/ -- Database B: sends a PL/SQL table to database ACREATE OR REPLACE PROCEDURE pcalling IS   TabX DBMS_SQL.VARCHAR2S@DBLINK2;BEGIN   pcalled@DBLINK2(TabX);END;/&lt;/div&gt;      &lt;b&gt;Is it better to put code in triggers or procedures? What is the difference?&lt;/b&gt;        In earlier releases of Oracle it was better to put as much code as possible in procedures rather than triggers. At that stage procedures executed faster than triggers as triggers had to be re-compiled every time before executed (unless cached). In more recent releases both triggers and procedures are compiled when created (stored p-code) and one can add as much code as one likes in either procedures or triggers.   &lt;b&gt;Is there a limit on the size of a PL/SQL block?&lt;/b&gt;         Yes, the max size is not an explicit byte limit, but related to the&lt;br&gt;parse tree that is created when you compile the code. You can run the following select statement to query the size of an existing package or procedure:  SQL&amp;gt; select * from dba_object_size where name = &amp;#39;procedure_name&amp;#39;;            &lt;b&gt;Can one COMMIT/ ROLLBACK from within a trigger?&lt;/b&gt;            Changes made within triggers should be committed or rolled back as part of the transaction in which they execute. Thus, triggers are NOT allowed to execute COMMIT or ROLLBACK statements (with the exception of autonomous triggers). Here is an example of what will happen when they do:   &lt;br&gt;&lt;div&gt;SQL&amp;gt; CREATE TABLE tab1 (col1 NUMBER); Table created. SQL&amp;gt; CREATE TABLE log (timestamp DATE, operation VARCHAR2(2000)); Table created. SQL&amp;gt; CREATE TRIGGER tab1_trig  2     AFTER insert ON tab1  3  BEGIN  4     INSERT INTO log VALUES (SYSDATE, &amp;#39;Insert on TAB1&amp;#39;);  5     COMMIT;  6  END;  7  / Trigger created. SQL&amp;gt; INSERT INTO tab1 VALUES (1);INSERT INTO tab1 VALUES (1)            *ERROR at line 1:ORA-04092: cannot COMMIT in a triggerORA-06512: at &amp;quot;SCOTT.TAB1_TRIG&amp;quot;, line 3ORA-04088: error during execution of trigger &amp;#39;SCOTT.TAB1_TRIG&amp;#39;&lt;/div&gt;        &lt;b&gt;Autonomous transactions:&lt;/b&gt;        As workaround, one can use autonomous transactions. Autonomous transactions execute separate from the current transaction.  Unlike regular triggers, autonomous triggers can contain COMMIT and ROLLBACK statements. Example:&lt;br&gt;&lt;div&gt;SQL&amp;gt; CREATE OR REPLACE TRIGGER tab1_trig  2    AFTER insert ON tab1  3  DECLARE  4    PRAGMA AUTONOMOUS_TRANSACTION;  5  BEGIN  6    INSERT INTO log VALUES (SYSDATE, &amp;#39;Insert on TAB1&amp;#39;);  7    COMMIT; -- only allowed in autonomous triggers  8  END;  9  / Trigger created. SQL&amp;gt; INSERT INTO tab1 VALUES (1); 1 row created.&lt;/div&gt;     Note that with the above example will insert and commit log entries - even if the main transaction is rolled-back!     &lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>Oracle FAQ</title><link>http://faqworldofrastogi.wetpaint.com/page/Oracle+FAQ</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/Oracle+FAQ</guid><pubDate>Tue, 21 Nov 2006 23:19:08 CST</pubDate><description>&lt;b&gt;What are the difference between DDL, DML and DCL commands?&lt;/b&gt;    &lt;b&gt;DDL&lt;/b&gt;  &lt;br&gt;&lt;b&gt;Data Definition Language&lt;/b&gt; (DDL) statements are used to define the database structure or schema. Some examples:   o                                CREATE - to create objects in the database   o                                ALTER - alters the structure of the database   o                                DROP - delete objects from the database   o                                TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed   o                                COMMENT - add comments to the data dictionary   o                                RENAME - rename an object      &lt;b&gt;DML&lt;/b&gt;  &lt;br&gt;&lt;b&gt;Data Manipulation Language&lt;/b&gt; (DML) statements are used for managing data within schema objects. Some examples:   o                                SELECT - retrieve data from the a database   o                                INSERT - insert data into a table   o                                UPDATE - updates existing data within a table   o                                DELETE - deletes all records from a table, the space for the records remain   o                                MERGE - UPSERT operation (insert or update)   o                                CALL - call a PL/SQL or Java subprogram   o                                EXPLAIN PLAN - explain access path to data   o                                LOCK TABLE - control concurrency   &lt;b&gt;DCL&lt;/b&gt;  &lt;br&gt;&lt;b&gt;Data Control Language&lt;/b&gt; (DCL) statements. Some examples:   o                                GRANT - gives user&amp;#39;s access privileges to database   o                                REVOKE - withdraw access privileges given with the GRANT command   &lt;b&gt;TCL&lt;/b&gt;  &lt;br&gt;&lt;b&gt;Transaction Control&lt;/b&gt; (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.   o                                COMMIT - save work done   o                                SAVEPOINT - identify a point in a transaction to which you can later roll back   o                                ROLLBACK - restore database to original since the last COMMIT   o                                SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use       &lt;b&gt;What is SQL and where does it come from?&lt;/b&gt;       Structured Query Language (SQL) is a language that provides an interface to relational database systems. The proper pronunciation of SQL is &amp;quot;ess cue ell,&amp;quot; and not &amp;quot;sequel&amp;quot; as is commonly heard.   SQL was developed by IBM in the 1970s for use in System R, and is a de facto standard, as well as an ISO and ANSI standard.   In common usage SQL also encompasses DML (Data Manipulation Language), for INSERTs, UPDATEs, DELETEs and DDL (Data Definition Language), used for creating and modifying tables and other database structures.  The development of SQL is governed by standards. A major revision to the SQL standard was completed in 1992, called SQL2. SQL3 support object extensions and are (partially?) implemented in Oracle8 and 9i.  Example SQL statements:  CREATE TABLE table1 (column1 NUMBER, column2 VARCHAR2(30));  INSERT INTO table1 VALUES (1, &amp;#39;XYZ&amp;#39;);  SELECT * FROM table1 WHERE column2 = &amp;#39;XYZ&amp;#39;;       &lt;b&gt;Difference between TRUNCATE, DELETE and DROP commands&lt;/b&gt;         &lt;b&gt;DELETE&lt;/b&gt;  The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. &lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT COUNT(*) FROM emp;   COUNT(*)----------        14 SQL&amp;gt; DELETE FROM emp WHERE job = &amp;#39;CLERK&amp;#39;; 4 rows deleted. SQL&amp;gt; COMMIT; Commit complete. SQL&amp;gt; SELECT COUNT(*) FROM emp;   COUNT(*)----------        10&lt;/div&gt;     &lt;b&gt;TRUNCATE&lt;/b&gt;     TRUNCATE removes &lt;b&gt;all rows&lt;/b&gt; from a table. The operation cannot be rolled back. As such, TRUCATE is faster and doesn&amp;#39;t use as much undo space as a DELETE.&lt;br&gt;&lt;div&gt;SQL&amp;gt; TRUNCATE TABLE emp; Table truncated. SQL&amp;gt; SELECT COUNT(*) FROM emp;   COUNT(*)----------         0&lt;/div&gt;     &lt;b&gt;DROP&lt;/b&gt;     The DROP command removes a table from the database. All the tables&amp;#39; rows, indexes and privileges will also be removed. The operation cannot be rolled back. &lt;br&gt;&lt;div&gt;SQL&amp;gt; DROP TABLE emp; Table dropped. SQL&amp;gt; SELECT * FROM emp;SELECT * FROM emp              *ERROR at line 1:ORA-00942: table or view does not exist&lt;/div&gt;  &lt;br&gt;DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.   From Oracle 10g a table can be &amp;quot;undropped&amp;quot;. Example:&lt;br&gt;&lt;div&gt;SQL&amp;gt; FLASHBACK TABLE emp TO BEFORE DROP; Flashback complete.&lt;/div&gt;  PS: DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. As such, DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.      &lt;br&gt;&lt;div&gt;  &lt;h3&gt;&lt;b&gt;Difference between TRUNCATE and DELETE commands&lt;/b&gt;&lt;/h3&gt;&lt;/div&gt;     1&amp;gt;TRUNCATE is a DDL command whereas DELETE is a DML command.  2&amp;gt;TRUNCATE is much faster than DELETE.  Reason:When you type DELETE.all the data get copied into the Rollback Tablespace first.then delete operation get performed.Thatswhy when you type ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the Rollback Tablespace).All this process take time.But when you type TRUNCATE,it removes data directly without copying it into the Rollback Tablespace.Thatswhy TRUNCATE is faster.Once you Truncate you cann&amp;#39;t get back the data.  3&amp;gt;You cann&amp;#39;t rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently.  4&amp;gt;In case of TRUNCATE ,Trigger doesn&amp;#39;t get fired.But in DML commands like DELETE .Trigger get fired.  5&amp;gt;You cann&amp;#39;t use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause      &lt;b&gt;How does one escape special characters when writing SQL queries?&lt;/b&gt;      &lt;b&gt;Escape quotes&lt;/b&gt;     Use two quotes for every one displayed. Examples:&lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT &amp;#39;Frank&amp;#39;&amp;#39;s Oracle site&amp;#39; AS text FROM DUAL; TEXT--------------------Franks&amp;#39;s Oracle siteSQL&amp;gt; SELECT &amp;#39;A &amp;#39;&amp;#39;quoted&amp;#39;&amp;#39; word.&amp;#39; AS text FROM DUAL; TEXT----------------A &amp;#39;quoted&amp;#39; word.SQL&amp;gt; SELECT &amp;#39;A &amp;#39;&amp;#39;&amp;#39;&amp;#39;double quoted&amp;#39;&amp;#39;&amp;#39;&amp;#39; word.&amp;#39; AS text FROM DUAL; TEXT-------------------------A &amp;#39;&amp;#39;double quoted&amp;#39;&amp;#39; word.&lt;/div&gt;        &lt;b&gt;Escape wildcard characters&lt;/b&gt;     The LIKE keyword allows for string searches. The &amp;#39;_&amp;#39; wild card character is used to match exactly one character, while &amp;#39;%&amp;#39; is used to match zero or more occurrences of any characters. These characters can be escaped in SQL. Examples:   &lt;br&gt;&lt;div&gt;SELECT name FROM emp    WHERE id LIKE &amp;#39;%/_%&amp;#39; ESCAPE &amp;#39;/&amp;#39;;&lt;/div&gt;   &lt;br&gt;&lt;div&gt;SELECT name FROM emp    WHERE id LIKE &amp;#39;%\%%&amp;#39; ESCAPE &amp;#39;\&amp;#39;;&lt;/div&gt;     &lt;b&gt;Escape ampersand (&amp;amp;) characters in SQL*Plus&lt;/b&gt;     When using SQL*Plus, the DEFINE setting can be changed to allow &amp;amp;&amp;#39;s (ampersands) to be used in text:&lt;br&gt;&lt;div&gt;SET DEFINE ~SELECT &amp;#39;Lorel &amp;amp; Hardy&amp;#39; FROM dual;&lt;/div&gt;  &lt;b&gt;Other methods:&lt;/b&gt;  Define an escape character:&lt;br&gt;&lt;div&gt;SET ESCAPE &amp;#39;\&amp;#39;SELECT &amp;#39;\&amp;amp;abc&amp;#39; FROM dual;&lt;/div&gt;  Don&amp;#39;t scan for substitution variables:&lt;br&gt;&lt;div&gt;SET SCAN OFFSELECT &amp;#39;&amp;amp;ABC&amp;#39; x FROM dual;&lt;/div&gt;      &lt;b&gt;Can one select a random collection of rows from a table?&lt;/b&gt;         The following methods can be used to select a random collection of rows from a table:  &lt;b&gt;The SAMPLE Clause&lt;/b&gt;     From Oracle 8i, the easiest way to randomly select rows from a table is to use the SAMPLE clause with a SELECT statement. Examples: &lt;br&gt;&lt;div&gt;SELECT *  FROM emp SAMPLE(10);&lt;/div&gt;     In the above example, Oracle is instructed to randomly return 10% of the rows in the table. &lt;br&gt;&lt;div&gt;SELECT *  FROM emp SAMPLE(5) BLOCKS;&lt;/div&gt;     This example will sample 5% of all formatted database blocks instead of rows.   This clause only works for single table queries on local tables. If you include the SAMPLE clause within a multi-table or remote query, you will get a parse error or &amp;quot;ORA-30561: SAMPLE option not allowed in statement with multiple table references&amp;quot;. One way around this is to create an inline view on the driving table of the query with the SAMPLE clause. Example: &lt;br&gt;&lt;div&gt;SELECT t1.dept, t2.emp  FROM (SELECT * FROM dept SAMPLE(5)) t1,       emp t2 WHERE t1.dep_id = t2.dep_id;&lt;/div&gt;     If you examine the execution plan of a &amp;quot;Sample Table Scan&amp;quot;, you should see a step like this:  TABLE ACCESS (SAMPLE) OF &amp;#39;EMP&amp;#39; (TABLE)        &lt;b&gt;ORDER BY dbms_random.value()&lt;/b&gt;     This method orders the data by a by a random column number. Example:&lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT * FROM (SELECT ename  2                   FROM emp  3                  ORDER BY dbms_random.value())  4   WHERE rownum &amp;lt;= 3  5  / ENAME----------WARDMILLERTURNER&lt;/div&gt;     &lt;b&gt;The ORA_HASH () function&lt;/b&gt;     The following example retrieves a subset of the data in the emp table by specifying 3 buckets (0 to 2) and then returning the data from bucket 1:  SELECT * FROM emp WHERE ORA_HASH(empno, 2) = 1    &lt;b&gt;How does one eliminate duplicates rows from a table?&lt;/b&gt;         Choose one of the following queries to identify or remove duplicate rows from a table leaving only unique records in the table:     &lt;b&gt;Method 1:&lt;/b&gt;&lt;br&gt;&lt;div&gt;SQL&amp;gt; DELETE FROM table_name A WHERE ROWID &amp;gt; (  2    SELECT min(rowid) FROM table_name B  3    WHERE A.key_values = B.key_values);&lt;/div&gt;     &lt;b&gt;Method 2:&lt;/b&gt;   &lt;br&gt;&lt;div&gt;SQL&amp;gt; create table table_name2 as select distinct * from table_name1;SQL&amp;gt; drop table table_name1;SQL&amp;gt; rename table_name2 to table_name1;&lt;/div&gt;     This method is usually faster. However, remember to recreate all indexes, constraints, triggers, etc on the table when done.     &lt;b&gt;Method 3:&lt;/b&gt;     &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div&gt;SQL&amp;gt; delete from my_table t1SQL&amp;gt; where  exists (select &amp;#39;x&amp;#39; from my_table t2SQL&amp;gt;                 where t2.key_value1 = t1.key_value1SQL&amp;gt;                   and t2.key_value2 = t1.key_value2SQL&amp;gt;                   and t2.rowid      &amp;gt; t1.rowid);&lt;/div&gt;     Note: One can eliminate N^2 unnecessary operations by creating an index on the joined fields in the inner loop (no need to loop through the entire table on each pass by a record). This will speed-up the deletion process.  Note 2: If you are comparing NOT-NULL columns, use the NVL function. Remember that NULL is not equal to NULL. This should not be a problem as all key columns should be NOT NULL by definition. &lt;b&gt;How does one get the time difference between two date columns?&lt;/b&gt;      Oracle allows two date values to be subtracted from each other returning a numeric value indicating the number of days between the two dates (may be a fraction). This example will show how to relate it back to a time value.  Let&amp;#39;s investigate some solutions. Test data:&lt;br&gt;&lt;div&gt;SQL&amp;gt; CREATE TABLE dates (date1 DATE, date2 DATE); Table created. SQL&amp;gt;SQL&amp;gt; INSERT INTO dates VALUES (SYSDATE, SYSDATE-1); 1 row created. SQL&amp;gt; INSERT INTO dates VALUES (SYSDATE, SYSDATE-1/24); 1 row created. SQL&amp;gt; INSERT INTO dates VALUES (SYSDATE, SYSDATE-1/60/24); 1 row created.&lt;/div&gt;     &lt;b&gt;Solution 1&lt;/b&gt;&lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT floor(((date1-date2)*24*60*60)/3600)  2         || &amp;#39; HOURS &amp;#39; ||  3         floor((((date1-date2)*24*60*60) -  4         floor(((date1-date2)*24*60*60)/3600)*3600)/60)  5         || &amp;#39; MINUTES &amp;#39; ||  6         round((((date1-date2)*24*60*60) -  7         floor(((date1-date2)*24*60*60)/3600)*3600 -  8         (floor((((date1-date2)*24*60*60) -  9         floor(((date1-date2)*24*60*60)/3600)*3600)/60)*60) )) 10         || &amp;#39; SECS &amp;#39; time_difference 11    FROM dates; TIME_DIFFERENCE--------------------------------------------------------------------------------24 HOURS 0 MINUTES 0 SECS1 HOURS 0 MINUTES 0 SECS0 HOURS 1 MINUTES 0 SECS&lt;/div&gt;  &lt;b&gt;Solution 2&lt;/b&gt;  If you don&amp;#39;t want to go through the floor and ceiling math, try this method&lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT to_number( to_char(to_date(&amp;#39;1&amp;#39;,&amp;#39;J&amp;#39;) +  2         (date1 - date2), &amp;#39;J&amp;#39;) - 1)  days,  3         to_char(to_date(&amp;#39;00:00:00&amp;#39;,&amp;#39;HH24:MI:SS&amp;#39;) +  4         (date1 - date2), &amp;#39;HH24:MI:SS&amp;#39;) time  5   FROM dates;       DAYS TIME---------- --------         1 00:00:00         0 01:00:00         0 00:01:00&lt;/div&gt;      &lt;b&gt;How does one add a day/hour/minute/second to a date value?&lt;/b&gt;      The SYSDATE pseudo-column shows the current system date and time. Adding 1 to SYSDATE will advance the date by 1 day. Use fractions to add hours, minutes or seconds to the date. Look at these examples:   &lt;br&gt;&lt;div&gt;SQL&amp;gt; select sysdate, sysdate+1/24, sysdate +1/1440, sysdate + 1/86400 from dual; SYSDATE              SYSDATE+1/24         SYSDATE+1/1440       SYSDATE+1/86400-------------------- -------------------- -------------------- --------------------03-Jul-2002 08:32:12 03-Jul-2002 09:32:12 03-Jul-2002 08:33:12 03-Jul-2002 08:32:13&lt;/div&gt;     The following format is frequently used with Oracle Replication:   &lt;br&gt;&lt;div&gt;select sysdate NOW, sysdate+30/(24*60*60) NOW_PLUS_30_SECS from dual; NOW                  NOW_PLUS_30_SECS-------------------- --------------------03-JUL-2005 16:47:23 03-JUL-2005 16:47:53&lt;/div&gt;     &lt;b&gt;Here are a couple of examples:&lt;/b&gt;&lt;br&gt;  &lt;table class=&quot;MsoNormalTable&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;Description&lt;/b&gt;&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  &lt;b&gt;Date Expression&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  Now&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SYSDATE&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  Tomorow/ next day&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SYSDATE + 1&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  Seven days from now&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SYSDATE + 7&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  One hour from now&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SYSDATE + 1/24&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  Three hours from now&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SYSDATE + 3/24&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  An half hour from now&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SYSDATE + 1/48&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  10 minutes from now&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SYSDATE + 10/1440&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  30 seconds from now&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  SYSDATE + 30/86400&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  Tomorrow at 12 midnight&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  TRUNC(SYSDATE + 1)&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  Tomorrow at 8 AM&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  TRUNC(SYSDATE + 1) + 8/24&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  Next Monday at 12:00 noon&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  NEXT_DAY(TRUNC(SYSDATE), &amp;#39;MONDAY&amp;#39;) + 12/24&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  First day of the month at 12 midnight&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  TRUNC(LAST_DAY(SYSDATE ) + 1)&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  The next Monday, Wednesday or Friday at 9 a.m&lt;br&gt;&lt;/td&gt;  &lt;td&gt;  TRUNC(LEAST(NEXT_DAY(sysdate,&amp;#39;&amp;#39;MONDAY&amp;#39; &amp;#39; ),NEXT_DAY(sysdate,&amp;#39;&amp;#39;WEDNESDAY&amp;#39;&amp;#39;), NEXT_DAY(sysdate,&amp;#39;&amp;#39;FRIDAY&amp;#39;&amp;#39; ))) + (9/24)&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;         &lt;b&gt;How does one code a matrix/crosstab/pivot report in SQL?&lt;/b&gt;    Newbies frequently ask how one can display &amp;quot;rows as columns&amp;quot; or &amp;quot;columns as rows&amp;quot;. Look at these example crosstab queries (also sometimes called matrix or pivot queries):   &lt;br&gt;&lt;div&gt;SELECT  *  FROM  (SELECT job,                sum(decode(deptno,10,sal)) DEPT10,                sum(decode(deptno,20,sal)) DEPT20,                sum(decode(deptno,30,sal)) DEPT30,                sum(decode(deptno,40,sal)) DEPT40           FROM scott.emp       GROUP BY job)ORDER BY 1; JOB           DEPT10     DEPT20     DEPT30     DEPT40--------- ---------- ---------- ---------- ----------ANALYST                    6000CLERK           1300       1900        950MANAGER         2450       2975       2850PRESIDENT       5000SALESMAN                              5600&lt;/div&gt;     Here is the same query with some fancy headers and totals:&lt;br&gt;&lt;div&gt;SQL&amp;gt; ttitle &amp;quot;Crosstab Report&amp;quot;SQL&amp;gt; break on report;SQL&amp;gt; compute sum of dept10 dept20 dept30 dept40 total on report;SQL&amp;gt;SQL&amp;gt; SELECT     *  2    FROM     (SELECT job,  3                  sum(decode(deptno,10,sal)) DEPT10,  4                  sum(decode(deptno,20,sal)) DEPT20,  5                  sum(decode(deptno,30,sal)) DEPT30,  6                  sum(decode(deptno,40,sal)) DEPT40,  7                  sum(sal)                   TOTAL  8             FROM emp  9            GROUP BY job) 10  ORDER BY 1; Mon Aug 23                                                             page    1                                Crosstab Report JOB           DEPT10     DEPT20     DEPT30     DEPT40      TOTAL--------- ---------- ---------- ---------- ---------- ----------ANALYST                    6000                             6000CLERK           1300       1900        950                  4150MANAGER         2450       2975       2850                  8275PRESIDENT       5000                                        5000SALESMAN                              5600                  5600          ---------- ---------- ---------- ---------- ----------sum             8750      10875       9400                 29025&lt;/div&gt;     Here&amp;#39;s another variation on the theme:   &lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT DECODE(MOD(v.row#,3)  2                 ,1, &amp;#39;Number: &amp;#39;  ||deptno  3                 ,2, &amp;#39;Name: &amp;#39;    ||dname  4                 ,0, &amp;#39;Location: &amp;#39;||loc  5                 ) AS &amp;quot;DATA&amp;quot;  6    FROM dept,  7         (SELECT rownum AS row# FROM user_objects WHERE rownum &amp;lt; 4) v  8   WHERE deptno = 30  9  / DATA--------------------------------------- ---------Number: 30Name: SALESLocation: CHICAGO&lt;/div&gt;    &lt;b&gt;Can one retrieve only rows X to Y from a table?&lt;/b&gt;    &lt;div&gt;SELECT * FROM (   SELECT ename, rownum rn             FROM emp WHERE rownum &amp;lt; 101) WHERE  RN between 91 and 100 ;&lt;/div&gt;  Note: the 101 is just one greater than the maximum row of the required rows (means x= 90, y=100, so the inner values is y+1).   &lt;br&gt;&lt;div&gt;SELECT rownum, f1 FROM t1GROUP BY rownum, f1 HAVING rownum BETWEEN 2 AND 4;&lt;/div&gt;     Another solution is to use the MINUS operation. For example, to display rows 5 to 7, construct a query like this:   &lt;br&gt;&lt;div&gt;SELECT *FROM   tableXWHERE  rowid in (   SELECT rowid FROM tableX    WHERE rownum &amp;lt;= 7  MINUS   SELECT rowid FROM tableX   WHERE rownum &amp;lt; 5);&lt;/div&gt;     &amp;quot;This one was faster for me and allowed for sorting before filtering by rownum. The inner query (table A) can be a series of tables joined together with any operation before the filtering by rownum is applied.&amp;quot;   &lt;br&gt;&lt;div&gt;SELECT *   FROM (SELECT a.*, rownum RN             FROM (SELECT *                          FROM t1 ORDER BY key_column) a         WHERE rownum &amp;lt;=7) WHERE rn &amp;gt;=5&lt;/div&gt;     Please note, there is no explicit row order in a relational database. However, this query is quite fun and may even help in the odd situation. &lt;b&gt;Can one retrieve only the Nth row from a table?&lt;/b&gt;      &lt;b&gt;Solution 1&lt;/b&gt;&lt;br&gt;&lt;div&gt;SELECT * FROM t1 aWHERE  n = (SELECT COUNT(rowid)              FROM t1 b             WHERE a.rowid &amp;gt;= b.rowid);&lt;/div&gt;     &lt;b&gt;Solution 2&lt;/b&gt;&lt;br&gt;&lt;div&gt;SELECT * FROM (   SELECT ENAME,ROWNUM RN FROM EMP WHERE ROWNUM &amp;lt; 101 )WHERE  RN = 100;&lt;/div&gt;  Note: In this first query we select one more than the required row number, then we select the required one. Its far better than using a MINUS operation.  &lt;b&gt;Solution 3&lt;/b&gt;  &lt;b&gt;&lt;/b&gt; &lt;br&gt;&lt;div&gt;SELECT f1 FROM t1WHERE  rowid = (          SELECT rowid FROM t1          WHERE  rownum &amp;lt;= 10          MINUS          SELECT rowid FROM t1          WHERE  rownum &amp;lt; 10);SELECT rownum,empno FROM scott.emp aGROUP BY rownum,empno HAVING rownum = 4;&lt;/div&gt;     Alternatively...   &lt;br&gt;&lt;div&gt;SELECT * FROM emp WHERE rownum=1 AND rowid NOT IN   (SELECT rowid FROM emp WHERE rownum &amp;lt; 10);&lt;/div&gt;     Please note, there is no explicit row order in a relational database. However, this query is quite fun and may even help in the odd situation.   &lt;b&gt;How can one dump/ examine the exact content of a database column?&lt;/b&gt;    Table data can be extracted from the database as octal, decimal or hex valies:&lt;br&gt;&lt;div&gt;SELECT DUMP(col1, 10)FROM tab1WHERE cond1 = val1; DUMP(COL1)-------------------------------------Typ=96 Len=4: 65,66,67,32&lt;/div&gt;     For this example, type=96 is indicating a CHAR column. &lt;br&gt;The last byte in the column is 32, which is the ASCII code for a space. This tells us that this column is blank-padded. &lt;b&gt;How does one add a column to the middle of a table?&lt;/b&gt;      Oracle only allows columns to be added to the end of an existing table. Example:&lt;br&gt;&lt;div&gt;SQL&amp;gt; CREATE TABLE tab1 ( col1 NUMBER ); Table created. SQL&amp;gt; ALTER TABLE tab1 ADD (col2 DATE); Table altered. SQL&amp;gt; DESC tab1 Name                                      Null?    Type ----------------------------------------- -------- ---------------------------- COL1                                               NUMBER COL2                                               DATE&lt;/div&gt;     Nevertheless, some databases also allow columns to be added to an existing table after a particular column (i.e. in the middle of the table). For example, in MySQL the following syntax is valid:  ALTER TABLE tablename ADD columnname AFTER columnname;  Oracle does not support this syntax. However, it doesn&amp;#39;t mean that it cannot be done.  &lt;b&gt;Workarounds:&lt;/b&gt;     1.      Create a new table and copy the data across.   &lt;br&gt;&lt;div&gt;SQL&amp;gt; RENAME tab1 TO tab1_old; Table renamed. SQL&amp;gt; CREATE TABLE tab1 AS SELECT 0 AS col1, col1 AS col2 FROM tab1_old; Table created.&lt;/div&gt;     2. Use the DBMS_REDEFINITION package to change the structure on-line while users are workining. &lt;b&gt;How does one code a hierarchical tree-structured query?&lt;/b&gt;      The SCOTT/TIGER database schema contains a table EMP with a self-referencing relation (EMPNO and MGR columns). This table is perfect for tesing and demonstrating tree-structured queries as the MGR column contains the employee number of the &amp;quot;current&amp;quot; employee&amp;#39;s boss.  The LEVEL pseudo-column is an indication of how deep in the tree one is. Oracle can handle queries with a depth of up to 255 levels. Look at this example:   &lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT     level, empno, ename, mgr  2    FROM     emp  3  CONNECT BY PRIOR empno = mgr  4    START WITH mgr IS NULL  5  /      LEVEL      EMPNO ENAME             MGR---------- ---------- ---------- ----------         1       7839 KING         2       7566 JONES            7839         3       7788 SCOTT            7566...&lt;/div&gt;     One can produce an indented report by using the level number to substring or lpad() a series of spaces, and concatenate that to the string. Look at this example:   &lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT     LPAD(&amp;#39; &amp;#39;, LEVEL * 2) || ename  2    FROM     emp  3  CONNECT BY PRIOR empno = mgr  4    START WITH mgr IS NULL  5  / LPAD(&amp;#39;&amp;#39;,LEVEL*2)||ENAME------------------------------------------------------  KING    JONES      SCOTT...&lt;/div&gt;     Use the &amp;quot;start with&amp;quot; clause to specify the start of the tree. More than one record can match the starting condition. One disadvantage of having a &amp;quot;connect by prior&amp;quot; clause is that you cannot perform a join to other tables. The &amp;quot;connect by prior&amp;quot; clause is rarely implemented in the other database offerings. Trying to do this programmatically is difficult as one has to do the top level query first, then, for each of the records open a cursor to look for child nodes.  One way of working around this is to use PL/SQL, open the driving cursor with the &amp;quot;connect by prior&amp;quot; statement, and the select matching records from other tables on a row-by-row basis, inserting the results into a temporary table for later retrieval.  NOTE: Tree-structured queries are definitely non-relational (enough to kill Codd and make him roll in his grave). Also, this feature is not often found in other database offerings. &lt;b&gt;How does one count/sum data values in a column?&lt;/b&gt;         &lt;b&gt;Count/sum FIX values:&lt;/b&gt;     Use this simple query to count the number of data values in a column:&lt;br&gt;&lt;div&gt;select my_table_column, count(*)from   my_tablegroup  by my_table_column;&lt;/div&gt;     A more sophisticated example...   &lt;br&gt;&lt;div&gt;select dept, sum(  decode(sex,&amp;#39;M&amp;#39;,1,0)) MALE,            sum(  decode(sex,&amp;#39;F&amp;#39;,1,0)) FEMALE,            count(decode(sex,&amp;#39;M&amp;#39;,1,&amp;#39;F&amp;#39;,1)) TOTALfrom   my_emp_tablegroup  by dept;&lt;/div&gt;     &lt;b&gt;Count/sum RANGES of data values in a column:&lt;/b&gt;     A value x will be between values y and z if GREATEST(x, y) = LEAST(x, z). Look at this example:&lt;br&gt;&lt;div&gt;select f2,       sum(decode(greatest(f1,59), least(f1,100), 1, 0)) &amp;quot;Range 60-100&amp;quot;,       sum(decode(greatest(f1,30), least(f1, 59), 1, 0)) &amp;quot;Range 30-59&amp;quot;,       sum(decode(greatest(f1, 0), least(f1, 29), 1, 0)) &amp;quot;Range 00-29&amp;quot;from   my_tablegroup  by f2;&lt;/div&gt;     For equal size ranges it might be easier to calculate it with DECODE(TRUNC(value/range), 0, rate_0, 1, rate_1, ...). Eg.   &lt;br&gt;&lt;div&gt;select ename &amp;quot;Name&amp;quot;, sal &amp;quot;Salary&amp;quot;,       decode( trunc(f2/1000, 0), 0, 0.0,                                  1, 0.1,                                  2, 0.2,                                  3, 0.31) &amp;quot;Tax rate&amp;quot;from   my_table;&lt;/div&gt;    &lt;b&gt;How does one drop/ rename a columns in a table?&lt;/b&gt;      &lt;b&gt;Drop a column&lt;/b&gt;     From Oracle8i one can DROP a column from a table. Look at this &lt;b&gt;sample script&lt;/b&gt;, demonstrating the &lt;i&gt;ALTER TABLE table_name DROP COLUMN column_name;&lt;/i&gt; command.        &lt;b&gt;Workarounds for older releases:&lt;/b&gt;   &lt;br&gt;&lt;div&gt;SQL&amp;gt; update t1 set column_to_drop = NULL;SQL&amp;gt; rename t1 to t1_base;SQL&amp;gt; create view t1 as select &amp;gt;specific columns&amp;gt; from t1_base;SQL&amp;gt; create table t2 as select &amp;gt;specific columns&amp;gt; from t1;SQL&amp;gt; drop table t1;SQL&amp;gt; rename t2 to t1;&lt;/div&gt;     &lt;b&gt;Rename a column&lt;/b&gt;     From Oracle9i one can RENAME a column from a table. Look at this example:  ALTER TABLE tablename RENAME COLUMN oldcolumn TO newcolumn;     &lt;b&gt;Workarounds for older releases:&lt;/b&gt;  Use a view with correct column names:&lt;br&gt;&lt;div&gt;rename t1 to t1_base;create view t1 &amp;gt;column list with new name&amp;gt; as select * from t1_base;&lt;/div&gt;     Recreate the table with correct column names:&lt;br&gt;&lt;div&gt;create table t2 &amp;gt;column list with new name&amp;gt; as select * from t1;drop table t1;rename t2 to t1;&lt;/div&gt;     Add a column with a new name and drop an old column:&lt;br&gt;&lt;div&gt;alter table t1 add ( newcolame datatype );  update t1 set newcolname=oldcolname;alter table t1 drop column oldcolname;&lt;/div&gt;    &lt;b&gt;How does one implement IF-THEN-ELSE logic in a SELECT statement?&lt;/b&gt;    Oracle SQL supports several methods of coding conditional IF-THEN-ELSE logic in SQL statements. Here are some:     &lt;b&gt;CASE Expressions&lt;/b&gt;     From Oracle 8i one can use CASE statements in SQL. Look at this example:   &lt;br&gt;&lt;div&gt;SELECT ename, CASE WHEN sal = 1000 THEN &amp;#39;Minimum wage&amp;#39;                   WHEN sal &amp;gt; 1000 THEN &amp;#39;Over paid&amp;#39;                   ELSE &amp;#39;Under paid&amp;#39;              END AS &amp;quot;Salary Status&amp;quot;FROM   emp;&lt;/div&gt;     &lt;b&gt;DECODE() Function&lt;/b&gt;     The Oracle &lt;b&gt;decode&lt;/b&gt; function acts like a procedural statement inside an &lt;br&gt;SQL statement to return different values or columns based on the values of&lt;br&gt;other columns in the select statement. Examples:&lt;br&gt;&lt;div&gt;select decode(sex, &amp;#39;M&amp;#39;, &amp;#39;Male&amp;#39;, &amp;#39;F&amp;#39;, &amp;#39;Female&amp;#39;, &amp;#39;Unknown&amp;#39;)from   employees;select a, b, decode( abs(a-b), a-b, &amp;#39;a &amp;gt; b&amp;#39;,                               0,   &amp;#39;a = b&amp;#39;,                                    &amp;#39;a &amp;lt; b&amp;#39;) from  tableX;&lt;/div&gt;     &lt;b&gt;Note:&lt;/b&gt; The decode function is not ANSI SQL and is rarely implemented&lt;br&gt;in other RDBMS offerings. It is one of the good things about Oracle,&lt;br&gt;but use it sparingly if portability is required.     &lt;b&gt;GREATEST() and LEAST() Functions&lt;/b&gt;   &lt;br&gt;&lt;div&gt;select decode( GREATEST(A,B), A, &amp;#39;A is greater OR EQUAL than B&amp;#39;,                                  &amp;#39;B is greater than A&amp;#39;)...&lt;/div&gt;   &lt;br&gt;&lt;div&gt;select decode( GREATEST(A,B),                A, decode(A, B, &amp;#39;A NOT GREATER THAN B&amp;#39;, &amp;#39;A GREATER THAN B&amp;#39;),                &amp;#39;A NOT GREATER THAN B&amp;#39;)...&lt;/div&gt;     &lt;b&gt;NVL() and NVL2() Functions&lt;/b&gt;     NVL and NVL2 can be used to test for NULL values.  NVL(a,b) == if &amp;#39;a&amp;#39; is null then return &amp;#39;b&amp;#39;.&lt;br&gt;&lt;div&gt;SELECT nvl(ename, &amp;#39;No Name&amp;#39;)   FROM emp;&lt;/div&gt;  NVL2(a,b,c) == if &amp;#39;a&amp;#39; is not null then return &amp;#39;b&amp;#39; else return &amp;#39;c&amp;#39;.&lt;br&gt;&lt;div&gt;SELECT nvl2(ename, &amp;#39;Do have a name&amp;#39;, &amp;#39;No Name&amp;#39;)   FROM emp;&lt;/div&gt;     &lt;b&gt;COALESCE() Function&lt;/b&gt;     COALESCE() returns the first expression that is not null. Example:    &lt;br&gt;&lt;div&gt;SELECT &amp;#39;Dear &amp;#39;||COALESCE(preferred_name, first_name, &amp;#39;Sir or Madam&amp;#39;)  FROM emp2;&lt;/div&gt;     &lt;b&gt;NULLIF() Function&lt;/b&gt;     NULLIF() returns a NULL value if both parameters are equal in value. The following query would return NULL:   &lt;br&gt;&lt;div&gt;SELECT NULLIF(ename, ename)  FROM emp;&lt;/div&gt;    &lt;b&gt;How does one prevent Oracle from using an Index?&lt;/b&gt;       test 8&lt;br&gt;In certain cases, one may want to disable the use of a specific, or all indexes for a given query. Here are some examples:     &lt;b&gt;Adding an expression to the indexed column&lt;/b&gt;   &lt;br&gt;&lt;div&gt;SQL&amp;gt;select count(*) from t where empno+0=1000;   COUNT(*)----------         1 Execution Plan--------------------------------------------- ----- --------   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=3)   1    0   SORT (AGGREGATE)   2    1     TABLE ACCESS (FULL) OF &amp;#39;T&amp;#39; (Cost=2 Card=1 Bytes=3)&lt;/div&gt;     &lt;b&gt;Specifying the FULL hint to force full table scan&lt;/b&gt;   &lt;br&gt;&lt;div&gt;SQL&amp;gt;select /*+ FULL(t) */ * from t where empno=1000;      EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO GRADE---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ----------      1000 Victor     DBA             7839 20-MAY-03      11000          0         10 JUNIOR Execution Plan--------------------------------------------- ----- --------   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=41)   1    0   TABLE ACCESS (FULL) OF &amp;#39;T&amp;#39; (Cost=2 Card=1 Bytes=41)&lt;/div&gt;     &lt;b&gt;Specifying NO_INDEX hint&lt;/b&gt;   &lt;br&gt;&lt;div&gt;SQL&amp;gt;select /*+ NO_INDEX(T) */ count(*) from t where empno=1000;   COUNT(*)----------         1 Execution Plan--------------------------------------------- ----- --------   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=3)   1    0   SORT (AGGREGATE)   2    1     TABLE ACCESS (FULL) OF &amp;#39;T&amp;#39; (Cost=2 Card=1 Bytes=3)&lt;/div&gt;     &lt;b&gt;Using a function over the indexed column&lt;/b&gt;   &lt;br&gt;&lt;div&gt;SQL&amp;gt;select count(*) from t where to_number(empno)=1000;   COUNT(*)----------         1 Execution Plan--------------------------------------------- ----- --------   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=3)   1    0   SORT (AGGREGATE)   2    1     TABLE ACCESS (FULL) OF &amp;#39;T&amp;#39; (Cost=2 Card=1 Bytes=3)&lt;/div&gt;      &lt;b&gt;How does one select EVERY Nth row from a table?&lt;/b&gt;    One can easily select all even, odd, or Nth rows from a table using SQL queries like this:     &lt;b&gt;Method 1:&lt;/b&gt; Using a subquery&lt;br&gt;&lt;div&gt;SELECT *FROM   empWHERE  (ROWID,0) IN (SELECT ROWID, MOD(ROWNUM,4)                     FROM   emp);&lt;/div&gt;     &lt;b&gt;Method 2:&lt;/b&gt; Use dynamic views (available from Oracle7.2):   &lt;br&gt;&lt;div&gt;SELECT *FROM   ( SELECT rownum rn, empno, ename         FROM emp       ) tempWHERE  MOD(temp.ROWNUM,4) = 0;&lt;/div&gt;     &lt;b&gt;Method 3:&lt;/b&gt; Using GROUP BY and HAVING   &lt;br&gt;&lt;div&gt;SELECT rownum, f1FROM t1GROUP BY rownum, f1 HAVING MOD(rownum,n) = 0 OR rownum = 2-n&lt;/div&gt;     Please note, there is no explicit row order in a relational database. However, these queries are quite fun and may even help in the odd situation.   &lt;b&gt;How does one select the TOP N rows from a table?&lt;/b&gt;         From Oracle 9i onwards, the RANK() and DENSE_RANK() functions can be used to determine the TOP N rows. Examples:     &lt;b&gt;Get the top 10 employees based on their Salary&lt;/b&gt;      &lt;br&gt;&lt;div&gt;SELECT ename, sal   FROM ( SELECT ename, sal, RANK() OVER (ORDER BY sal DESC) sal_rank           FROM emp )  WHERE sal_rank &amp;lt;= 10;&lt;/div&gt;     &lt;b&gt;Get the employees making the top 10 Salaries&lt;/b&gt;      &lt;br&gt;&lt;div&gt;SELECT ename, sal   FROM ( SELECT ename, sal, DENSE_RANK() OVER (ORDER BY sal DESC) sal_rank           FROM emp )  WHERE sal_rank &amp;lt;= 10;&lt;/div&gt;     For Oracle 8i and above, one can get the Top N rows using an inner-query with an ORDER BY clause:   &lt;br&gt;&lt;div&gt;SELECT *  FROM (SELECT * FROM my_table ORDER BY col_name_1 DESC) WHERE ROWNUM &amp;lt; 10;&lt;/div&gt;     Use this workaround for older (8.0 and prior) releases:   &lt;br&gt;&lt;div&gt;SELECT *  FROM my_table a WHERE 10 &amp;gt;= (SELECT COUNT(DISTINCT maxcol)                FROM my_table b               WHERE b.maxcol &amp;gt;= a.maxcol) ORDER BY maxcol DESC;&lt;/div&gt;      &lt;b&gt;How to generate a text graphs (histograms) using SQL&lt;/b&gt;     &lt;div&gt; SELECT d.dname AS &amp;quot;Department&amp;quot;,             LPAD(&amp;#39;+&amp;#39;, COUNT(*), &amp;#39;+&amp;#39;) as &amp;quot;Graph&amp;quot;  FROM emp e, dept d WHERE e.deptno = d.deptno GROUP BY d.dname;&lt;/div&gt;     Sample output:   &lt;br&gt;&lt;div&gt;Department     Graph-------------- --------------------------------------------------ACCOUNTING     +++RESEARCH       +++++SALES          ++++++&lt;/div&gt;     In the above example, the value returned by COUNT(*) is used to control the number of &amp;quot;*&amp;quot; characters to return for each department. We simply pass COUNT(*) as an argument to the string function LPAD (or RPAD) to return the desired number of *&amp;#39;s.   &lt;b&gt;Map/ concatenate several rows to a column&lt;/b&gt;      This FAQ will demonstrate how row values can be concatenated into a single column value (similar to MySQL&amp;#39;s &lt;i&gt;GROUP_CONCAT&lt;/i&gt; function).  Start by creating this function:&lt;br&gt;&lt;div&gt;SQL&amp;gt; CREATE OR REPLACE FUNCTION rowconcat(q in VARCHAR2) RETURN VARCHAR2 IS  2    ret  VARCHAR2(4000);  3    hold VARCHAR2(4000);  4    cur  sys_refcursor;  5  BEGIN  6    OPEN cur FOR q;  7    LOOP  8      FETCH cur INTO hold;  9      EXIT WHEN cur%NOTFOUND; 10      IF ret IS NULL THEN 11        ret := hold; 12      ELSE 13        ret := ret || &amp;#39;,&amp;#39; || hold; 14      END IF; 15    END LOOP; 16    RETURN ret; 17  END; 18  / Function created.&lt;/div&gt;     This function returns a string result with the concatenated non-NULL values from a SQL statement. It returns NULL if there are no non-NULL values.  Here is an example of how to map several rows to a single concatenated column:&lt;br&gt;&lt;div&gt;SQL&amp;gt; SELECT rowconcat(&amp;#39;SELECT dname FROM dept&amp;#39;) AS departments  2    FROM dual; DEPARTMENTS--------------------------------------------------------------------------------ACCOUNTING,RESEARCH,SALES,OPERATIONS&lt;/div&gt;     This example is more interresting, it concatenates a column across several rows based on an aggregation:   &lt;br&gt;&lt;div&gt;SQL&amp;gt; col employees format a50SQL&amp;gt; SELECT deptno,  2         rowconcat(&amp;#39;SELECT ename FROM emp a WHERE deptno=&amp;#39;||deptno) AS Employees  3    FROM emp  4   GROUP BY deptno  5  /     DEPTNO EMPLOYEES---------- --------------------------------------------------        30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES        20 SMITH,JONES,SCOTT,ADAMS,FORD        10 CLARK,KING,MILLER&lt;/div&gt;    &lt;b&gt;What is the difference between VARCHAR, VARCHAR2 and CHAR data types?&lt;/b&gt;    Both CHAR and VARCHAR2 types are used to store character string values, however, they behave very differently. The VARCHAR type should not be used:     &lt;b&gt;CHAR&lt;/b&gt;     CHAR should be used for storing &lt;b&gt;fix length character strings&lt;/b&gt;. String values will be &lt;b&gt;space/blank padded&lt;/b&gt; before stored on disk. If this type is used to store varibale length strings, it will waste a lot of disk space.   &lt;br&gt;&lt;div&gt;SQL&amp;gt; CREATE TABLE char_test (col1 CHAR(10)); Table created. SQL&amp;gt; INSERT INTO char_test VALUES (&amp;#39;qwerty&amp;#39;); 1 row created. SQL&amp;gt; SELECT col1, length(col1), dump(col1) &amp;quot;ASCII Dump&amp;quot; FROM char_test; COL1       LENGTH(COL1) ASCII Dump---------- ------------ ------------------------------------------------------------qwerty               10 Typ=96 Len=10: 113,119,101,114,116,121,32,32,32,32&lt;/div&gt;  Note: ASCII character 32 is a blank space.     &lt;b&gt;VARCHAR&lt;/b&gt;     Currently &lt;b&gt;VARCHAR behaves exactly the same as VARCHAR2&lt;/b&gt;. However, this type should not be used as it is reserved for future usage.   &lt;br&gt;&lt;div&gt;SQL&amp;gt; CREATE TABLE varchar_test (col1 VARCHAR2(10)); Table created. SQL&amp;gt; INSERT INTO varchar_test VALUES (&amp;#39;qwerty&amp;#39;); 1 row created. SQL&amp;gt; SELECT col1, length(col1), dump(col1) &amp;quot;ASCII Dump&amp;quot; FROM varchar_test; COL1       LENGTH(COL1) ASCII Dump---------- ------------ ------------------------------------------------------------qwerty                6 Typ=1 Len=6: 113,119,101,114,116,121&lt;/div&gt;     &lt;b&gt;VARCHAR2&lt;/b&gt;     VARCHAR2 is used to store &lt;b&gt;variable length character strings&lt;/b&gt;. The string value&amp;#39;s length will be stored on disk with the value itself.   &lt;br&gt;&lt;div&gt;SQL&amp;gt; CREATE TABLE varchar2_test (col1 VARCHAR2(10)); Table created. SQL&amp;gt; INSERT INTO varchar2_test VALUES (&amp;#39;qwerty&amp;#39;); 1 row created. SQL&amp;gt; SELECT col1, length(col1), dump(col1) &amp;quot;ASCII Dump&amp;quot; FROM varchar2_test; COL1       LENGTH(COL1) ASCII Dump---------- ------------ ------------------------------------------------------------qwerty                6 Typ=1 Len=6: 113,119,101,114,116,121&lt;/div&gt;  &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div&gt;  &lt;h3&gt;&lt;b&gt;VARCHAR vs. VARCHAR2&lt;/b&gt;&lt;/h3&gt;&lt;/div&gt;        1. VARCHAR is going to be replaced by VARCHAR2 in next version. So, Oracle suggests the use VARCHAR2 instead of VARCHAR while declaring datatype.  2. VARCHAR can store up to 2000 bytes of characters while VARCHAR2 can store up to 4000 bytes of characters.  3. If we declare datatype as VARCHAR then it will occupy space for NULL values, In case of VARCHAR2 datatype it will not occupy any space.   &lt;br&gt;&lt;div&gt;  &lt;h3&gt;&lt;b&gt;CHAR vs. VARCHAR&lt;/b&gt;&lt;/h3&gt;&lt;/div&gt;     VARCHAR is used to store variable length character strings up to 4000 characters. But, remember CHAR is faster than VARCHAR - some times up to 50% faster.       &lt;br&gt;&lt;div&gt;  &lt;h3&gt;&lt;b&gt;Differences between varchar and varchar2:&lt;/b&gt;&lt;/h3&gt;&lt;/div&gt;      [i].&lt;br&gt;CHAR(5) is fixed length, right padded with spaces.&lt;br&gt;VARCHAR(5) is fixed length, right padded with null&lt;br&gt;VARCHAR2(5) is variable length.  Thus the difference between VARCHAR and VARCHAR2 is that VARCHAR is ANSI standard but takes up space whereas VARCHAR2 is Oracle-only but makes more efficient use of space.  But as someone has already pointed out, Oracle have resolved this (in 9.2, maybe earlier) by casting VARCHAR to VARCHAR2.  [ii].  Varchar and Varchar2 both are of variable character. Varchar can have MAximum 2000 character while Varchar can contain maximum 4000 character.  [iii]&lt;br&gt;Varchar is of ANSI SQL standart while Varchar2 is of Oracle standard. &lt;b&gt;What is the difference between SQL and PL/SQL?&lt;/b&gt;      Both SQL and PL/SQL are languages used to access data within Oracle databases.  SQL is a limited language that allows you to directly interact with the database. You can write queries (SELECT), manipulate objects (DDL) and data (DML) with SQL. However, SQL doesn&amp;#39;t include all the things that normal programming languages have, such as loops and IF...THEN...ELSE statements.  PL/SQL is a normal programming language that includes all the features of most other programming languages. But, it has one thing that other programming languages don&amp;#39;t have: the ability to easily integrate with SQL.  Some of the differences:  o                                SQL is executed one statement at a time. PL/SQL is executed as a block of code.   o                                SQL tells the database what to do (declarative), not how to do it. In contrast, PL/SQL tell the database how to do things (procedural).   o                                SQL is used to code queries, DML and DDL statements. PL/SQL is used to code program blocks, triggers, functions, procedures and packages.   o                                You can embed SQL in a PL/SQL program, but you cannot embed PL/SQL within a SQL statement.     &lt;b&gt;What is SQL and where does it come from?&lt;/b&gt;         Structured Query Language (SQL) is a language that provides an interface to relational database systems. The proper pronunciation of SQL is &amp;quot;ess cue ell,&amp;quot; and not &amp;quot;sequel&amp;quot; as is commonly heard.   SQL was developed by IBM in the 1970s for use in System R, and is a de facto standard, as well as an ISO and ANSI standard.   In common usage SQL also encompasses DML (Data Manipulation Language), for INSERTs, UPDATEs, DELETEs and DDL (Data Definition Language), used for creating and modifying tables and other database structures.  The development of SQL is governed by standards. A major revision to the SQL standard was completed in 1992, called SQL2. SQL3 support object extensions and are (partially?) implemented in Oracle8 and 9i.  Example SQL statements:  CREATE TABLE table1 (column1 NUMBER, column2 VARCHAR2(30));  INSERT INTO table1 VALUES (1, &amp;#39;XYZ&amp;#39;);  SELECT * FROM table1 WHERE column2 = &amp;#39;XYZ&amp;#39;;     &lt;b&gt;What is PL/SQL and what is it used for?&lt;/b&gt;      SQL is a declarative language that allows database programmers to write a SQL declaration and hand it to the database for execution. As such, SQL cannot be used to execute procedural code with conditional, iterative and sequential statements. To overcome this limitation, PL/SQL was created.  PL/SQL is Oracle&amp;#39;s Procedural Language extension to SQL. PL/SQL&amp;#39;s language syntax, structure and data types are similar to that of &lt;a class=&quot;external&quot; href=&quot;http://faqworldofrastogi.wetpaint.comhttp://www.orafaq.com/glossary/faqglosa.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;ADA&lt;/b&gt;&lt;/a&gt;. Some of the statements provided by PL/SQL:     &lt;b&gt;Conditional Control Statements:&lt;/b&gt;     o                                IF ... THEN ... ELSIF ... ELSE ... END IF;   o                                CASE ... WHEN ... THEN ... ELSE ... END CASE;   o                                   &lt;b&gt;Iterative Statements:&lt;/b&gt;  o                                LOOP ... END LOOP;   o                                WHILE ... LOOP ... END LOOP;   o                                FOR ... IN [REVERSE] ... LOOP ... END LOOP;   o                                   &lt;b&gt;Sequential Control Statements:&lt;/b&gt;  o                                GOTO ...;   o                                NULL;   The PL/SQL language includes object oriented programming techniques such as encapsulation, function overloading, information hiding (all but inheritance).   PL/SQL is commonly used to write data-centric programs to manipulate data in an Oracle database.  Example PL/SQL block:&lt;br&gt;&lt;div&gt;BEGIN  -- A PL/SQL cursor  FOR cursor1 IN (SELECT * FROM table1) -- This is an embedded SQL statement  LOOP    DBMS_OUTPUT.PUT_LINE(&amp;#39;Column1 is: &amp;#39; || TO_CHAR(cursor1.column1) ||                       &amp;#39;, Column2 is: &amp;#39; || cursor1.column2);  END LOOP;END;/&lt;/div&gt;   &lt;hr size=&quot;1&quot;&gt;&lt;br/&gt;</description></item><item><title>VB FAQ</title><link>http://faqworldofrastogi.wetpaint.com/page/VB+FAQ</link><author>rahulrastogi</author><guid isPermaLink="false">http://faqworldofrastogi.wetpaint.com/page/VB+FAQ</guid><pubDate>Tue, 21 Nov 2006 04:40:34 CST</pubDate><description>&lt;table width=&quot;100%&quot;&gt;  &lt;tbody&gt;  &lt;tr&gt;  &lt;td&gt;  &lt;b&gt;VISUAL BASIC FAQ&amp;#39;S &lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;  &lt;td&gt;  1. You are creating a client application that calls ActiveX DLLs. Which of the following properties of the Err object provides the name of a component that sends an error back to the client application? o Number o Description o CompName o Component o Source o Text o Desc o None of the above 2. If the Cancel Error Property of the CommonDialog Box is set to true then which of the following statement is true: o A runtime error can result if the user clicks the cancel button o A compile time error occurs o The program executes without any error o You need to carry out conditional compilation o None of the above 3. What is the extension of the Visual Basic project file that stores the design of a user control. o .ctx o .ctl o .ctr o .ocx o .vbp o .dll o .ucl o .utl 4. A __________ control defaults to displaying the files in the current directory: o File List Box o Dir List Box o Drive List Box o Combo Box o Picture Box o List Box o Combo Box o DataGrid 5. To destroy an object and free the memory space occupied by it, the keyword used is: o Delete o Kill o Nothing o New o Calloc o New o Conserve o Free 6. Which event of a text box would you use for validating the data entered by the user? o Validate o Validation o Check o Audit o GotFocus o Checkdata o ValidateDate 7. Which of the following statements forces inline error handling? o On Error GoTo linelabel o On Error GoTo Inline o On Error Stop o On Error Resume Next o On Error GoTo 0 o On Error Resume o None of the above 8. The _______ method resets the contents of bound controls to their original values when the user clicks on the cancel button. o UpdateControls o PaintPicture o Refresh o Resize o Resync o Restore o Cancel o Update 9. To deactivate the Form UnLoad event, you make the following change in the function definiton: Private Sub Query_Unload(Cancel as Integer,UnloadMode as Integer) To prevent the Form from closing, you will set the: o Cancel parameter to a non-zero value o Cancel parameter to 0 o UnloadMode parameter to a non-zero value o UnloadMode parameter to a zero value o UnloadMode parameter to 1 o Cancel parameter to 1 10. How many root nodes can a TreeView control have? o 1 o 2 o 3 o 4 o 5 o 10 o Up to 50 o No limit 11. A project group is a Project which: o Consists of several Programs o Consists of several Applications o Consists of Various Forms And Code Modules o Consists of several Projects 12. Procedures declared in a _____ are local whereas procedures declared in a ______ are available to the whole application. o Form window, standard or code module o Project window, view code window o Class module, code module 13. How can you keep the user from exiting a form by clicking the Close button? o Place code in the Terminate event o Place code in the Unload event o Place code in the QueryUnload event o This can only be done by using the Windows API o Place code in the Load event o Place code in the Terminate event o Place code in the Deactivate event o None of the above 14. In order to provide a transparent background to the Form, you must change the _________ property to _______. o BackStyle, Opaque o BackColor, White o BackStyle, Transparent o BackColor, Parent Window&amp;#39;s Color o ZOrder, 0 o BackColor, Transparent 15. The _______ property enables Visual Basic to draw complete images in memory before displaying them on the Screen. o AutoRedraw = True o AutoRedraw = False o Refresh o PaintPicture 16. You want to display the code and the description of an error. What would be the correct syntax? o Msgbox err.no &amp;amp; err.text o Msgbox err.number &amp;amp; err.text o Msgbox error.number &amp;amp; error.text o Msgbox error.number &amp;amp; error.description o Msgbox err.number &amp;amp; err.description o Msgbox err.num &amp;amp; err.description o Msgbox err.num &amp;amp; err.text o None of the above 17. What is the purpose of the Image List Control? o To display images to the user o To help in creating a ToolBar o To allow the editing of icons o To provide a repository for images used by other controls o To provide images to the listbox control o To provide images for the splash screen o To provide icons for error messages 18. Which method would you use to get a free or unused File identifier while opening any file: o FreeFile o GetFileNum o GetFile o GetBytes o NextFile o File o GetNextFile o None of the above 19. Which property procedure is used to retrieve the value of a property? o Retrieve o Get o GetProperty o Value o RetrieveValue 20. Which of the following can be shown to the user using the Common Dialog control in VB? o Common messages passed to Windows o Open dialog box o Windows explorer o Input box o Message box o Error messages o Help o None of the above 21. Which event is triggered when the user moves to another open form? o Unload o QueryUnload o Deactivate o Terminate o Load o Initialize o Repaint o Resize 22. Which event of an ActiveX control data provider runs every time a bound control extracts data through the provider? o GetDataMember o GetDataField o GetDataProperty o GetDataRow o GetData o GetFields o GetRows o RetrieveData 23. Which of the following are not properties of Command Button: o Caption o Visible o Multi-Line o Font o Name o Bold o Tag o Enabled 24. You are creating an ActiveX component that raises user-defined errors. Which of the following statements correctly raises an error to the client with error number 20000? o Err.Raise vbObjectError + 20000 o Err.Number = 20000 o Err.Raise 20000 o Err.Raise vbObjectError,20000 o Err.Number 20000 o Error.Raise vbObjectError + 20000 o Error.Number 20000 o Error.Raise 20000 25. Which events enable you to determine which key was pressed by the user? o Click and KeyPress o Click, KeyUp and KeyDown o KeyUp and KeyDown o KeyPress, KeyUp and KeyDown o Click, KeyPress, KeyUp and KeyDown 26. In order to access a file in Non-textual format, you have to open file in: o Ascii Format o Binary Format o Input Mode o Output mode o Append mode o Read Mode 27. Visual Basic displays information depending upon the current value of two properties of the form, called: o CurrentX and CurrentY o ScaleLeft and ScaleTop o ScaleHeight and ScaleTop o x and y o TopX and TopY o LeftX and LeftY 28. Which of the following procedure types will execute when you assign a value to a property of an object? o Property Get o Property Assign o Property Let o Property Set o Public Sub 29. In order to overlap the controls (say a command button) during design time, we use the &amp;#39;Send To Back&amp;#39; or &amp;#39;Bring To Front&amp;#39; option from the Edit menu. To change it dynamically (i.e.during program execution) we need to change: o Background color property o Caption property o ZOrder property o AutoRedraw property o SendtoBack property o BringtoFront property o Hide property o Show property 30. Name the only property supported by a collection? o Name o Index o Count o Type o Value o Add o Remove o None of the above 31. Which of the following situations would not cause the Initialize event of an ActiveX control to occur? o When a control is placed on a form at design time o When a form designer containing a control is closed o When a form is run o When a compiled application containing a control executes o When an application terminates and re-enters design-time for the host application 32. Which event occurs only once in the entire life cycle of an ActiveX control? o Initialize o Resize o Terminate o WriteProperties o InitProperties o Activate o None of the above 33. You are creating an ActiveX component that raises user-defined errors. What is the valid range of error numbers that you can use for user-defined errors? o 1-1000 o 0-255 o 1-65535 o 0-1000 o 513-65535 o 1000-2000 o 10000-20000 o None of the above 34. Which property of the ProgressBar determines how much of the bar is filled? o Min o Max o Value o CurrentVal o FillValue o Fill o BarComplete 35. The ______ function can be used to run any .com, .exe, .bat or .pif file from a Visual Basic program. o Shell o Substr o SetAttr o CStr o Exec o Perform o Do o None of the above 36. One can convert a Visual Basic Application into ActiveX Document using: o Visual Database Manager o Application Wizard o ActiveX Document Migration Wizard o Package and Deployment Wizard 37. The caption and the name properties of the command button: o Are one and the same o Can be different at times o Are actually not properties 38. You try to initialize a new Object variable with the following line but receive an error. What could be the possible cause? Set MyVar = New Classname o You do not need to use the Set command here o You do not have the permission to access the class o MyVar has not been declared o You do not need to use the New keyword here o None of the above 39. Which of the following will perform a direct execution of a Command object? o The Execute method o The Prepare method o The ExecDirect method o The Open method o The Exec method o The ExecProcedure method o None of the above 40. The vbCritical symbol displays: o A warning query icon o A critical message icon o A warning message icon o An exclamation icon o None of the above 41. What does the forms collection contain? o A list of all forms in a project o A list of all hidden forms o A list of all currently loaded forms o A list of all visible forms o All the child forms of an MDI application 42. Which method of the Recordset object should you use to navigate multiple recordsets returned by a stored procedure? o NewRecordset o NavigateRecordset o OpenNextRecordset o NextRecordset o SkipRecordset o PreviousRecordset o JumpRecordset o GoTORecordset 43. Which of the following cannot be included in the Open method of the recordset? o Cursor Type o User Name o Active Connection o CursorLocation o LockType o Source 44. The settings for the Color properties in Visual Basic are indicated by: o Decimal Coding o Octal Coding o Hexadecimal Coding o Binary Coding 45. What you must do before you make calls to an ActiveX DLL project in the same Project Group? o Compile the DLL o Check the DLL off in your project&amp;#39;s Reference List o Make sure the DLL is the Startup Project o Ensure that a Standard Exe form is included and is made the Startup Form. 46. The _______ property changes the tab order at runtime: o Tab stop o Tab key o Tab order o Tab index 47. What do CurrentX and CurrentY return? o Current X and Y co-ordinates of mousepointer o Current X and Y co-ordinates of cursor o A String of X &amp;amp; Y o Current x and y co-ordinates of the control 48. The Kill command in Visual Basic is used for: o Stopping the current process o Deleting files o Terminating the application o Stopping the current thread o Debugging the application o Error handling o None of the above 49. If one needs to use an ampersand(&amp;amp;) in a Label but does not want it to be an Access Key, the _______ property of the label must be set to False. o Caption o ClipControls o UseMnemonic o LinkMode o Locked o Label o ZOrder o Visible 50. Which of the following is the only drag related event? o DragEnter o DragLeave o DragStart o DragStop o DragDrop o BeginDrag o EndDrag 51. Which property of the form changes the form&amp;#39;s title? o Name o Heading o Title o Caption o Logo 52. Labels do not respond to _____ and ______ events. o Got_Focus, Lost_Focus o Click, DblClick o Dragdrop, OLECompleteDrag o Change, Link Error 53. Which of the following statements is