Ankit Garg

Sheriff
+ Follow
since Aug 03, 2008
Ankit likes ...
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
Merit badge: grant badges
For More
Bangalore, India
Cows and Likes
Cows
Total received
43
In last 30 days
0
Total given
20
Likes
Total received
320
Received in last 30 days
0
Total given
245
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ankit Garg

IMHO Concurrency is a topic best understood with practice. One of the problems with Concurrency is it is tricky to produce race conditions which you can fix with locks. But with Thread.sleep race conditions can be created. Depending on how much time you have before your exam attempt, you can explore additional resources like "Java Concurrency in Practice" book or YouTube videos along with more free mock tests to get better understanding of the topics.
Howdy Badeanu, welcome to Coderanch.

I took the exam 15 years ago at an exam center. At the center they give you pen and paper which you can use and give it back to them after the exam. If you are taking the exam at home online, then you might not be able to do that. Again at the time I took the exam the application had a feature to take notes for each question. Then if you revisit the question you could look at your notes for that question. You could also mark questions to revisit them later if you were not sure about them. I doubt they would've removed these features from the application.

Stephan van Hulst wrote:First, polymorphism only applies to non-private instance methods. It doesn't apply to fields. So when the Ship class refers to weight or height, it will always be the weight or height field that is a member of the Ship class, not the field that is declared in the RocketShip class. Fields also don't override each other: RocketShip.weight is a completely different and unrelated field to Ship.weight.



I think this kind of explains most of your questions. Any method in Ship class cannot see variables defined in any sub-class. Also public int getWeight() { return weight; } and public int getWeight() { return this.weight; } mean the same thing at runtime (in this case where there is no variable in the method which shadows the class field).
Hi Amer, welcome to CodeRanch.

Inner interfaces are iplicitly static but inner classes are not. That's why you are able to access interface Power inside the main method but not if you change it to a class
Howdy Patrick, welcome to coderanch.

I guess the authors didn't want to confuse people by removing the parameter name. Other than that you are right, the parameter name is not part of the method signature. So if two methods have same name and parameter types, then the parameter names don't matter and both methods have same signature.
This book is an excellent resource for anyone preparing for Java Programmer certification. The book has detailed coverage of all exam objectives and includes a mock test to give a good idea of how the actual exam would be like. There are a lot of useful examples, figures and reference tables in the book and there are indexes to find these which is very handy. The review questions in every chapter are tricky and help solidify the concepts.

Some of the highlights of the book IMO are:
  • The order of chapters is also ideal for people relatively new to Java. For example, the chapter on object comparisons and the chapter Lambdas introduces equality, sorting, filtering concepts before collections and streams chapters.
  • The chapter on Generics has useful reference tables highlighting which operations are allowed when using Wildcards. There are many such useful tables throughout the book.
  • Dedicated and detailed chapter on ArrayList. Helps with introduction to collections vs arrays. Important collection classes summarised in figures and tables for reference.
  • Streams chapter has a lot of good figures to clearly explain how multiple operations on a stream are applied and how they affect each element in the stream.
  • Useful guides at the end about how to register for the exam as well as mapping of exam objectives to chapters including Java 11 certification objectives.


  • Nothing is perfect and neither is this book. Quick Summary/Review Notes at the end of each chapter would've helped as reference once someone goes through the book. Also due to the margin and paper size some of the examples span 2-3 pages. I wish there was a bigger paper size used (although it would've been a non-standard book size then), then it would be easier to fit more content on every page and the thickness of the book would be less.

    ---
    Disclosure: I received a free copy of the book from the publishers to review on behalf of coderanch.
    8 months ago

    Image from Amazon
    Title: OCP Oracle Certified Professional Java SE 17 Developer (Exam 1Z0-829) Programmer's Guide
    Authors: Khalid Mughal, Vasily Strelnikov
    Publisher: Oracle Press
    Category: Java Certifications

    Amazon wrote:OCP Oracle Certified Professional Java SE 17 Developer (Exam 1Z0-829) Programmer's Guide is a unique guide that combines a rigorous introduction to programming in Java with meticulous coverage of the Java SE 17 and Java SE 11 Developer exam objectives. Fully updated to reflect changes in the latest exams, it features an increased focus on analyzing code scenarios--not just individual language constructs. Each objective is thoroughly addressed, reflecting the latest features and APIs, as well as best practices for taking the exam. The only book anyone needs to study for Java SE 17 Developer or Java SE 11 Developer certification. Book features include:

    Easy to find coverage of key topics relevant to each exam objective
    An introduction to essential concepts in object-oriented programming (OOP) and functional-style programming
    In-depth coverage of declarations, access control, operators, flow control, OOP techniques, lambda expressions, streams, modules, concurrency, Java I/O, key API classes and much more
    Program output demonstrating expected results from complete Java programs
    Unique diagrams to illustrate important concepts, such as Java I/O, modules, and streams
    Extensive use of Unified Modeling Language (UML) to illustrate program design
    Dozens of review questions with annotated answers to help prepare for the exam and a complete mock exam



    Where to get it?
    Amazon
    Oreilly
    8 months ago
    I've read a few chapters of the book till now and I think the diagrams/figures can be divided into two categories. 1) The figures which show heirarchy of classes/interfaces and 2) figures which explain execution flow or concepts in general. The 1st category of figures (along with the tables) act as a good reference and the index helps find them easily. Regarding the 2nd category if you check the index, some of the chapters like Streams and Multi-Threading have a plethora of diagrams which greatly help understand the runtime flow of programs and concepts like Thread states. I really enjoyed reading the concurrency chapters, it is one of my faviorite topics.

    For disclosure, I got a review copy of the book from publisher but these opinions are my own.
    FWIW I did review for some of the chapters and they are very thorough. Any time I thought a topic was not covered and I found it on the next page
    The tests Simon mentioned at the end of the chapter were tricky and solidified the concepts.
    From my experience in the forums, most people give the exam by studying books (like Khalid mentioned) and then doing online mock exams. I've not seen many people doing the Oracle training so I have no idea if it is good. But a lot of people have cleared Oracle Java certifications using books + mock exams (including myself).
    Welcome, your book was of great help when I was preparing for my SCJP 5 certification ages ago :-D
    I agree with you Fabricio, the question is ambiguous. The compilation error is not on line 3, but to me the error/mistake is more on line 9 where hatch is not passed to super constructor.

    int i1 = c1 + c2; //Here c1 and c2 are promoted to ints?
    char c3 = c1 + c2; //How about here?


    You are right, c1 and c2 will be promoted to int, that's why the 2nd line won't compile.

    int i2 = 'a' + 'b'; //There is no promotion?
    char c4 = c1 + c2;   //How about here?


    Here I'm assuming you wanted to write char ch4 = 'a' + 'b'; which does compile i.e. the literal values are not promoted to int.
    As Mikalai mentioned, there is generally an option which says the code won't compile, but it won't ask how many lines won't compile. The creators of the exam make extra effort to make questions which are not ambiguous (or dependent on compiler behavior like this).
    Howdy Marco, let's take a look at it with an example. Let's say you have this parent class:


    Now looking only at the above code, can you say for sure whenever print method is called it will always print Message: Parent class? I might call the call method with new Parent() as parameter OR I might send a new Child() to the call method. Or I might create another class which extends Parent. I'm pretty sure that's what the question meant to say. When you look only at your class (Parent in this case), you don't know who will inherit from it (someone else 6 months later might inherit from your class), so you cannot be sure which method call will be overridden.