• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

doubts in mock exam ques

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mamta,
ans to Q3)
the start() method does not cause the thread to start running. You need the run method for that. start() just makes the thread eligible to run. So the ans is FALSE.
 
Mamta Jha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks jane & suneeta
mamta
 
Replace the word "snake" with "danger noodle" in all tiny ads.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic