This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!

Richard Hayward

Ranch Hand
+ Follow
since Feb 15, 2012
Richard likes ...
VI Editor
Cows and Likes
Cows
Total received
13
In last 30 days
0
Total given
0
Likes
Total received
26
Received in last 30 days
0
Total given
10
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Richard Hayward

Thanks to all for your help on this thread.

Seems I should spend a bit of time exploring what levels of access are given to objects when reflection is used, as opposed to when it's not.
1 month ago
So could I clarify this?

Stephan van Hulst wrote:The error message tells you exactly why it can't create an instance of NewInstanceTest1$Dog: It has the private access modifier.



I didn't understand Stephan's response here because I thought that as far as inner classes are concerned, the outer class can see members of an inner class, even if they are declared private. For example:


the dog barks. Therefore, from my initial post


I was thinking that because Dog is an inner class, the outer class should be able access all it methods. Is the problem that it's Dog that's the inner class, not dogClass?


1 month ago
Thanks for the tips about Date. It's not primarily Date I was interested in, any class would do. I just came across that code snippet when googling for an example of the use of newInstance().

Campbell Ritchie wrote: It also doesn't tell you that you oughtn't to use newInstance() any more.


ok. That link for the java 12 api shows newInstance as deprecated since java 9. I'm using a java 8 compiler.

Campbell Ritchie wrote:
So  tried your code and didn't get any exceptions.


Should still work though shouldn't it?

1 month ago
Could anyone tell me why one of these examples works and the other doesn't?

My first example compiles but throws an exception.

According to the api for Class
'IllegalAccessException is thrown  if the class or its nullary constructor is not accessible.'

I'm thinking that the fact that the dog barks at line 7 demonstrates that neither of those things is true.

My second example, (simplified from the example at TutorialsPoint ) compiles and runs ok.


Seems to me however that the second example is doing the same thing.
1 month ago
I'm thinking of doing the upgrade exam from java 6 to 8.

I liked the Sierra/Bates book when I did the java 6 exam, so I thought I'd stick with those authors.

Could anyone with experience of that book comment on a couple of questions?

Assuming I have a good grasp of the material required for the java 6 exam, is it reasonable to start with volume II? Or, would I find that volume II assumed knowledge of some post java 6 feature that had already been explained in the first volume?

Secondly, does the book contain a checklist of what pages/chapters need to be mastered for the upgrade exam? The preview at Amazon cuts off at the point where my guess is that any such table would be.

Liutauras Vilda wrote:
But that is really what would happen. s[0] trying to access very first element within an array, while s isn't referring to an array of Strings, but rather a singular String.


oops.. apologies!  I should have said that the test had several questions  like this:

Key point being that an isolated bit of code like this won't compile. Put it inside a class and it will compile but throw an exception at runtime.
I wasn't expecting incomplete code samples like this.
Yes, thanks to all here, both those who've answered my many questions and everybody else who has provided many interesting discussions.

ok, so it's ancient Java 6, the exam for which is about to retire. But, I've been studying for it, on and off, for ages and as I thought I could probably pass I might as well have a go. If I want to upgrade to certification against more recent version, I'll have less to deal with all in one go. Not thinking of doing that any time soon however, I've got real life stuff I want to write.

I got 91%, which is better than I was expecting at the end of the test. I got thrown by the first few questions which had things like



Now, I immediately thought, hey this isn't going to compile, as we can't have methods kicking around loose, outside of any class. However 'It won't compile' wasn't an option. There were line numbers down the left side, which unlike the coderanch formatting, didn't start at 1. I guess I was supposed to infer from those line numbers that this was code correctly placed inside an unseen enclosing class, however I don't think that was ever explicitly stated.

One couldn't highlight sections of code. I'm accustomed to doing that to isolate in my mind the bit of logic I'm trying to think about. One question had many brackets to match up.. is there a closing bracket to match every opening bracket? It was so horribly formatted that without being able to highlight sections I just couldn't tell.

Then there are the pens! The caps need to be replaced or they stop writing. It means that if a method takes several minutes to trace through, making notes as you go, the pen is dry by the time you reach the end. Pencil & paper would be far better.

For my study materials, I used the excellent SCJP book from Sierra & Bates.

Plus, Enthuware Test Studio. I obviously can't speak to the other exams, but the Enthuware product I used is beautifully crafted. That goes for the quality of the questions, the accompanying explanations, the forum support and the actual desktop software itself. I'd certainly buy from them again.

Plus, many many many small programs. I just did a file count on my source directory, about 1500 files. That's got to be excessive!

Final tip. 150 minutes is quite a long time. Don't drink a lot beforehand

Panic over.

I raised a support ticket with Oracle support via their support page. Googling 'Oracle Certification Program (OCP) Support Help' should find it.

Their response was quick. Created a ticket on Sunday, got a mail on Monday, and by today Tuesday, problem is resolved.

Emanuele Mazzante wrote:Could you suggest me something to start with that is valid (video course, manual or other)?



There's a youtube playlist from javabrains Developing RESTful APIs with JAX-RS that I really liked:

https://www.youtube.com/user/koushks

I linked to this in a previous thread here, so apologies if you've already seen it.
1 year ago
Could anyone advise on what the process for logging in to certview is, or if there is any such thing?

I have a test booked & paid for next week in the UK. During the booking process I was given an Oracle Testing ID.

I can login to  https://wsr.pearsonvue.com/  where I can see next week's exam, date, time & location.

According to http://pearsonvue.com/oracle/ the next step is to 'verify you have an Oracle Web Account and then authenticate your account at certview.oracle.com.'

I do have an Oracle account, or I think I do! I can certainly login at www.oracle.com, and once logged in, the email address they hold for me is the same as that held for me at the pearsonvue site. However I can't see any link to my list (of zero!) certifications. So, I'm uncertain if my Oracle account is aware of my pearson account. When I try to use Oracle's CertView Authentication page, to authenticate my Oracle testing id & email address, it tells me that 'Unfortunately, we are still unable to authenticate the information that you have entered'.

So, I don't know if I have a certview account, whatever that is, or not. Is there some way of verifying this?

I've tried phoning Pearson and was told that no such certview page, listing certifications, exists until after the test, at which time I'll be mailed a link to it. However, the conversation was difficult as neither of the two people I spoke with seemed to be fluent in English and I'm not convinced they understood my query once it deviated from their script.


I'd appreciate any advice.

I did read through this earlier post from some months back, where Roel De Nijs linked to a discussion indicating that this isn't just me. But, that was about 8 months ago.
https://coderanch.com/t/683067/certification/Unable-login-certview

Thank you Stephan.

Stephan van Hulst wrote:You're asking Class to access it, and Dog is not a private member of Class.


Trying to think that through, Class is in java.lang, a different package from PrivateTest1 and I didn't declare the static nested class Dog as public, so from the perspective of java.lang.Class, even in my PrivateTest1 example, Dog shouldn't be visible.

This might involve a deeper enquiry into the workings of java.lang.Class than I need for practical purposes
1 year ago
Suppose a test class contains a static inner class Dog, which it instantiates and makes bark.

Everything works, even if I instantiate a Dog in the over-complicated fashion of line 7.
Assuming that class can access its own private members, I was expecting this to work exactly the same if Dog is declared private, but that's not the case. The code compiles, but throws an IllegalAccessException.


So, is it not true to say, without qualification, that a class can access it's own private members?

1 year ago

Tim Holloway wrote:I think that this is actually a grammatical problem. The word "Exception" in the message means "An exception was thrown", not that specifically a "java.lang.Exception" was thrown.


ok. There is a similar circumstance if I attempt to compile code where I throw a Throwable that's neither caught or declared.


The unreported Throwable is described as an exception, not an Exception (with an upper case E).

1 year ago
Thanks Stephan.
1 year ago

Running from the command line results in a message that there is an Exception:



But, I didn't throw an Exception, I threw a Throwable. So, I wondered if the act of throwing a Throwable caused the jvm to throw an Exception and if so, of what type. However, that can't be true either, since any Exception would have been caught.

At this stage in a program's life, is it pointless attempting to distinguish between the two, or is there some subtlety to be understood here?




1 year ago