This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

This code is not acting the same way in NetBeans

 
Ranch Hand
Posts: 106
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad you put it the way you did.
The reason I posted it is because first I wrote the if statement in the code snippet, by itself and of course I got a compiler error. Then I placed it inside a for, while , and do loops and no compiler or exception problems!
After all, the certificate exams are like the DMV - some of answers to the questions, have nothing to do with real world scenarios:)
 
Jake Monhan
Ranch Hand
Posts: 106
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick question - is there a rule as to how and where test() can be used in Java? Thanks
 
Saloon Keeper
Posts: 10668
228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is test()?

If this question is not related to the rest of this thread, please start a new topic.
 
Jake Monhan
Ranch Hand
Posts: 106
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:What is test()?

The following is the last paragraph of page 215 of the OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide,

"For the OCA exam, you only need to know how to implement lambda expressions that
use the Predicate interface. Remember the one method in the interface called test()? It
takes any one reference type parameter and returns a boolean."

I went searching to see if it had any other applications in java, but I couldn't find any. So in essence my question is the same question you've asked.

 
Stephan van Hulst
Saloon Keeper
Posts: 10668
228
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah you mean Predicate.test().

Predicate is a functional interface that represents a test to be performed on some input. I think its best known occurrence is in the Stream.filter() method. You supply a predicate to be tested on every element in the stream, and it filters out all the elements that fail the test.

I'm not sure what you mean by the question about what rule there is to using Predicate.test().
 
Jake Monhan
Ranch Hand
Posts: 106
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I'm not sure what you mean by the question about what rule there is to using Predicate.test().



Adding up the quote from the book and your answer, I gather that test() is only applicable within Predicate. That being the case, then second part of my question has no bearing.
 
Jake Monhan
Ranch Hand
Posts: 106
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 220, choice E to question 9 of the book OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide,

Which are methods using JavaBeans naming conventions for accessors and mutators?



If something like this shows up on the exam as one of the choices to the question, is it a wrong choice because variable canSwim has not been declared, or is it correct due to context of the question?

I guess what I am asking is, how tricky can the exam get?

 
Jake Monhan
Ranch Hand
Posts: 106
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been taking practice exams from different places and questions about following subject have popped up.



I have not seen any of these in the OCA prep book.  So I was wondering if I should study these independently or are they not in the book because they are beyond the 1z0-808 exam scope? Thanks
 
Jake Monhan
Ranch Hand
Posts: 106
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the following code MyClass() object created in line //1 is set to be garbage collected after line //6. I just was wondering, the object in question still has mc pointing to it, so why doesn't that prevent it from being garbage collection eligible?



 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!