An open API service indexing awesome lists of open source software.

https://github.com/seanmisra/java-coding-exercises

40 Java Exercises
https://github.com/seanmisra/java-coding-exercises

java java-11 java-17 java-8

Last synced: 3 months ago
JSON representation

40 Java Exercises

Awesome Lists containing this project

README

        

# java-coding-exercises

Commits correspond to each exercise

1. Maven project Hello World
2. write main() entry-point function in another way
3. Demonstrate String immutability
4. Importance of order in String concatenation
5. Widening and Narrowing (casting) examples
6. How many primitive data types can equal 'a'?
7. Demonstrate StringBuilder mutability (in contrast to String)
8. String literal pool (use == to demonstrate equality)
9. String equality with equals (use same examples from Exercise 8 for clarity)
10. Default values (local vs instance)
11. 3-5 ways to initialize an array
12. 4 ways to initialize wrapper class (ex: Integer)
13. Static/Instance initializer blocks (demonstrate calling order relative to constructor)
14. Type Promotion (show one operator where it is used and one where it is not)
15. x++ vs ++x
16. Short-circuit vs Logical operator (ex: || vs |)
17. Example where finally clause is not executed
18. Create an infinite loop with for
19. Examples of unary, binary, ternary operators
20. Constructors -- demonstrate multiple constructors including usage of this()
21. Constructors -- demonstrate usage of super()
22. Multiple Inheritance (superclass vs interface)
23. 4 kinds of interface methods (abstract, default, static, and private)
24. 4 kinds of abstract class methods (abstract, non-abstract, static, and private)
25. Convert array to List 2 ways (as List view and as new unique List)
26. Use streams to sum integers 1-100 inclusive (ideally 2-3 different ways)
27. Sort an ArrayList based on two properties (1st/2nd precedent)
28. Generate 1000 random numbers btw 1 and 5, and return a Map with the results
29. Streams - examples of using map and flatmap
30. Get today's date in YYYY-MM-DD format
31. Get today's date in YYYY-MM-DD format with timezone offset
32. 2 ways to create a Thread (extend Thread/implement Runnable)
33. Read a file line by line with BufferedReader
34. Read all lines from file with Files utility class
35. Use BufferedWriter to write to a file
36. Write/read object to file via serialization/deserialization (include one static and one transient field)
37. Example class that uses generics
38. Synchronized function (counter example; test with ExecutorService)
39. Repeat exercise 38 with a synchronized lock
40. JDBC (code flow for calling a PreparedStatement and reading from ResultSet)