This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
hi friends, These are some of the quest from a mock exam- Q1. Which of the following are true about the class defined inside an interface 1> it is not possible in the java Laungage. //ans 2> The class is always public. 3> The class is always static. 4> the class methods cannot call the methods declared in the interface. 5> the class methods can call only the static methods declared in the interface. my ans is 2. Q2.What does the following expression return Math.max(Float.POSITIVE_INFINITY,Double.POSITIVE_INFINITY); 1>Float.POSITIVE_INFINITY 2>Double.POSITIVE_INFINITY //ans 3>runtime Exception when I tried this using a code , the answer comes id infinity.Does Double.POSITIVE_INFINITY and infinity mean the same. Q3.Assume that th is an instance holding a thread object. th.start() causes the thread to start running and eventually complete its execution. The object reference by th is not accessable any more and is garbage collected when the garbage collecter runs. True False //ans Shouldn't the thread object get gced after completion of run? so the ans should be true. Q4. can we explicitly call the constructor of an abstract class? I'll be thankful if anyone could give the correct explanation for these. Mamta
Hi Mamta, Q1. 1 - TRUE. An Interface can contain constants and empty method declarations but NOT classes. Classes and Interfaces are both types in Java. (see JLS�.4.3) Correction: Sorry Mamta. Just discovered that you CAN declare classes within an interface. Any classes nested inside an interface are Static and Public.
Q2. The value does print as just Infinity. When I ran a test using the following code both if statements printed.
So I don't think, for practical purposes, the two values are different. The JSK defines them as
Q3. Think the answer is FALSE. The Java Programming Language states "when a thread dies, its object doesn't go away" which I interpret to mean just because a thread ends does not mean the object is available for gc. Q4. Think the answer to this is Yes. An abstract class cannot be instantiated BUT a subclass of an abstract can use super() to call an abstract class ctor.
Hope that helps. ------------------ Jane [This message has been edited by Jane Griscti (edited October 21, 2000).] [This message has been edited by Jane Griscti (edited October 21, 2000).] [This message has been edited by Jane Griscti (edited October 21, 2000).]