Learning is incomplete without challenging questions to assess the knowledge gained. There are courses and books available on Functional Programming & Stream API, which cover these topics in detail, but simply watching the video lectures or finishing the book will not give enough confidence unless the knowledge is validated.
Practice tests in this course will not only help you to assess your current knowledge of these topics but will also help you to revise the topics quickly. Questions are designed to challenge your understanding of the topics. Detailed explanations for all the questions are also provided for your reference.
Functional programming is not a new concept. Lambdas were implemented in other languages much before they were introduced in Java.
Before JDK 8, anonymous inner classes with a single method was the closest Java came to functional programming but with lots of boilerplate code. If anyone wants to really appreciate the implementation of lambda expressions in java, it is necessary to know the anonymous inner classes in depth and to understand anonymous inner class you need to have knowledge of Regular and method-local inner classes.
You may face lots of questions in interviews or written tests where you are asked to convert anonymous inner class syntax to lambda expression and vice versa. Therefore, I decided to start with questions on inner classes and then go on with Lambda expression, method references, built-in functional interfaces and finally end this test series with questions on Stream API.
1st practice test covers questions on:
Regular Inner class:
Regular inner class and its syntax
Usage of this reference with Regular inner classes
Shadowing of Outer class variable by Inner class variable
Allowed access and non-access modifiers for Regular inner class
Accessing Regular inner class's name from within outer class and outside of outer class
Instantiating Regular inner class
Allowed and not allowed components inside a Regular inner class
Method-local inner class:
Method-local inner class and its syntax
Modifiers used with method local inner classes
Relationship between method local inner class and top-level class
Where to create the instance of method local inner class?
Usage of local variables with method-local inner class
Anonymous inner class:
Syntax of anonymous inner class
Inheritance and Polymorphism with anonymous inner class
Defining non-overriding methods in anonymous inner classes
Instance of anonymous inner class can be assigned to static variable, instance variable, local variable, method parameter and return value
Anonymous inner class extending from concrete class or abstract class or implementing an interface
Constructors and anonymous inner class
Static nested class:
Syntax of static nested class
Accessing instance and static members of static nested class
Allowed access modifiers with static nested class
Nested interface defined within a class
Nested interface and nested class defined within an interface
2nd practice test will test, how well you know lambda expressions.
2nd Practice test covers questions on:
Lambda expression and its syntax
Arrow (->) operator
Simplified Lambda expression syntax
@FunctionalInterface annotation
Requirements for an interface to be a Functional interface
Convert anonymous inner class code to Lambda expression
this within anonymous inner class vs this within lambda expression
Usage of local variables with Lambda expression
Once you are comfortable with lambda expressions, then you can take 3rd practice test to assess your method references concepts.
3rd Practice test covers questions on:
Method reference and its syntax
Double colon (::) operator
4 types of method references:
Method Reference to Constructor
Method Reference to Static Method
Method reference to an Instance Method of a Particular Object
Method Reference to an Instance Method of an Arbitrary Object of a Particular Type
Possibility of ambiguous call when a method reference syntax refers to both static and instance method of the class
Java 8 has provided various built-in functional interfaces, out of which 4 are most important and rest are dependent upon these 4 interfaces.
4th practice test covers questions on:
Supplier interface
Consumer interface and its default method: andThen
Predicate interface and its default methods: and, or, negate
Function interface and its default methods: compose, andThen
Comparator interface, its static method: comparing and default methods: thenComparing, reversed
Stream API made the life of Java developers a lot easier.
5th practice test covers questions on:
Generic Stream interface and its primitive counterparts
Creating sequential streams
Important methods of Stream interface
Generic Optional class and its primitive counterparts
Convert arrays and collections to streams
Sort a collection using Stream API
After Stream support in Collection API, processing collection elements became a lot easier. Parallel streams can run tasks in parallel without writing cumbersome logic.
6th practice test covers questions on:
Method stream() of Collection interface
Save results to a collection using the collect method and group/partition data using the Collectors class
forEach(Consumer) method of Iterator<T> interface
Convert arrays and collections to streams
stream() and parallelStream() methods of Collection interface
parallel() and sequential() method of Stream interface
Behavior of various methods such as forEach, reduce, forEachOrdered, findFirst with parallel streams
NOTE: All the codes in this practice test are tested against JDK 8.
So, grab a cup of coffee or your favourite drink and test your Java Functional Programming skills.
Features of Practice Tests:
You can pause the test at any time and resume later.
You can retake the test as many times as you would like.
The progress bar at the top of the screen will show your progress as well as the time remaining in the test. If you run out of time, don’t worry; you will still be able to finish the test.
You can skip a question to come back to at the end of the exam.
You can also use “Mark for Review” to come back to questions you are unsure about before you submit your test.
If you want to finish the test and see your results immediately, press the stop button.
Copyright 2024 Udayan Khattry
All rights reserved. No part of this course may be reproduced in any form or by any electronic or mechanical means, including information storage and retrieval systems, without permission in writing from the author.
275
0
TAKE THIS COURSE