I can't think of a logic to test the following code in a correct way.
I read that in java8 interface can implement boolean but it will error if we pass object class into it. That is if we try to overwrite object class through interface we'll get an error. Before trying it out I thought I'd first try to write something that makes uses of boolean method and accept objects into but I'm not sure what to write it without any idea. Can someone think of something like bike, car or vehicle logic to write the below code to make more sense and so I can test various different methods of it. Maybe no need to write the code but give me a logic that I can implement?
Here is something I tried out for Interface.. I want a logic like this for the above code.
What I meant is that I don't know a case (like a real world scenario but very simple) to use boolean class and method. This is just so I can practice a lot with different methods and scenarios. I only just learnt about boolean so I can't think of a case myself and Java is my first programming language.
Btw I've already completed the complete core java but going through tutorials second time and want to try various use case of each stuff. I've been getting some ideas from youtube when I search for "java boolean example or tutorial" but haven't found a case where they pass object to boolean method.
I can think of writing a if statement for status and print something if its returns true which it does, but what's the point of passing "testing_2". Can't think of anything at the moment to try out different ways to test.
Which book are you using? Is it Horstmann? That isn't a tutorial, nor a beginner's book. Also beware of things you find on YouTube; you don't know whether they are all right, or bad.
Please find out about the conventions for Java® identifiers. Don't use underscores. Don't call a class Interface1; that is a good recipe for confusing yourself later on. In your first example, yes, what is the point in that method taking a parameter at all? It doesn't use it.
Only write, “class object,” if you are making an instance of the Class class. Nor, “object class.”
I think you want to find out about the Predicate interface. Find a book like Modern Java in Action by Urma Fusco and Mycroft (Manning 2018) (or its older edition called Java8 in Action), and go through it looking for examples of use of the Predicate interface.
If you are speaking of Predicates -- as Campbell is guessing -- and you want to know of a real-life use for them, I use them for validation in a class I call Inputer. This class prompts for a value at the command line. You pass in the prompt and any validation you need with a predicate.
The i -> i > 0 is the predicate.
All things are lawful, but not all things are profitable.