• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

'JvalTest' Java2 Certification Mock Exam Applet

 
sasank manohar
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This below question is from the website
http://valiveru.tripod.com/java/jvaltest.html
Question 49.
Which of the following java classes are immutable??

A.java.lang.Math
B.java.util.String
C.java.util.StringBuffer
D.java.lang.Boolean
E.java.lang.Object

Answer is B and D
My question is Why A is not correct.I thought Math class is also immutable.
One more question

Question 52.
If you want to create java GUI application using AWT, you constructed a frame calling
Frame f = new Frame();
What methods you need to call on the Frame f to make it visible.

A.f.setVisible(true);
B.f.setSize(true);
C.Both A & B
D.There is no need to call any methods on f explicitly to
make it visible.
Answer is c
I think setSize takes two parameters with width and height, here they have given boolean value parameter .
Can anyone please help with this.

[This message has been edited by sdev (edited July 18, 2000).]
[This message has been edited by sdev (edited July 18, 2000).]
[This message has been edited by sdev (edited July 18, 2000).]
[This message has been edited by sdev (edited July 18, 2000).]
 
sasank manohar
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any takers please............
 
Khalid Bou-Rabee
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right on both accounts. Math is immutable because it is final, and setSize takes two int's as parameters.
Mock exams are never 100% correct.
Regards,
Khalid
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding the first question, if it means to ask which classes create immutable objects, then I'd have to say that the Math class doesn't fall into this category. You can't instantiate Math objects. I find that question to be rather ambiguous.
 
John Fairbairn
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DaB... that is an interesting point. At first glance at this question, I would say the Math class was immutable since it 'cannot be changed'.
We know that for strings a new string object is created when we try to change the string and the original string stays intact.
So i'm wondering do you have to be able to create an instance of a class for it to even be considered immutable? Since the math class is final maybe it can't be referred to as immutable...
 
rajsim
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
B. java.util.String
Since when the String class moved to Java.util !?
A. java.lang.Math
Immutable classes do not permit change in the value of the object once it is created.
String is immutable as the value it contains can not be changed,
not that it is final.
But, instance variables of final classes can be changed at
any point in the program as per access rules.
Hence final classes do not necessarily mean immutable.
Now, As Math class doesn't contain any value, it may not be
termed as immutable or mutable
Please feel free to correct me.

[This message has been edited by rajsim (edited July 18, 2000).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic