Posts

Data Types in Java

Image
In Java, every variable and every expression has some type. Data type defines the values that a variable can take. Data types represent the different values to be stored in the variable. Each and every data type is clearly defined. Every assignment should be checked by compiler for type compatibility. Because of above reasons, we can conclude java language is strongly typed programming language. Java is not considered as pure Object Oriented Programming language because several OOPs features are not satisfied by Java like (Operator overloading, Multiple Inheritance etc..). Moreover, we are depending on primitive data types which are non-objects. Data Type Default Value Default size byte 0 1 byte short 0 2 bytes int 0 4 bytes long 0L 8 bytes float 0.0f 4 bytes double 0.0d 8 bytes boolean false 1 bit char '\u0000' 2 bytes 1) Primitive data types In Java, we have eight primitive data types: boolean, char, byte, short, int, long, float and double. Ja...

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...

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...