filmov
tv
Basic To Advanced Selenium Java Full Course - Session 3 - Strings, Arrays, OOPs, Classes & Objects

Показать описание
Strings:
String is a sequence of characters
Strings are immutable (Cannot be changed)
Two strings can be combined by using a + operator
String Methods:
Arrays:
Array is a container object that can hold a fixed number of values of a single type
Length of the array can be defined during declaration and it will remain fixed
Each item in an array is called an element and each element can be accessed by its index
Methods in Arrays:
sort - Sorts the specified array in ascending order
toString - Returns a string representation of the contents of the
specified array
equals - Returns true if two specified arrays of int are equal to
one another
copyOf - Copies the specified array
length - Returns the length of the specified array
File & I/O:
A stream can be defined as a sequence of data. There are 2 types:
InputStream - It is used to read data from a source
OutputStream - It is used to write data to a source
Standard Streams:
FileInputStream It is used to read data from the files.
Class - Class is a user defined blueprint from which individual objects are
created.
Objects - Object is an instance of a class. All instances share the same attributes and behavior of class but values of the attributes are unique
Constructors:
Constructor initializes an object when it is created
It has the same name as the class and is very similar to a method except
they don’t have return type
If no constructor is defined for a class, then a default constructor is
automatically created by Java
Constructors are used to assign values to class variables at the time of
object creation
Constructor cannot be abstract, final or static
Two types of Constructors:
Default Constructor It has no parameters
Parameterized Constructor It has parameters
Access Modifiers:
They help to restrict the scope of a class, constructor, variable, method
or data member
Four types of access modifiers:
Default - When no access modifier is specified for class/method/members then it has default
access modifier. These can be only accessed within the same package
Private - Methods/data members declared as private are only accessible within the same class.
Any other class within the same package cannot access these members
Protected - Methods/data members declared as protected are only accessible within the same
package or subclasses in different package
Public - Methods/data members declared as public can be accessed from everywhere in the
program. No restriction on the public data members
Non Access Modifiers:
Static Modifier:
Static keyword is a non access modifier which can be used with variables, methods and blocks
Static member is shared across all instances of the class
Static methods belong to a class instead of the object, they can be called without creating the object of the class
Static keyword is mainly used for memory management
Static variables gets memory only once in the class area when it is loaded
Final Modifier:
Final keyword is a non access modifier used for classes, methods and variables
Whenever a variables is declared final, it’s value cannot be changed which means it is a constant
When a class is declared final, it cannot be inherited
When a method is declared final, it cannot be overridden by a derived class
OOPs:
OOPs is also known as Object Oriented Programming System
It is based on the concept of objects which can contain methods, variables and attributes
It has four basic concepts
Encapsulation
Inheritance
Polymorphism
Abstraction
Makes the code easier to maintain, modify and debug
Many programming languages support OOPs like C++, Java, Python
String is a sequence of characters
Strings are immutable (Cannot be changed)
Two strings can be combined by using a + operator
String Methods:
Arrays:
Array is a container object that can hold a fixed number of values of a single type
Length of the array can be defined during declaration and it will remain fixed
Each item in an array is called an element and each element can be accessed by its index
Methods in Arrays:
sort - Sorts the specified array in ascending order
toString - Returns a string representation of the contents of the
specified array
equals - Returns true if two specified arrays of int are equal to
one another
copyOf - Copies the specified array
length - Returns the length of the specified array
File & I/O:
A stream can be defined as a sequence of data. There are 2 types:
InputStream - It is used to read data from a source
OutputStream - It is used to write data to a source
Standard Streams:
FileInputStream It is used to read data from the files.
Class - Class is a user defined blueprint from which individual objects are
created.
Objects - Object is an instance of a class. All instances share the same attributes and behavior of class but values of the attributes are unique
Constructors:
Constructor initializes an object when it is created
It has the same name as the class and is very similar to a method except
they don’t have return type
If no constructor is defined for a class, then a default constructor is
automatically created by Java
Constructors are used to assign values to class variables at the time of
object creation
Constructor cannot be abstract, final or static
Two types of Constructors:
Default Constructor It has no parameters
Parameterized Constructor It has parameters
Access Modifiers:
They help to restrict the scope of a class, constructor, variable, method
or data member
Four types of access modifiers:
Default - When no access modifier is specified for class/method/members then it has default
access modifier. These can be only accessed within the same package
Private - Methods/data members declared as private are only accessible within the same class.
Any other class within the same package cannot access these members
Protected - Methods/data members declared as protected are only accessible within the same
package or subclasses in different package
Public - Methods/data members declared as public can be accessed from everywhere in the
program. No restriction on the public data members
Non Access Modifiers:
Static Modifier:
Static keyword is a non access modifier which can be used with variables, methods and blocks
Static member is shared across all instances of the class
Static methods belong to a class instead of the object, they can be called without creating the object of the class
Static keyword is mainly used for memory management
Static variables gets memory only once in the class area when it is loaded
Final Modifier:
Final keyword is a non access modifier used for classes, methods and variables
Whenever a variables is declared final, it’s value cannot be changed which means it is a constant
When a class is declared final, it cannot be inherited
When a method is declared final, it cannot be overridden by a derived class
OOPs:
OOPs is also known as Object Oriented Programming System
It is based on the concept of objects which can contain methods, variables and attributes
It has four basic concepts
Encapsulation
Inheritance
Polymorphism
Abstraction
Makes the code easier to maintain, modify and debug
Many programming languages support OOPs like C++, Java, Python