0% found this document useful (0 votes)
7 views151 pages

Core Java Programming Fundamentals

Java concepts

Uploaded by

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

Core Java Programming Fundamentals

Java concepts

Uploaded by

Hamdulla Rahmat
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

{ Java } BluePrint.

Pramod Dutta

Jump to Core Java


[Link]
Remove Coding FEAR!
Jump to programming(1
Shot)

[Link]
Agenda
● Install Java JDK
● Variables
● Data Types
● String Class & Casting
● Operators
a. Arithmetic Operators
b. Assignment Operators
c. Comparison/Relational Operators
d. Logical Operators
[Link]
Agenda
● Math class
● Taking Input
● Conditional Statements ‘if-else’
● Class
● Object
● Mini-Project Problem

[Link]
Install Java
● Install JDK
● Eclipse
● Set the Path Java_home.

[Link]
[Link]
[Link]

[Link]
What is Java?
Java is an object oriented language.

Java is a programming language and


computing platform first released by Sun
Microsystems in 1995.

[Link]
Primary goals in the creation of the Java language

[Link]
Primary goals in the creation of the Java language

[Link]
Primary goals in the creation of the Java language

[Link]
Primary goals in the creation of the Java language

[Link]
Core Funda of Java is
Write once and Run anywhere!!

[Link]
Run anywhere ??
JVM Architecture

[Link]
Run anywhere ??
JVM Architecture
Java Development Kit (JDK)

JRE (Java Runtime Environment)

JVM (Java Virtual Machine)

[Link]
JDK > JRE> JVM
Java Development Kit (JDK) used for developing Java applications

includes the Java Runtime Environment (JRE), an interpreter/loader


(Java), a compiler (javac), an archiver (jar), a documentation generator
(Javadoc), and other tools needed in Java development.

JRE (Java Runtime Environment)


to execute your java program not develop

JVM (Java Virtual Machine) JVM is responsible for executing the java program line by line,
hence it is also known as an interpreter.

[Link]
JDK > JRE> JVM

[Link]
How Java Works?

401
Response

[Link]
How Java Works?
Source Code -> Compile It (Javac) -> Run the Compiled Code -> JVM
installed on Machines

401
Response

[Link]
Running Java File Using
CMD
[Link]

Move to src

401
Response

java [Link]

[Link]
What does the
compiler do?
- The compiler is a translator that acts as an intermediary between
the programmer and the CPU on the computer.

401
Response

[Link]
Code Structure in Java

Class Holds -> Methods -> Statements (what Methods


can do)

401
Response

[Link]
Code Structure in Java

401
Response

[Link]
!Important
- Every line that needs to be executed should be inside a class.
- Declarations and definitions
- class HelloWorld is the class declaration.
- The main is the point from where all the Java programs
start its execution. 401
Response

- Just as sentences in English must be terminated with a


period.
- Just as sentences in English can span several lines, so can
the statements in Java.

[Link]
Doubts
Do I have to put Main() Method in every class to run?

No, We can have multiple classes in Java, to run we need


only one main method 401
Response

[Link]
!Important
Did you know? The [Link]()
displays text in the current line of the console
and then move the cursor to the beginning of
the next line. 401
Response

[Link]
Quiz
Can we execute a java program without a
main method?

401
Response

[Link]
Quiz
Can we execute a java program without a
main method?
[Link]
gram-without-a-main-method
Yes, we can execute a java program without a main method by
using a static block
401
Response

[Link]
What you can Say in
Main Method?
Do something
Do Some Things Again and Again
Do some under this condition 401
Response

Loop and Loop Again

[Link]
Variables
A variable is a container (storage area) used to hold data.
Each variable should be given a unique name (identifier).

401
Response

[Link]
Variables
A variable is a storage location paired with an associated symbolic name
(an identifier), which contains some known or unknown quantity of information
referred to as a value.

Variables in Java are strongly typed; thus they all must have a data type
declared with their identifier

There are three rules to create an identifier:


401
Response

Characters from A to Z, as well as their lowercase counterparts, can be used.


Numbers from 0-9 can be used.
Special characters that can be used are $ (the dollar sign) and _ (underscore).

[Link]
Where are the variables
stored?
Variables, once declared in the program, are allocated space in memory.
Memory itself is organized as a long collection of one byte after another.

401
Response

[Link]
Variables
local variable
instance variable
static variable

401
Response

[Link]
Variables

401
Response

[Link]
Data Types
Data types are declarations for variables
There are 2 types of Data Types :
Primitive Data types : to store simple values These are the data types of fixed
size.

401
Response

[Link]
Data Types
Non-Primitive Data types : to store complex values

These are of variable size & are usually declared with a ‘new’ keyword.

Eg : String, Arrays

String name = new String("Aman");


401
Response

int[] marks = new int[3];


marks[0] = 97;
marks[1] = 98;
marks[2] = 95;

[Link]
Data Types
// A short type is a 16 bit signed integer
short age; // Stores from +32,767 to -32,768
These are the data types of fixed
// An int type is a 32 bit signed integer size.
int age; // Stores from +2,147,483,647 to -2,147,483,648

// A long type is a 64 bit signed integer


long age; // Stores from +9,223,372,036,854,775,807 to -
401
Response

9,223,372,036,854,775,808

[Link]
Data Types
float radius1 = 0.00000000000863872078f;
[Link](radius1);
double radius = 0.00000000000863872078;
[Link](radius);

401
Response

[Link]
Data Types

401
Response

[Link]
Declaring multiple variables in a
single line
// Group Declarations

int age, height;


char letter, alpha;
double radium, area;

401
Response

// Group initializations
int age = 10, height = 5;
double radius = 2.34, area = 4.55;

[Link]
Operations in Java

401
Response

[Link]
Operator precedence

Rule of BODMAS, which says; Brackets, Order, Division,


Multiplication, Addition, and then Subtraction.

(10 - 4) + 3 *4
401
Response

200 / 50 + (3 * 4)

10+3-4

[Link]
Java Math class

[Link]("2 raised to the power 3 is " + [Link](2, 3));


[Link]("Exponent squared is " + [Link](2));
[Link]("The square root of 16 is " + [Link](16));
[Link]("The cube root of 27 is " + [Link](27));

401
Response

[Link]
Comparative operators

401
Response

[Link]
Boolean operators

401
Response

[Link]
Problem Statement

401
Response

[Link]
Problem Statement
● First, compute the respective powers of two
floating-point variables x and y.
● Then Add them after taking powers.
● Then, compute the absolute value of floating-
point z. 401

● Subtract this from the above-computed addition


Response

value.
● Now take Cube Root of the answer.
● Use inbuilt functions to calculate this expression

[Link]
Quiz

● (2+3)-10 * 5;

401
Response

[Link]
String Class
Strings are immutable non-primitive data types in Java.
Once a string is created it’s value cannot be changed
if we wish to alter its value then a new string with a new value
has to be created.

401
Response

[Link]
String Immutability
Keep in mind that String objects are immutable, i.e, they
cannot be modified once created

401
Response

[Link]
String Class
Concatenation
String name1 = new String("Aman");
String description = new String("is a good boy.");

String sentence = name1 + description;


[Link](sentence);

CharAt
String name = new String("Aman"); 401

[Link]([Link](0));
Response

equalsIgnoreCase
Equals Demo
Split String
Substrings
ToUpper
ToLower

[Link]
String Class
Strings are immutable non-primitive data types in Java.
New String is created

401

String Pool or String Constant Pool Response

is a special area in Java Heap


memory where string literals are
stored

[Link]
String Class

401
Response

[Link]
String Class

401
Response

[Link]
String Interning is a method of storing only
one copy of each distinct String Value,
which must be immutable.

401
Response

[Link]
String Class
Substring
String name = new String("AmanAndAkku");
[Link]([Link](0, 4));

Length
String name = new String("Aman");
[Link]([Link]()); 401
Response

Replace
String name = new String("Aman");
[Link]([Link]('a', 'b'));

[Link]
Problem String

401
Response

[Link]
Problem String
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;

public class Solution {

public static void main(String[] args) {


Scanner in = new Scanner([Link]);
401

String S = [Link](); Response

int start = [Link]();


int end = [Link]();
String result = [Link](start,end);
[Link](result);

}
}

[Link]
[Link]
Problem String

401
Response

[Link]

[Link]
StringBuilder vs
StringBuffer

401
Response

[Link]
StringBuilder vs
StringBuffer

401
Response

[Link]
Casting
Casting in java is the assigning values of one type to another

we can only assign values of a number type to another type storing


numbers
Implicit casting
This casting is done by java implicitly i.e. on its own. It is assigning smaller values
to larger data types.
float price = 100.00F;
int gst = 18;
401
Response

float finalPrice = price + gst;

Explicit casting
This casting is done by the programmer. It is assigning larger values to smaller
data types.
int price = 100;
float gst = 18.00F;
int finalPrice = price + (int)gst;

[Link]
Casting : Auto widening and explicit
narrowing
The data is implicitly casted from small sized primitive type to big
sized primitive type. This is called auto-widening

The data is automatically casted from byte to short, short to int, int to
long, long to float and float to double.
explicitly convert the data from double to float, float to long, long to int, int to 401
Response

short and short to byte This is called explicit narrowing.

[Link]
Casting : Auto widening and explicit
narrowing

401
Response

[Link]
Constants
A constant is a variable whose value cannot change once it has
been assigned

final float pi = 3.14f;

401
Response

[Link]
Keywords
keywords are also known as reserved
words.

401
Response

[Link]
Operators in Java
● Unary Operator,
● Arithmetic Operator,
● Shift Operator,
● Relational Operator,
● Bitwise Operator, 401
Response

● Logical Operator,
● Ternary Operator and
● Assignment Operator.

[Link]
Operator
Preceden 401

ce
Response

[Link]
Math Class
Math is an important class in Java that is extensively used and has a lot
of interesting functions.
To import - import [Link];

Some functions include:


Max
int a = 10;
int b = 20; 401
Response

[Link](a, b);

Min
int a = 10;
int b = 20;
[Link](a,b);

Random
int randomNumber = (int)([Link]()*100);

[Link]
Taking Input
We take input using the Scanner class and
input various types of data using it.
To import the Scanner class - import
[Link];

Example :
401
Response

Scanner sc = new Scanner([Link]);


int n = [Link]();
float a = [Link]();
String name = [Link]();
String line = [Link]();

[Link]
Conditional Statements
ifelse
if(boolean) {
//Code
} else { 401

//Code
Response

[Link]
Conditional Statements
ifelse
int age = 30;
if(age > 18) {
[Link]("This is an
adult"); 401

} else {
Response

[Link]("This is not an
adult");
}

[Link]
Coding Exercise
Coding exercise#
Given a number x, you should check
whether it is even or odd.
401

If it is even, then store "even" in


Response

answer.

If it is odd, then store "odd" in


answer.
[Link]
Coding Exercise
String answer;
if (x % 2 == 0) {
answer = "even";
} else { 401

answer = "odd";
Response

}
return answer;

[Link]
Conditional Statements
switch(expression) Switch
{
case x:
// code block
break;
case y: 401
Response

// code block
break;
default:
// code block
}

[Link]
While Loop
int i = 0;
while (i < 5) {
[Link](i);
i++;
} 401
Response

[Link]
Do While Loop
do-while loop is used to iterate a part of the
program repeatedly, until the specified
condition is true.
do-while loop is called an exit control loop.
401
Response

do{
//code to be executed / loop body
//update statement
}while (condition);

[Link]
[Link]
[Link]
For LOOP
for (int i = 0; i <= 10; i = i + 2) {
[Link](i);
}

401
Response

[Link]
For Each Loop
String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
for (String i : cars) {
[Link](i);
} 401
Response

[Link]
Break & Continue
for (int i = 0; i < 10; i++) {
if (i == 4) {
break;
}
[Link](i); 401
Response

[Link]
Break & Continue
for (int i = 0; i < 10; i++) {
if (i == 4) {
continue;
}
[Link](i); 401
Response

[Link]
Conditional Statements
ifelse
Problem
[Link]
es/java-if-else/problem
401
Response

[Link]
Conditional Statements
ifelse
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;

Solution
import [Link].*;
import [Link].*;
import [Link].*;

public class Solution {

private static final Scanner scanner = new Scanner([Link]);

public static void main(String[] args) {


int N = [Link]();
[Link]("(\r\n|[\n\r\u2028\u2029\u0085])?");
if(N%2!=0){
[Link]("Weird"); 401
Response

}else{
if(N >= 2 && N <= 5){
[Link]("Not Weird");
}
if(N >= 6 && N <= 20){
[Link]("Weird");
}
if(N > 20){
[Link]("Not Weird");
}
}

[Link]();
}
}

[Link]
Arrays
Like a list of elements of the same type i.e. a list of integers,

Creating an Array (method 1) - with new keyword


int[] marks = new int[3];
marks[0] = 97;
marks[1] = 98;
401
Response

marks[2] = 95;

Creating an Array (method 2)


int[] marks = {98, 97, 95};

[Link]
Problem Max in Array
Max in ARRAY

Sample input & output #

Input: {4, 10, 12, 17, 11} 401


Response

Output: 17

[Link]
Functions / Methods
A function is a block of code which takes some input,
performs some operations and returns some output.
The functions stored inside classes are called methods.
The function we have used is called main.

401
Response

[Link]
Problem statement
Write a static method checkSum that adds two integer arguments and returns 0, 1 or 2.

● Takes two integers one and two in its input. Arguments are pass by value to the
method.
● Has a check variable whose value gets updated as explained below.
● Adds num1 and num2, and checks if their sum is less than 100 in which case
○ Sets the value of the check variable to 0.
● If sum is greater than 100
○ Sets the value of the check variable to 1.
● If sum is equal to 100
○ Sets the value of the check variable to 2.
● In the end, it will return the check variable.

[Link]
● public static int checkSum(int one, int two) {
● //Write your code here
● //Declare the necessary variable

● int check;
● int sum = one + two;
● if (sum < 100) {
● check = 0;
● } else if (sum > 100) {
● check = 1;
● } else {
● check = 2;
● }

● //Change the return variable as well

● return check;
● }
● }

[Link]
Problem
Sample input#
var = 3557
Sample output#
sum = 3 + 5 + 5 + 7 = 20

[Link]
Problems
Todo

problem of sum
max array
Function with return check variable
401
Response

[Link]
package [Link];

public class SumOfDigit {

public static void main(String[] args) {

int input = 3453;

int sum= 0;

while(input > 0){

sum = sum + input%10;

input = input/10;

[Link](sum);

[Link]
Class
A class is a group of objects which have common
properties. A class can have some properties and
functions (called methods).
The class we have used is Main.

401
Response

When a class is created, no


memory is allocated

[Link]
Objects
Object is an instance of a class. All
data members and member functions
of the class can be accessed with the
help of objects

401
Response

Objects are allocated memory


space whenever they are created.

[Link]
Class & Objects

401
Response

[Link]
Class
Every class in Java can be composed of the following elements:

● fields, member variables or instance variables - These are variables that hold data
specific to a particular object. For each object of a class, there is one field.
● member methods or instance methods - These perform operations on objects and are
defined within the class. 401
Response

● static or class fields - These fields are common to any object within the same class.
They can only exist once in the class irrespective of the total number of objects in the
class.
● static or class methods - These methods do not affect a specific object in the class.
● inner classes - At times a class will be defined within a class if it is a subset of another
class. The class contained within another is the inner class.

[Link]
What is your Biggest
takeaway from this...

[Link]
Action Item
Block at least
5-7 hour per
Weekend.

[Link]
ROADMAP
[Link]

[Link]
Topics
[Link]

[Link]
Course Details….

[Link]
ROADMAP - 4 Months

[Link]
● Core java
● OOPs Concepts
● Collection Framework
● Threading
● Design Patterns

[Link]
Core Java

[Link]
Collection Framework

[Link]
[Link]
Threading

[Link]
HackerRank

[Link]
Educative
[Link]

[Link]
Project Overview!!

[Link]
Manual Testing
Projects

[Link]
API Testing Projects

[Link]
Web Automation
Projects

[Link]
[Link]
Roadmap to learn
Selenium

[Link]
Web Automation
Selenium Real World
Projects

[Link]
Key features of Web Automation
Framework used
Key features of Web Automation Framework used :

● Page Object Model (POM)


● Java : most convenient programming language.
● Maven: For build management purpose, a common structure can be maintained very easily
● TestNG: Open source, most used Testing Framework, Amazing annotations
● Allure Reports : As it is most clean automation reports and provides lots of useful annotations as well.
For better documentation, it has been chosen over other reporting tools
● Lombok plugin : It provides very simple logging framework as compared to other logging methods
● Selenium Grid Handling
● Parallel Execution with Groupings
● Supports Cloud Testing Services like BrowserStack, SauceLabs.

[Link]
Web Automation -
Selenium
- Grouping.
- Parallel Execution.
- Running on Grid.
- Reports.
- Config Properties.

[Link]
[Link]
[Link]
[Link]
Playwright Self
Added(Pom)
Key features of Web Automation Framework used :

● Page Object Model (POM)


● Java : most convenient programming language.
● Maven: For build management purpose, a common structure
can be maintained very easily
● TestNG: Open source, most used Testing Framework, Amazing
annotations
● Allure Reports : As it is most clean automation reports and
provides lots of useful annotations as well. For better
documentation, it has been chosen over other reporting tools
● Parallel Execution with Groupings
● Supports Cloud Testing Services like BrowserStack,
SauceLabs.

[Link]
API Testing Projects
Manual + Automation

[Link]
Manually Testing the APIs
● End to End Life Cycle of STLC from Req. to Test EXECUTION
● LIVE Manually Testing an APIs
● 4x Examples of Real World Projects
● Quizz AND Interview Prep

[Link]
Key features of API Automation
Framework used
Key features of REST API Automation Framework used : (Supports SOAP(xml) also)

● Cucumber BDD
● Java : most convenient programming language.
● Maven: For build management purpose, a common structure can be maintained very easily
● TestNG: Open source, most used Testing Framework, Amazing annotations
● Allure Reports : As it is most clean automation reports and provides lots of useful annotations as well.
For better documentation, it has been chosen over other reporting tools
● Lombok plugin : It provides very simple logging framework as compared to other logging methods
● HTTP Methods Wrappers available.
● Support to GraphQL (in future)
● JSON Payload easy support.

[Link]
[Link]
Cucumber BDD + Rest
Assured

[Link]
CI/CD

[Link]
TheTestingAcademy Mobile
Automation Framework

[Link]
Resume Building
● Creating a Resume that works
● Help in Job finding and research
● LinkedIn methods to research jobs for Automation
Tester
● Tips and Tricks to get more HR Call

[Link]
Written Notes, (Recordings 24x7)

[Link]
Access to 24x7 LMS

Quiz
Assignments

[Link]
Doubt Session & Group
Discussion

[Link]
Curated Jobs,
Passing Resume to HRs

● Updated Curated Jobs Share


● Reference of Alumni if
possible
● Circulating Resumes within
peers
● References

[Link]
Mock Interview Prep
● Discussion on How to Crack QA
Interview
● How to Prepare for Interview ?
● Tips and Tricks which helped me to
crack QA Interview
● Things you should avoid in QA Interview

[Link]
Certificate of Completion!!

[Link]
TOTAL VALUE
~92,000 (with ai)
- Learn Java from ZERO exp.
- 3-4 Month - LIVE Course worth Rs 45,000
- 5+ Bonus (Manual Course + API Testing
Course) - Rs - 15,000
- SDET Club Access Lifetime. - Rs - 5,999

[Link]
Price Rs 9999
27th APRIL, 9 am to 12 PM (Sat & Sun)
Total Time - 6 Hours per Week
Friday - Doubt (Bi Weekly) - 8 PM -
LIVE Classes*
java
- 3-4 Month - LIVE Course (
- Access to Previous Batch
- Playwright with Java Course*
- 5+ Bonus (Manual Course + API
Testing Course)
- SDET Club Access Lifetime. [Link]

[Link]
Special Class Coupon
Discount: PROMODE

[Link]
[Link]
Price Rs 9999
LIVE Class

- 1 Month - LIVE Course


- Access to Previous Batch
- Playwright with Java Course. java
- 5+ Bonus (Manual Course +
API Testing Course)
- SDET Club Access Lifetime.

[Link]
[Link]
Testimonials

[Link]
BONUS -
Playwright with Java for Web
Automation Testing + API
Testing(+UI)

Rs 5,999, Self PACED


Will be Release on APR End.

[Link]
World it be worth it?
Get into a Single course Teaching you
Manual + API + Web Automation
Give you access to [Link] with
4500+ QA?
Lifetime Access and Masterclasses
weekly
Learn from a person 12+ Year Cracked Multiple
companies
[Link]
Important

[Link]
EMI

[Link]
Important

[Link]
Testimonials

[Link]
How can I help?

[Link]

[Link]
[Link]

How can I help?


[Link]

[Link]

Special Class Discount:


PROMODE

[Link]
Thanks, for attending Class

I hope you liked it. Say Thanks


in Comment :)

[Link]

You might also like