Ryan Beckett

Ranch Hand
+ Follow
since Feb 22, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
9
Received in last 30 days
0
Total given
7
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ryan Beckett

Thanks Paul! Quality software indeed.
5 years ago
Hi, a little background: I've been using Java for nearly 10 years in a hobbyist fashion. I started using it in College and used it as my primary language for fun coding over the years. I never really cared to study the language features in depth, but I became proficient with about 75% of the language features. Recently, I decided to get certified to help my resume, as I am not a degree holder, but IMHO, definitely possess the skills to be a professional developer. I took the OCAJP 8 exam a month ago and barely studied for it. I breezed through the official guide written by Ms. Boyarsky and Mr. Selikoff. Got a 92%. I immediately scheduled the OCPJP 8 exam and bought the official guide for that. I was very confident that I needn't study most of the exam topics that appeared prior to Java 7. I never really used NIO, the new concurrency APIs, Localization, the new Date/Time APIs, or functional programming APIs. I saw examples and tutorials over the years, but never actually used them in my projects. Mind you, I have minor experience in Scheme, Scala, and other functional languages, so I understood the concepts well, just not Java's implementation.

So, I had a month to study... and I ultimately ended up studying for roughly 4 days! In the beginning of the month, I read through the first 4 chapters of the official study guide book, then I just stopped studying. I spent most weekends working on an app for my portfolio. I had planned on spending my 3-day weekend before the exam to study the aforementioned topics in depth. I went through Enthuware's objective-wise tests and failed many of them, but I learned from their explanations. This approach was effective for me since I only needed to learn the nuances of certain topics and to get more practice with the new APIs. I studied for 10-12 hours straight both days doing Enthuware and playing with APIs in IntelliJ. I used the book as needed.

I was afraid that I didn't know the new APIs well enough that I could risk failing the test. There were so many complex Stream APIs! I knew I could deduce many correct answers if the exam didn't concentrate ONLY on testing for mundane API specifics (e.g. what exception does Files.move() throw). I completely accepted the fact that I wasn't going to be able to remember all the possible exceptions thrown by methods, or more importantly, what conditions would cause those exceptions to be thrown. Aside from that, I felt like I understood everything conceptual I needed to for the test. Or at least, so much that, I could remove the wrong answers. My impression of the first few questions invoked anxiety. They were code samples, and I was unsure of my answers. The vast majority of the test was all code samples, some small, some large. I had very few non-code questions that asked for straight-forward conceptual knowledge, and surprisingly some of them were not covered in the official OCPJP 8 text, nor Enthuware. I felt like I was guessing on more of the questions than I would have liked, which didn't sit well with me during the exam. Even worse, I'd always be able to narrow down an answer to two choices but was stuck between the two. The exam seemed to get easier with each passing question, or rather I just stopped caring since time was running out.

Ultimately, I finished with ~10 minutes left to review. Overall, the test provided good coverage of all the topics. As mentioned by others, the exam is dominated by lambdas and Streams, but I also got many Concurrency and NIO questions, so don't ignore those topics. There were some easy things I missed, such as knowing that methods could be 'final'. The questions do test multiple things at once, hence some of them were "gotchas". Ironically, I did the best on the lambdas/Streams questions.

Enthuware is a great product and should be used for preparation, but in my experience, the exam is nowhere near as hard as Enthuware. Enthuware is very tricky, and frankly, frustrating, but I highly recommend it to toughen you up. Also, shoutouts to Ms. Boyarsky and Mr. Selikoff. They wrote a fantastic study guide! Welp, hope this helps, and good luck to you all who are taking the exam!
5 years ago
Welcome guys!! The book looks good!
12 years ago
This program works as it should.
A few things:



You don't need and shouldn't use an instance to invoke a static factory method (or any static method). It should be:



Static factory methods are used in patterns where you want object creation control. In you case, it appears that you want to use the singleton pattern: allow only one instance to be created and used. To do so, your method should be:



You were probably getting an exception in your servlet, because the object that was returned was a databaseConn and not a Connection, which has the method preparedStatement(). After those changes your code should be working or close to it. And, yes, it's probably not the best idea to try and implement your own pooling, especially when reliable solutions exist.
12 years ago
I initially thought 4 too. To show you that's it's not 3, replace the instantiation wit this:



If SelfTestParent.sayHello was overridden "Child" would be displayed, but it's not.

It's not 1, because interface methods have to be overridden. Final methods cannot be overridden. It's not 2, because only abstract and public methods are allowed in interfaces. If an interface had a static method, each implementer would have to define it, which defeats the purpose of a static method: a method that is stored with each class, not instance. And finally, since members of interfaces are public by default (private members would be contradictory), since you can access an interface variable using qualification (making them static), and since all interface variables must be initialized (making them final) , 4 is true.
The member x of each instance of Ship refers to same array instance created in init(). It's the same for y. You need to create a new ones.

12 years ago
Polymorphism is an OO-programming concept, where the programmer has the ability to handle related derived types with a base class type. If my argument's type is a base class, then the object can be any derived type and I can call any method inherited from that base class. If the object's type has overridden the inherited method, that version should be invoked.



drawShape's argument is polymorphic, it can operate on many types (Rectangle and Circle) and invoke the correct function (if it's overridden).
12 years ago


Your attempting to define a method inside a method which is illegal in Java.
12 years ago
First, I'd a buy book on compilers. I recommend Modern Compiler Implementation in Java or Compilers: Principles, Techniques, and Tools. Then, I'd check out JLex, JavaCC and CUP, because it's probably not the best idea to try and create a compiler from scratch. There's a lot of formal language theory, automaton theory, and assembly language used in building compilers from the ground up.
12 years ago


I've read that StringBuffer.equals compares the objects' references, not the content of their strings. The correct way is as follows.


12 years ago
It's because 9.45 is a float and "the ternary operator converts the numeric types to whatever is more generic." It's one of those hidden Java traps. Joshua Bloch exposes this in Advanced Topics in Programming Languages: Java Puzzlers @ 0:56 minutes and in his book "Effective Java."

I quote from JLS 15.25:

The type of a conditional expression is determined as follows: ... if the second and third operands have types that are convertible (§5.1.8) to numeric types, then there are several cases: ... Otherwise, binary numeric promotion (§5.6.2) is applied to the operand types, and the type of the conditional expression is the promoted type of the second and third operands.

.
Try this.

12 years ago


Since I've just given you the answer, at least let me explain it, so you can learn how I did it.

Start off by reviewing the literature in the Regex API linked above. It's a good reference, but if you've never done regular expressions, check out the tutorials first.

(1)

This is the range of the specific Latin unicode characters you expect to be in the input. Simple enough. See the Latin Unicode chart for details.

(2)

This means match (or allow) any word character (0-9, A-Z, or a-z)

(3)

Allow whitespace characters.

(4)

Allow any punctuation character.

(5)

Allow all of previously declared characters "and not" this one. Whatever punctuation you don't want needs to be included inside the brackets.

(6)

This is a greedy quantifier. It says to allow "one or more of all of these characters" in the string. Note that the regular expression must be enclosed in brackets when applying the quantifier.

Also, Note that all of these specifiers are escaped because they're within strings. Hope that helps. Good luck.
12 years ago