Back to Browse

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

5.4K views
May 22, 2022
1:51:15

Strings: String is a sequence of characters Strings are immutable (Cannot be changed) Two strings can be combined by using a + operator String Methods: s1.length - Returns the length of string s1.toUpperCase - Converts the string to upper case s1.toLowerCase - Converts the string to lower case s1.indexOf - Returns the position of specified characters in a string s1.charAt - Returns the character at specified index s1.equals - Compares two strings s1.trim - Removes white space from both ends of a string 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: Standard Input -This is used to accept input from the user keyboard and represented as System.in Standard output - This is used to output the data to the console and represented as System.out Standard Error - This is used to output the error to the console and represented as System.err 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 To enquire more about Selenium Java Trainings, please contact us at [email protected]

Download

0 formats

No download links available.

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