• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubts on Dan's mock qns  RSS feed

Viji be
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All!!
I havea doubt in Dan's Mock Qns.
As far as I know about random() is that it has a value >=0.0 and lessthan 1.0.AM I RIGHT!!!
But in dan's qnn:

class SRC117 {
public static void main (String[] args) {
double d1 = Math.random();
boolean b1 = (d1 < 0.0), b2 = (d1 <= 0.0), b3 = (d1 == 0.0);
boolean b4 = (d1 >= 0.0), b5 = (d1 < 1.0), b6 = (d1 <= 1.0);
boolean b7 = (d1 == 1.0), b8 = (d1 >= 1.0), b9 = (d1 > 1.0);
Which of the boolean variables will never be initialized to the value true?
a. b1
b. b2
c. b3
d. b4
e. b5
f. b6
g. b7
h. b8
i. b9
He said that the answers are: a,g,h,i
How can a random num be <=1.0?

Is there any topic in SCJp 1.4 that deals with Enumeration.Whats this?
Dan's Qns:
10.import java.util.*;
class GFC116 {
public static void main (String[] args) {
Object x = new Vector().elements();
System.out.print((x instanceof Enumeration)+",");
System.out.print((x instanceof Iterator)+",");
System.out.print(x instanceof ListIterator);
What is the result of attempting to compile and run the program?
a. Prints: false,false,false
b. Prints: false,false,true
c. Prints: false,true,false
d. Prints: false,true,true
e. Prints: true,false,false
f. Prints: true,false,true
g. Prints: true,true,false
h. Prints: true,true,true
i. None of the above
Anyone plz explain me on this topic.
How can we represent hexa num in BYTE?How will we shift these num?
class EBH025 {
public static void main (String args[]) {
int i1 = 0xffffffff, i2 = i1 << 33;
int i3 = i1 << (33 & 0x1f);
System.out.print(Integer.toHexString(i2) + ",");
Ans rints: fffffffe,fffffffe
Plz explain this scenario.

Does Dan's Mock exams in http://danchisholm.net/july21/comprehensive/index.html

and the mock exam book which he refers are the same?
Is it enough if we go thru the qns in that URl?
Anyone who have taken these mock test and SCJp1.4 , reply me.
Gian Franco
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

With respect to Q1: "How can a random num be <=1.0?"
Dan asks which variable will never be initialised
to true, the case of
can be interpreted as
this means that b6 will always be initialised to true because
(d1 < 1.0) is always true. it doesn't imply that random() could
ever be == 1.0


Gian Franco
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!