Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!

Eric Longhorn

Ranch Hand
+ Follow
since Feb 09, 2017
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Eric Longhorn

During the test, do all the questions, besides the ones that may take some time or some of the head scratcher questions. Make sure you mark them. If you prepared well, you should finish with some extra time left. Use the remaining time to go over the marked questions (questions that take time and the head scratcher ones).
Hey everyone,

Today I took the OCAJP 7 and passed with 83% at the age of 13!  
I studied for around 2-3 months of 2 hours per day, using the following materials:
-Mala Gupta's Java SE 7 book
The exam was actually pretty easy compared to what I had thought. I've heard everyone say that Enthuware was slightly harder than the real exam, but I didn't know by THIS much.  
I had initially finished the exam in 1 hour, but I had a lot of questions marked for review (~25?) that I was either unsure about, or I thought I could have been careless with.
After the last hour in which I checked most of the marked, I had 7 marked questions, but I could not go over them since I had only 40 seconds left.
Overall, I'd say this exam was a great experience for me, and it was worth the time of studying.

Thanks to everyone on this forum!  
3 years ago
Ok, thanks.
3 years ago
So the following code throws a ClassCastException:

But I am not sure how it does.
Is it because m1() returns an object, and an Object is not a String, so therefore you cannot convert it into a String?
3 years ago
I've heard that you need to log on to CertView to view what you got on your exam, but is that the only way?
Does the test center show you your score immediately after you finish your exam?

Ok, I get the general gist of it, but I'm stuck on how the second object in class Emp has a member variable emp.
3 years ago
So I get that the default constructor made from the new on line 2 would like this:

Or something like that. What I don't get is how the new Emp(); is in the default constructor.
Prior to this question, I had thought that default constructors were either empty, or had super() in the case of inheritance, but clearly this is wrong.
How is an object in the default constructor?
3 years ago
How does the Emp constructor call itself over and over again?
3 years ago
So this code throws a StackOverflowError:

But I don't understand how. I get that an instance is created off of class Emp, which is the first step that causes the error, however after that I'm totally lost.
Could someone point me in the right direction?
3 years ago

The reference is being copied  
3 years ago

Bear Bibeault wrote:What lead you to that belief?

I ran this code:

and it printed out hello, which meant that the original String was not changed.
3 years ago
I think I figured it out. I ran a little code snippet, and based on the results I believe that whenever you pass a String into a method, a copy of the String is made and passed into the method.

3 years ago