Automation Testing - Part 2 (Things to know in JAVA)
Author: Mr. Ankit Prajapati
Below Topics are Covered:
What is Java?
What make Java so popular?
Class, Objects & Method
Interface & Package
Modifiers
OOPS Concept
Software Learning Tutorials - SLT ...!!!
2. Agenda
What is JAVA?
What make JAVA Popular?
Class, Object & Method
Interface & Package
Modifiers
OOPS Concepts
References
Software
Learning
Tutorials !!!
3. What is JAVA ?
Software
Learning
Tutorials !!!
Java is a programming language that produces software for
multiple platforms.
Java derives much of
its syntax from the C
and C++
programming
languages.
It was first released by
Sun Microsystem in
1995 and later acquired
by Oracle Corporation
Java platform includes an
execution engine, a
compiler, and a set of
libraries.
4. What make JAVA Popular ?
Software
Learning
Tutorials !!!
JAVA
OOPS
High
Performance
Secure
Robust
Platform
Independent
Multi
Threaded
5. Class – Object – Method
Software
Learning
Tutorials !!!
Class is a user defined
blueprint or prototype from
which objects are created.
Object is an instance of Class.
States & Behaviours
Method is a collection of
statements that are grouped
together to perform an operation
To be continued…!!!
7. Interface & Packages
Software
Learning
Tutorials !!!
To be continued…!!!
Interface: An interface is just like Java Class, but it only
has static constants and abstract method.
A class implements an interface, thereby inheriting the
abstract methods of the interface.
Package as the name suggests is a pack (group) of
classes, interfaces and other packages.
In java we use packages to organize our classes and
interfaces
8. Interface & Abstract Class
Software
Learning
Tutorials !!!
To be continued…!!!
Java uses Interface to implement multiple
inheritance.
A Java class can implement multiple Java
Interfaces.
Class contains ‘Abstract’ keyword.
If a class is declared abstract, it cannot be
instantiated, which means you cannot
create an object of an abstract class.
Abstract Class Interface
An abstract class can extend only one
class or one abstract class at a time.
An interface can extend any number of
interfaces at a time.
An abstract class can extend another
concrete (regular) class or abstract class.
An interface can only extend another
interface.
An abstract class can have both abstract
and concrete methods.
An interface can have only abstract
methods.
An abstract class can have protected and
public abstract methods
An interface can have only have public
abstract methods
10. Package
Software
Learning
Tutorials !!!
import java.util.Scanner
Here:
→ java is a top level package
→ util is a sub package
→ Scanner is a class which is present in the sub package util
Reusability: While developing a project in java, we often feel that there
are few things that we are writing repeatedly in our code.
Better Organization: In large java projects where we have several
hundreds of class.
Name Conflicts: We can define two classes with the same name in
different packages so to avoid name collision.
To be continued…!!!
12. Modifier
Software
Learning
Tutorials !!!
Modifiers are keywords that you
add to those definitions to
change their meanings. Java
language has a wide variety of
modifiers.
Access Modifiers: Default, Private, Protected, Public
Non-Access Modifiers: Static, Final, Abstract
Access Layer Default Private Protected Public
Same Class Yes Yes Yes Yes
Same Package – Sub Class Yes No Yes Yes
Same Package – Non Sub Class Yes No Yes Yes
Different Package – Sub Class No No Yes Yes
Different Package – Non Sub Class No No No Yes
14. OOPS - Inheritance
Software
Learning
Tutorials !!!
Inheritance means accessing one-class properties from another class.
Class C Class D
Class B
Class A
Class C
Class D
Class B
Class A
Single
Inheritance
Hierarchical
Inheritance
Multiple
Inheritance
Valid by Both: Class & Interface Invalid by Class, Valid by Interface
15. OOPS - Encapsulation
Software
Learning
Tutorials !!!
Encapsulation is a mechanism where you bind your data and code together as a single unit
VariablesMethodsClass
Encapsulation
We can achieve encapsulation in Java by:
Declaring the variables of a class as private.
Providing public setter and getter methods to modify and view the variables values
16. OOPS - Abstraction
Software
Learning
Tutorials !!!
Abstraction is the process in Java used to hide certain details and only show the essentials
features of the objects.
Abstract Class Interface