Write a Java program to find whether given number is Armstrong or not
Armstrong numbers are: 153, 370, 371, 407
Definition: We call a given number as Armstrong if it is equal to the sum of the powers of its own digits.
Ex: abcd...n => pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + .... =abcd...n
Answer:
package seleniumrepo;
import java.util.Scanner;
class ArmstrongNumber{
public static void main(String args[]){
...
Tuesday, January 29, 2019

Based on the type of data stored, data types are classifying as 3 types in Java.
Primitive Datatype (Fundamental Datatype):
Derived Datatype
User Defined Datatype
Primitive Datatype (Fundamental Datatype):
The datatype which stores only single value is Primitive datatype. Primitive datatypes are also known as fundamental datatypes. In java programming language,...

Difference between White Box Testing and Black Box Testing:
WBT: This is defined as method of testing in which one can perform testing on an application having internal structural knowledge of it. This is also known as Glass Box Testing.
This testing focuses on the structural part of an application and hence the Developers are involved in this type of testing.
BBT: This...
Monday, January 28, 2019
Sunday, January 27, 2019

we cannot iterate a Map directly using iterators, because Map are not Collection.
There are different methods to iterate through MAP elements:
Method 1: Using Iterator and keySet().
package seleniumrepo;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class TestIterator {
public static void main(String[] args) {
...
a. prime or not
Prime number: A prime number is a whole number greater than 1 whose only factors are 1 and itself.
Ans:
---
public class PrimeTest {
public static void main(String[] args) {
int n, i, k=0;
System.out.println("Enter a positive integer: ");
Scanner sc = new Scanner(System.in);
n=sc.nextInt();
...
Saturday, January 26, 2019
/*
* Input: A14BC654 -> acceptable
* Input: AB54C54D -> not acceptable
* Input: A23BED75 -> acceptable
* Conditions to check:
* 1) First and Last index values of the string are character and digit respectively
* 2) If condition 1 is satisfies it prints last number value of the string. For example, the value 654 if we pass first String, should print 75 if we pass 3rd string.
* Note: 2nd string fails in 1st condition...
Monday, January 21, 2019
Saturday, January 19, 2019

Palindrome Number: A Palindrome number is a number that remains the same when its digits are reversed.
We get total 90 numbers between 100 and 1000.
public class PalindromeNumber {
public static void main(String[] args) {
int n=121;
int rev=0;
int temp=n;
while(n!=0){
rev=rev*10+n%10;
n=n/10;
}
if(temp==rev){
System.out.println(temp+" Is Palindrome");
...
Thursday, January 17, 2019

All are used to mark a field in a page object.
@FindBy: It is an alternative mechanism for locating the element or a list of elements. Used in conjunction with PageFactory this allows users to quickly and easily create PageObjects. (api link)
Example:
For example, these two annotations point to the same element:
Syntax 1: ...
MySQL:
Sub queries in SQL are great tool for this kind of scenario, here we first select maximum salary and then another maximum excluding result of subquery
mysql> SELECT max(salary) FROM Employee WHERE salary NOT IN (SELECT max(salary) FROM Employee);
using subquery and < operator instead of IN clause:
mysql> SELECT max(salary) FROM Employee WHERE salary < (SELECT max(salary) FROM Employee);
Oracle:
using ROW_NUMBER
select * from...

A Project Object Model or POM is the fundamental unit of work in Maven. It contains the project configuration details used by Maven.
Some of the configuration that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on.
The minimum requirement for a POM are the following:
project root
modelVersion...

public static void main(String[] args){} or public static void main(String... args){}:
Java main method is the entry point of any java program. Its syntax is always "public static void main(String[] args)". You can only change the name of String array argument.
public: This is an access modifier means this method can be accessed anywhere.
static: The main() method can...

Why not List<String> listString = new ArrayList<String>();
You can assign an ArrayList<String> to a List<String> reference variable, but you can never assign an object with one generic type to an object with another generic type, no matter what inheritance there is.
Above code gives compile time Error "Type mismatch: cannot convert from ArrayList<String>...
Wednesday, January 9, 2019
Tuesday, January 8, 2019
Sunday, January 6, 2019

Both Iterator and Iterable are interfaces in Java Collection Framework. Here are some differences:
Iterator: Iterator is an interface that manages iteration over an Iterable. It maintains a state of where we are in the current iteration, and knows what the next element is and how to get it. See API here
Iterator lets you check if it has more elements using hasNext()...

Both are interfaces in Java. Here some common differences between Comparator and Comparable.
Comparator in Java is defined in java.util package while Comparable interface in Java is defined in java.lang package.
Comparator has the method int compare(T o1,T o2) which compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the...

It is very frequently asked interview question for me. I was no answer as till now we know only we need drivers( like chromedriver.exe, geckodriver.exe, IEDriverServer.exe) and pass them to the System.setProperty() to launch a browser using selenium web driver. But why?
Reason:
As selenium WebDriver has no native implementation of a browser, we have to direct all the...
Friday, January 4, 2019

Difference between HashMap and ConcurrentHashMap:
ConcurrentHashMap is thread-safe that is the code can be accessed by single thread at a time. while HashMap is not thread-safe
HashMap can be synchronized by using synchronizedMap(HashMap) method. By using this method we get a HashMap object which is equivalent to the HashTable object. So every modification is performed...
Thursday, January 3, 2019
Java API provides foreach() method since jdk1.8v.
This method traverses each element of the collection until all elements have been Processed by the method or an exception is raised.
Exceptions thrown by the Operation are passed to the caller.
foreach() is defined as default method in Iterable interface and overiden in ArrayList and Arrays classes.
(Note: interface allows default and static keywords since jdk1.8v)
Implementation in ArraList:
ArrayList...

Static is a keyword in Java, which is used for
static blocks
variables
methods and
inner classes or nested classes
A static member can be accessed directly with the class name with out creating an object.
The value of the static variable is shared by all objects of a class means same set of copy available to all the objects.
If any variable is modified...
Subscribe to:
Posts (Atom)