Workshop Timings
Workshop Dates: 16th - 29th July 2020 (weekdays)Workshop Timings: 12:00 AM - 3:30 PM (12 - 15.30)
Break Timings: 2:00 - 2:20 PM (14 - 14.20)
Exceptional: 27th July workshop to be conducted @ 5:30 PM - 9:00 PM (17.30 - 21)
Class Recordings π½ Course Flow π
- Introduction
- Environment Setup
- Day 1
- Day 2
- Day 3
- Day 4
- Day 5
- Day 6
- Day 7
- Day 8
- Day 9
- Day 10
- Capstone Project
- Further Reading
- Future Path? What to do next? π€π±βπ
Solutions to all sample problems on HackerRank under the Java domain can be looked up here.
Programming is a very hands process and is both an art as well as a science. We are engineers and are required to create efficient solutions but at the same time our programs should be highly readable and flexible and all the other snappy terms which makes it an art as well.
To become proficient in this art, there are many resources, and books and tutorials. Each has it's merit and making the first step in any direction is commendable, but the cardinal factor at the end of the day will be you sitting down (or standing) and writing code. No book or resource can substitute that.
So, what are you waiting for ππ - try as many questions (below or otherwise) as you can....
Stalk your Instructor on GitHub & linkedIn.
We need to install and configure a few things before we can write and run any Java code. To write Java code we need the Java runtime environment (JRE) and the Java Development Kit.
JDK Version >= 1.8 is recommended i.e. Java version 8 or above is recommended for this course and personal development projects. Install Java for your OS from the Oracle Website.
To check that java has been correctly installed on your machine run the following command on your terminal:
java -version
It should have an output akin to:
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
Once that Java has been successfully installed, we need to install a code editor or IDE so that we can write programs and run them. I suggest using VS Code if you prefer a Code editor over an IDE (or if you don't know the difference between Code editor and IDE π). using a code editor will aso be less intensive on computing resources.
I personally prefer the JetBrains IntelliJ IDEA, but warning β it is a heavy software and might not run properly on all machines (especially laptops that are constrained for resources).
- Download the setup from here.
- Run the setup which is pretty straight forward. Just click next like 10 times and voila!
- You can either install the community edition (free) from here.
- Or you can create an account on JetBrains if you have a university email address and then install the JetBrains Toolbox.
- You can easily manage JetBrains IDE's and projects using the ToolBox app. From the ToolBox app you can now install either IntelliJ IDEA Community Edition or Ultimate Edition.
This is an optional step of your getting started guide and can be skipped. Although installing git and using it in your projects is highly recommended. For a learning path to learn git have a look at the Future Path + Scope section.
Install git from the git-scm website. Run the setup and click next like 10 times and use the recommended settings for installation.
There will be a section when it will ask the standard text editor and gie you an option between Vim and nano. If you are not familiar with Vim then opt for nano.
IMPORTANT Opt for nano if not familiar with Vim.
To check your installation of git check that git bash has been intalled and run the following command on your terminal.
git --version
The output should be akin to
git version 2.24.1.windows.2
Open your text editor/IDE and create a new file HelloWorld.java
and in that file copy paste the following code
snippet.
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
To run the code navigate to file in terminal and run the following commands.
javac HelloWorld.java
java HelloWorld
Hello World # output
- Hello World
- Comments
- Data Types
- Variable Names
- Taking User Input
- Arithmetic Expressions
- Operators Short Syntax
- Logical Expressions
- If Else Statements
- Finding number is Even or Odd
- Ternary Operator
- While Loops
- Sum N Natural Numbers
- Factorial of a Number
Problem | Source | Solution Link |
---|---|---|
Welcome to Java | HackerRank | Solution |
Java StdIn and StdOut I | HackerRank | Solution |
Java If Else | HackerRank | Solution |
Data Types Problem | HackerRank | Solution |
Java Int To String | HackerRank | Solution |
Java Currency Formatter Problem | HackerRank | Solution |
Java String Reverse | HackerRank | Solution |
- Hello World Once Again !
- While Loop
- For Loops
- Do While Loop
- Sum N Natural Numbers
- Sum of Squares of N natural Numbers
- Pattern Question 1
- Pattern Question 2
- Pattern Question 3
- Pattern Question 4
- Pattern Question 5
- Control Flow Statements
- Switch Statements
Problem | Source | Solution Link |
---|---|---|
Java Output Formatting | HackerRank | Solution |
Java Strings Introduction | HackerRank | Solution |
Java Substring | HackerRank | Solution |
Java String Compare | HackerRank | Solution |
Java Date and Time | HackerRank | Solution |
Loop based & Pattern based questions given here
Problem No. | Solution |
---|---|
Question 1 | Solution |
Question 2 | Solution |
Question 3 | Solution |
Question 4 | Solution |
Question 5 | Solution |
Question 6 | Solution |
Question 7 | Solution |
Question 8 | Solution |
Question 9 | Solution |
Question 10 | Solution |
Question 11 | Solution |
Question 12 | Solution |
Question 13 | Solution |
Question 14 | Solution |
Question 15 | Solution |
Question 16 | Solution |
Question 17 | Solution |
Question 19 | Solution |
- Switch Statements
- Cosine Taylor Series Loop
- Sine Taylor Series Loop
- Multiplication Table
- Pascal's Triangle
- Functions
- Sum N Natural Numbers
- Question 18 of the loops section of begin with java.
Problem | Solution Link |
---|---|
Question 18. a | Solution |
Question 18. b | Solution |
Question 18. c | Solution |
Question 18. d | Solution |
Question 18. e | Solution |
Question 18. f | Solution |
Question 1
WAP (Write a program) to a print the following pattern. User entersrows
[See Solution]
******** *** *** ** ** * *
* * ** ** *** *** ********
Question 2
WAP to print the following pattern. User will enter number of rows (rows
>= 2). If user
enters rows
< 2 then no pattern is printed. You can also add a second variable called
columns
that takes how many stars *
to print in the first and last line.
[See Solution]
******** * * * * * * * * ********
Question 4
WAP to print the following pattern. User entersrows
.
[See Solution]
* * * * * * * * * * * * * * *
Question 5
WAP to print the following pattern. User entersrows
.
* * * * * * * * * * * * * * *
Question 6
WAP to print the following pattern. User entersrows
.
[See Solution]
* * * * * * * * * * * *
Question 7
WAP to print the following pattern. User entersrows
.
[See Solution]
1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Question 8
WAP to print the following pattern. User entersrows
.
[See Solution]
1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Question 9
WAP to print the following pattern. User entersrows
.
[See Solution]
1 1 2 1 x 3 1 x x 4 1 x x x 5 1 2 3 4 5 6
Question 10
WAP to print the following pattern. User entersrows
.
[See Solution]
A A B A A B C B A A B C D C B A
Question 11
WAP to print the following pattern. User entersrows
.
[See Solution]
********1******** *******2*2******* ******3*3*3****** *****4*4*4*4***** ****5*5*5*5*5**** ***6*6*6*6*6*6*** **7*7*7*7*7*7*7** *8*8*8*8*8*8*8*8*
Question 13
WAP to print the following pattern. User entersrows
.
[See Solution]
* * * * * * * * * * * * * * * *
Question 14
WAP to print the following pattern. User entersrows
.
[See Solution]
* ** *** **** *** ** *
In case rows = 4
* ** ** *
Question 15
WAP to print the following pattern. User entersrows
.
[See Solution]
For rows = 3
3 44 555 6666 555 44 3
For rows = 2
2 33 444 33 2
For rows = 5
5 66 777 8888 99999 101010101010 99999 8888 777 66 5
Question 16
WAP to print the following pattern. User entersrows
.
[See Solution]
For rows = 4
1 2 3 4 5 6 7 8 9 10
For rows = 2
1 2 3
Question 17
WAP to print the following pattern. User entersrows
.
[See Solution]
For rows = 4
1 2*3 4*5*6 4*5*6 2*3 1
If rows = 4
1 2*3 4*5*6 7*8*9*10 7*8*9*10 4*5*6 2*3 1
Question 18
WAP to print the following pattern (Pascal's Triangle). User entersrows
.
[See Solution]
For rows = 5
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
The pattern is derived in the pascal's triangle using values in the previous row.
1 1 1 1 (1 + 1) 1 1 (1 + 2) (2 + 1) 1 1 (1 + 3) (3 + 3) (3 + 1) 1
Question 19
WAP to print the following pattern (Hollow Rhombus). User entersrows
.
[See Solution]
For rows = 3
****** ** ** * * * * ** ** ******
For rows = 5
********** **** **** *** *** ** ** * * * * ** ** *** *** **** ***** **********
Question 20
WAP to print the following pattern (Butterfly pattern) [See Solution]
For rows = 3
* * ** ** ****** ****** ** ** * *
For rows = 5
* * ** ** *** *** **** **** ********** ********** **** **** *** *** ** ** * *
- Recursion
- Sum N Natural Numbers
- Factorial: Introduction to Recursion
- Fibonacci: Recursion Continued
- Function Signatures
- Math Module
- Arrays
- Array Input
- Arrays Deeper Dive
- For Each Loop
- Sum of Elements in Array
- Binomial and Pascal's triangle
- Cubes Example
- Hypotenuse in Right Angled triangle
- Odd even
- Prime Numbers
-
Time Complexity Problems [InterviewBit]
-
WAP to create a function
add()
that takes 2 integer values and returns the sum. [See Solution]
public static int add(int a, int b) {
}
- WAP to create a function
difference()
that takes 2 integer values and returns the difference. [See Solution]
public static int difference(int a, int b) {
}
- WAP to create a function
product()
that takes 2 integer values and returns the product. [See Solution]
public static int product(int a, int b) {
}
- WAP to create a function
divide()
that takes 2 integer values and returns the quotient. [See Solution]
public static int divide(int a, int b) {
}
- WAP that creates a function which calculates the factorial of a number
n
. Where: [See Solution]
0! = 1
1! = 1
3! = 1 * 2 * 3 = 6
5! = 1 * 2 * 3 * 4 * 5 = 120
- WAP to create a function that calculates the Binomial Coefficient
nCr
. Where: [See Solution]
nCr = n! / (r! * (n-r)!)
4C0 = 4! / 0! 4! = 1
3C2 = 3! / 2!*1! = 6 / 2 = 3
- WAP to create a function that calculates the Permutation value
nPr
. Where [See Solution]
nPr = n! / (n-r)!
5P0 = 5! / 5! = 1
6P3 = 6! / 3! = 6*5*4 = 120
- WAP to create a function to check whether a given number is prime or not. [See Solution]
private static boolean isPrime(int number) {
}
- WAP to create a function that returns the length of a hypotenuse of a right angle triangle given the lengths of the other 2 sides [See Solution]
private static double hypotenuseLength(double a, double b) {
}
- WAP to create a function to return the day of the week (name) from the day number. Example [See Solution]
private static String dayFrom(int value) {
}
dayFrom(0) --> "Sunday"
dayFrom(1) --> "Monday"
...
...
dayFrom(6) --> "Saturday"
- Swap
- Return Statement
- Sum of Power Series
- Finding Maximum Element in Array
- Finding Minimum Element in Array
- Linear Search
- Circular Right Shift (Home work)
- Number of Even Numbers in Array
- Zeros in Array
- Palindrome
- Reverse of Array
- Sub Array
- Varargs Input
- 2D Arrays
- 2D Arrays Input
-
WAP to return the value of the sum of the following series recursively given
n
. [See Solution]1^1 + 2^2 + 3^3 + 4^4 + ... + n^n
-
WAP a program that returns that sum of the first N natural numbers and finds this sum recursively. [See Solution]
f(N) = 1 + 2 + 3 + ... + N
so, for
N = 3
f(3) = 1 + 2 + 3 = 6
and forN = 5
f(5) = 15
. -
WAP a program that calculates the sum of the series
f(N) = 1 + 2^2 + 3^2 + ... + N^2
using a recursive function. [See Solution]
-
WAP to input an integer number
length
from the user and then instantiate an integer array of sizelength
and then display that array on the terminal with all entered values.
[See Solution] -
WAP that inputs an integer array from the user and returns the sum of all its elements. Create a dedicated method for calculating array sum with the following signature. [See Solution]
private static int sum(int[] array);
-
WAP that inputs an integer array from the user and prints the number of even, odd and zero elements. [See Solution]
-
WAP to implement linear searching in an array. The user enters an array of size
n
and then an integerelement
. search for thiselement
in the array and return the first index at which it is found otherwise return -1 if not found in the array. [See Solution] -
WAP that takes an array from the user and returns a reverse array with the order of all elements reversed and then prints this reversed array. [See Solution]
If the input array is array = [1, 2, 3, 4, 5] then the resultant array should be = [5, 4, 3, 2, 1]
The method should have the following signature.
private static int[] reverse(int[] array);
-
WAP that takes an integer array from the user and returns the product of all it's elements. [See Solution] The method signature should be
private static long product(int[] array);
-
WAP to tell whether an array is an anagram or not. The user will enter an integer array. [See Solution] For example
array = [1, 2, 1] this is an anagram as the reverse of this array is also [1, 2, 1] array = [1, 1, 1, 1] This is also an anagram as the reverse is the same [1, 1, 1, 1] array = [] The empty array is also an anagram as the reverse is [] the same. array = [-1, 0] is not an aanagram as the reverse = [0, -1] isn't the same.
Crete a method with the following signature that returns boolean; true or false i it is an anagram or not.
private static boolean isAnagram(int[] array);
-
WAP to Merge 2 sorted arrays and return the new array which is also sorted. [See Solution] For example
Let there be 2 arrays first = [1, 10, 20] and second = [1, 2, 4, 10, 67] Define a function with a sigature as:
private static int[] merge(int[] first, int[] second);
which should return an array = [1, 1, 2, 4, 10, 10, 20, 67]
Problem | Platform | Solution Link |
---|---|---|
Java Inheritance I | HackerRank | Solution |
Java Inheritance II | HackerRank | Solution |
Java Abstract Class | HackerRank | Solution |
Java Interface | HackerRank | Solution |
Java Method Overriding | HackerRank | Solution |
Java Overriding II (Super Keyword) | HackerRank | Solution |
- Classes
- Access Modifiers
- Inheritance
- Static KeyWord
- Static KeyWord Running Programs
- Functional Parameters
- Abstract Classes
- Composition
- Interfaces
Try the problems given below and have a look at the solution only after you have solved it to see the different implementations and ideas we might've used or to use as a reference if unable to solve yourself.
Problem | Platform | Solution Link |
---|---|---|
Java List | HackerRank | Solution |
Java ArrayList | HackerRank | Solution |
Java Comparator | HackerRank | Solution |
Covariant Return Types | HackerRank | Solution |
- Stack
- Stack (Continued)
- Builder Design Pattern
- Builder Design Pattern (Continued)
- Collections Framework: ArrayList
- Collections Framework: Queues
- Collections Framework: PriorityQueues
- Collections Framework: Stacks
- Iterable Interface: Even Numbers
- Iterable Interface: Even Numbers
Try the problems given below and have a look at the solution only after you have solved it to see the different implementations and ideas we might've used or to use as a reference if unable to solve yourself.
Problem | Platform | Solution Link |
---|---|---|
Java Stack | HackerRank | Solution |
Java Priority Queue | HackerRank | Solution |
Maximum Element | HackerRank | Solution |
Equal Stacks | HackerRank | Solution |
Balanced Brackets | HackerRank | Solution |
- Natural Numbers Iterator
- Natural Numbers Iterator (Continued)
- Prime Numbers Iterator
- Prime Numbers Iterator (Continued)
- Comparators
- Comparators (Continued)
- Graphing Application
- Graphing Application (Continued)
- Queue
- Stacks
- Priority Queues
- hashCode()
- HashSet
- HashMap
- HashMap: Words in a Sentence
Problem | Platform | Solution Link |
---|---|---|
Java Anagrams | HackerRank | Solution |
Java Hashset | HackerRank | Solution |
Java Map | HackerRank | Solution |
To showcase what we have learnt in this 10 day training workshop I have built a small hangman cli game that covers the different language constructs we have seen and also shows an example project that can be built using Java. See here .
The following online resources/videos, practice Questions and Books π are a good place to further enhance your Java Knowledge.
- HackerRank Java Domain
- HackerRank Data Structures Domain
- HackerRank Algorithms Domain
- HackerRank Java (Basic) Skill Certification
- HackerRank Problem Solving (Basic) Skill Certification
- w3 Schools Java
- Herbert Schildt Java 9e π
- Programming Pearls 2e π
- Clean Code π
- Stack Overflow Survey 2020
Hint: points to solution repo links...
Java is a very popular programming language and by learning the basics and stepping out into the Object Oriented Programing using Java could never be a bad step ;)
You can now advance in many different directions and learn many varied skill-sets.
Something that you think about doing is further learning more Java basics and improving your fundamental understanding of the different concepts in Java such as different recipes to use the Object Oriented Programming to create different design patterns etc.
Also learning about threads and multi-threaded programs and understanding the core library and interfaces and concepts such as Reflection in a better manner.
This can be done by going through the questions on the Java Domain on hackerRank whose solutions can be found here.
You could also read up about the language comprehensively in Herbert Schildt's Excellent Reference volume here π
Or like me you can take a deep dive in solving problems because that's just too much fun π. I highly recommend HackerRank's Data Structures & Algorithms domain whose solutions can be found here & here. I also recommend trying out programming challenges on leet code for those who may not like HackerRank's UI. And if you do try that, do help me in building up my leet code solutions repository by contributing (making pull requests).
This is not very correlated to Java, but Git is a technology being used by all organizations big and small that wish to maintain their code over teams of varied sizes and manage projects. Even this repository which you are currently reading in is being maintained by git & has been deployed on github.
Being proficeint with git and version control will help you manage all your projects, be in any language Java, Python, C++ and even non-programming projects very efficiently and you will be able to easily maintain project state over all your devices.
There is an excellent Version Control with Git course on Coursera by Atlassian or you can even try this Git Introductory 30min Video on YouTube to learn the basics of git.
So, what are you waiting for git started π (bad pun!)
Java being such a versatile and popular language has many web frameworks that have been built on it. The most popular ones being:
What is the Difference between Spring and Spring Boot?
Spring Boot is basically an extension of the Spring framework which eliminated the boilerplate configurations required for setting up a Spring application. It takes an opinionated view of the Spring platform which paved the way for a faster and more efficient development eco-system
Web development consists of 2 major parts. One is designing the client side that mainly covers designing the interface and front end controls that the client will be able to see and interact with. The core front-end technologies are HTML, CSS and JavaScript and all popular frameworks such as Angular, Vue & React have been built using these core technologies only!
So, if you are interested in front-end design you can learn the basics of HTML5 + CSS3 + js @ w3 schools and then learn any popular front-end framework. The other part of web development is the server side part which is hidden from the user and this is where all the heavy lifting and computation takes place. This is also where all the logic such as validation, authentication and parsing of data takes place.
Both Spring ad Spring Boot are server side frameworks built on Java and after this course you can easily get started with either as you are now familiar with all Language constructs.