Ed Orsini

Greenhorn
+ Follow
since Apr 15, 2008
Ed likes ...
Java
Merit badge: grant badges
For More
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 Ed Orsini

Great! Thanks for the feedback. I will definitely look those up.

-- Ed
Hi:

Thank you all for this great site. I passed my OCPJP exam yesterday.. ;)

My question is: is there a book you'd recommend for learning SPRING? I am starting to learn the framework at work, but I'm interested in a easy-read book to start from the beginnings. Any feedback is very much appreciated as usual.

Thank you.

-- Ed
Thank you very much for making it clearer for me!
Hi all:

I have a question regarding when to cast and not to cast covariant returns. I have one example I coded that uses covariant returns where object2 extends object1 and a method in object2 returns B which is a subclass of A -- which the method in object1 returns A. This makes sense because it is the definition of covariant returns. This is done without a cast.

Now, my question comes in in the next example where object2 extends object1 and a method in object2 returns a String which is a subclass of Object -- which the method in object1 returns type Object. This code requires a cast to String and I am confused as of why it is needed here and not in the case above. Can anyone please explain? The following is the code that I am working with:

CASE 1: without a cast
**************************************************************************
class A{
int x=5;
}

class B extends A{
int x=6;
}

public class CovariantTest{
public A getObject(){
return new A();
}

public static void main(String[] args){
CovariantTest c1=new SubCovariantTest();
System.out.println(c1.getObject().x);
}
}

class SubCovariantTest extends CovariantTest{
public B getObject(){
System.out.println("Inside SUB");
return new B();
}
}


CASE 2: with a cast
**************************************************************************
class First{
public Object method1(){
System.out.println("Calling super class method");
//return new String("Base");
return new Object();
}
}

class Second extends First {
public String method1(){
System.out.println("Calling sub class method");
return new String("Derived");
}
}

public class CovariantTest2{
public static void main(String[] args) {
First o = new Second();
String s = (String)o.method1(); // if cast to a String it will compile --
System.out.println(s);
}
}


Thanks for your help.

-- Ed
Hi guys:

The first mock exams I took (Whizlabs), I was not passing the exams. I was getting 38/72, 40/72, 41/72. I did learn a lot from doing them. But I did not want to take the exams with Whilabs just because if I do good I am afraid of memorizing the questions. So, it wouldn't give me a good measure to determine if I am ready for the test. I started doing the exams at ePractiveLabs and I am passing them with at least a 70%. My question is, should I feel ready? Are the Whizlabs exam harder than the ePracticeLabs exam? Is the real exam more like Whizlabs or more like ePracticeLabs? I am just worried that it would be more like Whizlabs and those were the ones I did worse on... Please advise. Regardless, I will keep studying until I get better scores on both, but was wondering if anyone had any input on this. Thanks.
So, the Whizlabs tests I did not pass, but I did learn a lot from. I just dont think doing them over again would do me any good since I am afraid I would be memorizing the answers. Thanks for your advice and help.
Hi all, congratulations to all that have cleared the exam. I am at that stage where I am not sure if I am ready to schedule the exam yet. I read the book. I did mock exams. I did ePraticeLabs and score 70 or higher on the mock exams. But, I am not sure if ePracticeLabs is a true measure for the exam? Can anyone please advise if I am getting 70 or more on those exams, am I in good shape to pass? Thanks for your time and help. I also started to do Whizlabs and I found those a bit harder. I was getting 40 out of 72 right. Any help is appreciated. Thanks!