Win a copy of Terraform in Action this week in the Cloud forum!

Bob Vel

Greenhorn
+ Follow
since Mar 21, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bob Vel

Also, my sincer thanks to jqplus. It helped a lot.
20 years ago
Dear friends,
Finally, finally I passed with scoring 70% on SCJP.
I messed up in gc and exception.
Thanks for all your encouragement.
Thanks to all you guys and also for this great site.
20 years ago
Dear friends,
Yesterday I appeared for exam and I scored 59% (35 questions answered)
Secion Analysis
Declaraion and access control 50%
Flow control and exception handling 42%
Garbage Collection 100%
Language Fundamentals 66%
Operators and Assignments 28%
Overloading, Overriding, Runtime Type, and Object orient. 71%
Threads 71%
java.awt package 50%
java.lang package 50%
java.util package 100%
java.io pacakge 80%
I felt really bad. I should have prepared more on operatores and assignments and exception handling. Even though I got 10 minutes to complete my last question, I have not reviewed all my answers once. I should have done that. Anyhow now it is too late and next time I will be more careful. It was really a bad luck. Anyhow I am going to appear again and I registered immediatly for next exam once I reached my home. This time I will work hard and prepare for exam. I will schedule my exam by 28th of this month. Bless me to pass this time.
Thanks for all you guys help and this great site.
20 years ago
Which of these statements are true?
Select all valid answers.
(a) {{}} is a valid statement block
(b) { continue; } is a valid statement block
(c) block: { break block; } is a valid statement block
(d) block: { continue block; } is a valid statement block
(e) The break keywork can only be used if there exists an enclosing loop construct.
The Answer is a and c.
Why not d ?
Please explain. Thanks in advance.
Which one is the most preferable to use?
I was reading about interface and abstract and they are behaving like same. Interface gives the benefits of an abstract as well interface. So, which one I should use always?
Someone please explain.
Thanks in advance.
class Test1{
private Test1() {}
static Test1 makeATest1() {
return new Test1();
}
}
public class Test2{
public static void main(String[] args) {
//!Test1 x = new Test1();
Test1 x = Test1.makeATest1();
}
}
//!Test1 x = new Test1();
You cannot create a Test1 object via its constructor. Instead you should call the makeaTest1() method to do this.
So, only answer 2 is applicable. Hope this will help.
If I am wrong then someone please correct it.
Regards
Bob
Hello Tejas,
Congrats ! Man without programming background you prepared in 10 days and passed. Great!!!
Please give some hints and materials that you referred.
20 years ago
Thank you all for clearing my doubt.
Hi Eric,
Thanks for your reply.
It is not clear yet. How come when you use curly braces it is working fine. I am still confused.

1 class Test {
2 Test(int i) {
3 System.out.println("Creating Rock number "+i);
4 }
5}
6public class SampleConstructor {
7 public static void main(String[] args) {
8 for(int i = 0; i < 10; i++)
9 new Test(i);
10 }
11}
The above code works fine.
If I change line number 9 to Test r = new Test(i);
I am not able to complie code. Why?
public class EqualsClass1 {
public static void main(String[] args) {
Integer i1 = new Integer(50);
Integer i2 = new Integer(50);
System.out.println(i1.equals(i2));
}
}
Result is true - Perfect

class Value {
int i;
}
public class EqualsClass2 {
public static void main(String[] args) {
Value b1 = new Value();
Value b2 = new Value();
b1.i = b2.i = 75;
System.out.println(b1.equals(b2));
}
}
Result is false - How come?
Please explain. Thanks in advance.
A programmer's guide to Java Certification
By Khalid A.Mughal & Rolf W.Rasmussen
class StaticTest
{
static int i = 47;
}
class StaticFun
{
static int incr()
{
//System.out.println("Resuls is "+StaticTest.i++);
return StaticTest.i++;
}
}
class StaticRun
{
public static void main(String arg[])
{
StaticFun sf = new StaticFun();
int rslt = sf.incr();
System.out.println("Resuls is "+rslt);
}
}
Question :
Running this code I am getting output as 47. If I uncomment SOP
then I am getting 47 & 48. I expected result 48.
Please explain. Thanks is adv.
Bill,
Thanks for your reply.
As per your reply (ans 2) the following code is throwing runtime ClassCastException. How can I avoid this? Thanks in advance.
Class hierarchy is
Animal -> Mammal -> Dog & Cat (Cat implements Runrun)
Cat c;
Dog d;
Runrun r;
c = new Cat();
r = c;
d = (Dog)r;