0% found this document useful (0 votes)
2 views

Java_Core_2022

Uploaded by

snehasahu0444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java_Core_2022

Uploaded by

snehasahu0444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 9

Author - Adarsh Gupta, ©Sheryians Coding School Bhopal. v4.

0
-- MODULE 1 --
Day 1 --Installation of Java & Intellij IDEA
--IDE ? Integrated Development Environment
--Creating a new project in Intellij IDEA
--Exploring Settings of Intellij
--Font Size
--Theme
--Enabling zoom feature
--Writing your first program
--main public static void main(String[] args) { }
--sout System.out.println();
--Running a Java program
--Comments
--Single Line //
--Multi line /* comments */
--Understanding the need of a variable
--Intro to data types
--int - stores integers Ex - 1 2 3
--String - stores combination of characters Ex - "Shery"

Day 2 --Variables
--can contain Data or Object References (DTL)
--Variable declation, Initialization
--Role of + operator between String & numbers
--String + String = String - Concatenation
--String + int = String - Concatenation
--int + int = int - Arithmetic Addition
--Naming Convention for Class/Variable/Method name - identifiers
--Must start with an alphabet or _ or $
--Can end with a alphabet or _ or $ or numeric digit
--Spaces are not allowed
--No reserved keyword
--Java is CASE SENSITIVE
--Cases and Conventions for clean and readable code.
--PascalCase - Class & Interface
--camelCase - variable and method name
--Game of brackets
--( ) - Methods - Parantheses
--{ } - Scope/body - Curly
--[ ] - Array - Square
--<> - Generics - Angular

Day 3 --Literal or constant


--Data Types - Graphic
--Primitive or Pre-defined
--Integer --why 4 ?
--byte, short, int, long( l or L suffix )
--Every Integer constant in java is int by default
--Floating Points
--Stop calling these decimal numbers
--float( suffix - f or F ), double( suffix - d or D -
Optional)
--Every floating constant in java is double by default
--Non Numeric
--boolean, allowed values - true or false
--char - UNICODE (ASCII is a subset of UNICODE)
--Range - 0 to 65,535
--char can hold a equivalent int value
--Non Primitive
--User defined or Custom data types
--Derived from Primitive data types
--String literals
--String name = "Shery"

Day 4 --API - Application Programming Interface


--Reading Inputs from User
--Scanner Class
--Present inside java.util package
--Import Scanner class - import java.util.Scanner;
--Create Instance - Scanner sc = new Scanner(System.in);
--Standard Input, Output - STDIN, STDOUT
--Use methods to read respective data
--nextByte(), nextShort(), nextInt(), nextLong(), nextFloat(),
nextDouble(), nextBoolean()
--Reading String Data
--nextLine() - Reads the whole line
--next() - Reads the first word
--Reading char data
--nextLine().charAt(0)
--Problem with nextLine method
--If nextLine is used right after any scanner method then it will
not work properly.
--Remember to use a dummy nextLine method after reading nextXYZ
data
which will pick the newline character
--Introduction to JAVA DOCUMENTATION

Day 5 --Operators in Java


--Unary, Binary
--Arithmatic +, -, *, /, %, ++, --
--int/int will always yields int
--Modulo can work with int (works perfactly) as well as floats
(produces unambiguity)
--Increment/Decrement operators can only be applied on variables,
not on constants.
--Pre ++a
--Post a++
--Special powers of / & %
--/ to reduce the number
--% to get last digit(s) of number
--Relational <, >, <=, >=, ==, !=
--These returns values in boolean - true or false
--Logical &&, ||, !
--Used to combine multiple conditions
--ShortHand operators
--Precedence and Associativity of Operators
--Rest to be covered later like bitwise and shift operators

Day 6 --Control Flow Statements


--if(condition)
--executes its body if condition returns true
--works only on boolean values
--did not do anything if condition returns false

--if(condition) ... else


--executes body of if, if condition returns true otherwise
executes else body
--else can't exist without if
--else do not have any condition

--if(condition) ... else if(condition)


--it is just a combitionation of the above two

--if(condition) if(condition) if(condition) if(condition) - Aka if


ladder
--Nothing but a combination if multiple independent if statements

--Package
--Creating a new package
--package statement should be the first line in the java code file
--Used to group a similar set of classes (code management)
--Default Library package imported by default in every Java class
java.lang.*
--Math class
--Present inside java.lang
--abs()
--floor()
--sqrt()
--cbrt()
--ceil()
--pow(double a, double b)
--round()
--max(double a, double b)

Day 7 --MORE PROGRAMS ON IF ELSE


--Discount on Bill
--INR Denomination
--Weekdays of corresponding number

--Ternary Operator
--<condition> ? true : false;
--Type Coversion or Type casting
--Implcit or Widening
--order byte->short->int->long->float->double
char->int
--Expilicit or Narrowing
byte<-short<-int<-long<-float<-double
short<-char<-int
--syntax
<data_type><var> = <data_type><var or val>;
--Type Promotion

Day 8 --Loops
--Need of loops in programming
--Types
--Entry Controlled
--Exit Controlled

--for(init; condition; incre/decre)


--Executes its body untill condition returns true
--Syntax tweaks
--Init outside loop
--multiple conditions
--incre/decre inside loop body
--Conditions for infinite for loop
--for(;;)
--for(;;);
--if condition never returns false
Day 9 --while(conditions)
--Executes its body untill condition returns true
--Use it when the number of iterations are unknown
--Conditions for infinite while loop
--while(true)
--condition never returns false

Day 10 --Nested Loops


--Loop inside loop
--How to identify if nested loop is required ?
--Pattern Programming
--print() Vs println()
--Hackerrank

Day 11 --DO ... WHILE(condition);


--Executes at least one time
--Don't forget to put semicolon after while
--Executes untill conditions returns false

Day 12 --Switch statement


--Allowable data types - byte, short, char, int, String. (also wrapper
classes of the same)
--Why not floating points ?
--Generates ambiguity (comparison is not perfact with
floats)
--switch dont check each and every case.
--multiple cases can be combined together
--Seperate multiple cases by commas.
--cant use the expressions as cases.
--Generates ambiguity
--every case must be unique.
--fall through - gir jana.
--switch table
--Java v14
--Reducing boilerplate using arrow functions - aka lambdas
--No break statement required.
--Switch Expression
--yeild keyword

Day 13 --Arrays Data Structure


--Need
--Architecture
--One D array
--Different ways of initialization
--with new keyword
--With size
--int[] arr = new int[size]
--Without size
--int[] arr = new int[]{1, 2, 3}
--size and init can't be done together
--without new keyword
--int[] arr = {1, 2, 3}

--Default values of array element


integers - 0
floats - 0.0
char - null character, unicode - '\u0000'
boolean - false
non-primitives - null

Day 14 --Programs on array

Day 15 --Enhanced for loop


--Searching
--Linear Search
--Binary Search
--Sorting
--Bubble Sort

Day 16 --Multi D Arrays


--2D/Matrix, 3D Array
--Array of Array References
--Memory structure
--Matrix form of 2D array
--Initialization
--With new keyword
--With constant values
--Programs
--Traversing / Visiting each index of array
--Taking inputs
--Displaying elements of array in matrix form
--Sum of Digonals
--Jagged Arrays
--Must provide the size of first dimension
--Importance of length property in traversing

--ArrayIndexOutOfBoundsException
--NullPointerException

Day 17 --Methods
--Method Signature / Method Prototype / Method Definition
--Need of methods
--Method types
--static
--Invoke by class name
--instance / factory method / non static
--Invoke by object's reference
--Programs
--Factorial
--Strong Number
--145 = 1! + 4! + 5!
--Armstrong Number
--153 = 1^3 + 5^3 + 3^3
--Special Number
--109 = 1 + 0 + 9 = 10 = 1 + 0 = 1

Day 18 --Arguments
--Formal Arguments
--Actual arguments
--Arguments Passing
--Pass by value
--Passing Array Objects.
--varargs
--exactly three dots (...)
--variable length arguments
--there can be only one varargs in a method
--if there are other parameters then varargs must be declared in the
last.

Day 19 --Object Oriented Programming Part 1


--Relation bw Class, Object & Constructor
--Class is prototype, object a real thing
--Class is a blueprint of building, object is building itself
--Constructor runs only once after object creation
--Class
--Class can have attributes(variables) and behavior(methods)
--How will you store the information of a student
--Custom data types
--Instance fields / Data members
--Keep the data members of class private
--Factory methods
--Object
--Creating an Object
<Class name> ref = new <any constructor of Class>
--Object has state(instance fields) & behaviour(methods)
--Constructor
--Executes at the time of object creation
--Main purpose is to initialize the instance fields
--Default Constructor
--Para Constructor
--this keyword
--Points to current calling object
--Rules and Properties.
--Same name as class name,
--when an object is created with new keyword, the
constructer is called.
--called only once in object lifecycle at object creation
--No return type.
--can not made static.
--What happen if we provide it a return type
--It will become an ordinary java method and will not be
called at object creation.

Day 20 --Making a Model


--Data Containers
--Getters
--Setters
--toString()
--hashCode
--equals()
--Data members of a class must be private.
--Making a class read only
--Array of Objects
Program to Store the data of 5 students and print them
--Overloading
--Rules(By following any of given rules we can achieve overloading).
--Number of agrs must be different
--Data type of one or more args must be differnt.
--Order of args must be different
--Constructor overloading
--Method Overloading
Day 21 --Understanding behind the scenes
--JDK, JRE, JIT, JVM
--Platform Indepent
--Java bytecode
--Command Line
--cd, cd.., cls, dir, mkdir, rmdir, tree, ping
--Running Java program via cmd
--In case of single java class
java FileName.java
--In case of multiple classes
javac FileName.java
java MainClassName
--Leetcode

Day 22 --String API


--array of characters.
--Strings instances are immutable that is they can not be changed,
however if u try to change the
value a new instance/object will be created in the memory.
--Strings literals
--String name = "Adarsh";
--Using this method, they gets generated in the special memory
location called
String Constants pool inside heap(architecture).
--Why immutable ?
--String Constructor
--String name = new String( "Adarsh" );
--Gets generated inside heap but points to different objects.
(architecture)
--String Methods
--Comparing Strings
--Avoid using == operator
--Using equals(), compareTo()

Day 23 --StringBuilder API


--Mutable String Objects
--Default capacity - 16 characters.
--Constructors
--StringBuilder() - 16 characters capacity
--StringBuilder(int n) - N characters capacity
--StringBuilder(String str) - Length of str + 16 characters
capacity
--Important Methods
--When to choose StringBuilder
--In case of too many manupulations on String Objects
--StringBuilder vs StringBuffer vs String

Day 24 --Wrapper Classes


--Autoboxing
--Unboxing
--Useful Methods
--Parsing Strings
--Useful in Collection framework and other APIs

--BufferedReader API
--InputStreamReader
--Reading data through BufferedReader
--readLine()
--Parse Strings into respective data type
--Why BufferedReader

Day 25 --ArrayList API


--Lists - ArrayList - Kind of Dynamic Array
--Default Capacity is 10
--Can store duplicates and null values
--ArrayList stores Objects
--Autoboxing & Unboxing in ArrayList
--Creating an ArrayList
ArrayList<TYPE> ref = new ArrayList<>();
--Important Methods
--add(E e), add(int index, E e),
--clear()
--remove(int index) - remove from particular index.
--remove(Object obj) - remove first matched object.
--forEach() ex- ref.forEach((n) -> sout(n));
--contains(Object obj) -returns true if the element found.
--set(int index, E element)
--get(int index)
--subList(int from, int to);
--size()
--indexOf(Object obj)

Day 26 --Hashing/HashSet/Map

stack calls in a normal prog


heap
recursion
break
continue

You might also like