Posts

Showing posts from March, 2018

Explain public static void main in Java

Image
Whether the class contains main method or not and whether main method is declared according to requirement or not these things won’t be checked by compiler. At Run time JVM is responsible to check these things. If JVM unable to find main method then we will get run time exception saying “No SuchMethodError: main” class Test { } Javac Test.java Java Test Runtime Exception: “No SuchMethodError: main” At Run time JVM always searches for the main method with the following prototype. public static void main (String[] args) public : public keyword is an access modifier which represents visibility, it means it is visible to all. To call by JVM from anywhere. This makes the main method public that means that we can call the method from outside the class. static : static is a keyword, if we declare any method as static, it is known as static method. The core advantage of static method is that there is no need to create object to invoke the static method. The main me

Java Naming Conventions

Image
Java naming convention is a rule to follow as you decide what to name your identifiers such as class, interface, package, variable, constant, method etc. They must be followed while developing software in java for good maintenance and readability of code. Java uses CamelCase as a practice for writing names. Camel case in Java Programming: It consists of compound words or phrases such that each word or abbreviation begins with a capital letter or first word with a lowercase letter, rest all with capital. 1. Classes and Interfaces : Class names should have  first letter uppercase and  first letter of each internal word capitalized . Interfaces name should also have  first letter uppercase  and  first letter of each internal word capitalized . This naming method is popularly called as UpperCamelCase . Ex:- Name, FirstName Examples: Interface  Bicycle Class MountainBike implements Bicyle Interface Sport Class Football implements Sport 2. Methods : Methods name sho

Reserve or Key Words in Java

Image
Any programming language reserves some words to represent functionalities defined by that language. These words are called Reserved words. These words can't be used as names for Variables, Methods, Class or any other Identifier. Keywords for Data Types (8): 1. byte 2. short 3. int 4. long 5. float 6. double 7. boolean 8. char Keywords for Flow control (11): 1. if 2. else 3. switch 4. case 5. default 6. while 7. do 8. for 9. break 10. continue 11. return Keywords for Modifiers (11): 1. public 2. private 3. protected 4. static 5. final 6. abstract 7. synchronized 8. native 9. strictfp (came in 1.2 version) 10. transient 11. volatile Keywords for Exceptional Handling (6): 1. try 2. catch 3. finally 4. throw 5. throws 6. assert (came in 1.4 version) Keywords for Class Related (6): 1. class 2. interface 3. extends 4. implements 5. package 6. import Keywords for Object Related (4

Rules for defining Java Identifiers

Image
Before we go through the Rules for defining Java Identifiers, if you are not aware with what is Java Identifiers you can check out here  Java Identifiers There are certain rules for defining a valid java identifiers. These rules must be followed, otherwise we get compile-time error. These rules are also valid for other languages like C,C++. 1. Only allowed characters for identifiers are all alphanumeric ([a to z],[A to Z],[0 to 9]) and '$' dollar sign and '_' underscore sign. 2. Identifiers should not start with digits([0-9]). For example “123geeks” is a not a valid java identifier. 3. Java identifiers are case-sensitive. ( Example - number, Number, NUMBER) 4. There is no limit on the length of the identifier but it is advisable to use an optimum length of 4 – 15 letters only. 5. Reserved Words can’t be used as an identifier. For example “int while = 20;” is an invalid statement as while is a reserved word. There are 53 reserved words in Java. Valid Ja

Java Identifiers

Image
In programming languages, identifiers are used for identification purpose. In Java an identifier can be a Class name, Method name, Variable name or a Label . For Example , public class Test { public static void main(String[] args) { int x = 10; } } In the above Java code, we have 5 identifiers: 1. Test - Class name 2. main - Method name 3. String - Predefined Class name 4. args - Variable name 5. x - Variable name Happy Learning !

What is the Best Way to learn SELENIUM?

Image
I continuously see newbie questions like: "How I do I learn Selenium?", with little or no other context given. So first... a clarification : Selenium WebDriver is a system for automating browser interaction. It is accessed via programming library/API. If you want to use it without touching code, it is not possible (record/replay/export-madness via IDE aside). You can abstract away most of the programming aspects with higher level frameworks, but at that point you are no longer really dealing with Selenium anymore. Selenium (WebDriver) provides language bindings and a similar API for several programming languages. It gives you a programming library that can manipulate a browser and web elements/controls. You can't "learn" a library for a programming language if you don't know the language itself (syntax, idioms, etc). So, my question to you: Which programming language are you going to use Selenium with? If you define that, someone can surely hel

OOPs concepts in Java with Examples

Image
Object Oriented programming is a programming style which is associated with the concepts like  Class Object Inheritance Encapsulation Abstraction Polymorphism It's based on the concept of “objects” that contain data and methods. It works on the principle that objects are the most important part of your program.  It allows users to create the OBJECTS that they want and then create METHODS to handle those objects.  Manipulating these objects to get results is the goal of Object Oriented Programming. Simula is considered as the first object-oriented programming language. Smalltalk is considered as the first truly object-oriented programming language. Programming languages can be classified into 3 primary types: A. Unstructured Programming Languages: The most primitive of all programming languages having sequentially flow of control. Code is repeated through out the program B. Structured Programming Languages: Has non-sequentially flow of control. Use of

What is TESTING ?

Image
Testing  =  Verification  ( Static Testing )  +   Validation   ( Dynamic Testing )  " Testing  is the process of  Verifying  are we developing the right product or not and also  Validating  does the developed product is right or not"  OR in more Simpler words:- TESTING  is the process of  finding   or  identifying  or  searching  or  catching  or  preventing   defects. Now the question is what do you mean by  Software testing  ? or Hardware testing, Mobile testing, Pen testing, Machine testing?? Software Testing  is the process of  finding  or  identifying  or  searching  or  catching  or  preventing   defects  in the software .     Hardware Testing  is the process of  finding  or  identifying  or  searching  or  catching  or  preventing   defects  in the hardware . Mobile Testing  is the process of  finding  or  identifying  or  searching  or  catching  or  preventing   defects  in the mobile .  Pen Testing  is the process of  finding  or

Test Automation Design Patterns - Page Object Model (POM)

Image
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in  software design . It is a description or template for how to solve a problem that can be used in many different situations. Design patterns are formalized  best practices  that the programmer can use to solve common problems when designing an application or system. List of Design Patterns are:- Ø Page Object Ø Page Factory Ø Singleton Ø Four Phase Test Ø Builder Ø Factory Ø Abstract Factory   Page Object Model using Selenium Web driver           Page Object Model (POM) is just a design pattern, not a framework. What is Page Object Model (POM)? ·       Page Object Model is a design pattern to create Object Repository for web UI elements. ·       Under this model, for each web page in the application, there should be corresponding page class. ·       This Page class will find the WebElements of that web