Sunday 2 May 2021

JAVA interview question SET-04 for SDET-AutomationQA - 2021?

 

Java Interview question Set-1:
SET-01 1-10

Java Interview question Set-2:

SET-02 10-20

Java Interview question Set-3:

SET-03 21-30


31. How to create a folder with the current timestamp in java?

Click Here For Answer

32.  How to insert ABCD in the 3rd index of string abcdefgh ?

                   StringBuilder sb1 = new StringBuilder("abcdefgh");

// StringBuilder insert(int indext, String whatToInsert)

System.out.println(sb1.insert(3, "ABCD"));// abcABCDdefgh

33.  What are superclass and subclass in Java?

Superclass and Subclass

A superclass is also referred to as a parent class or a base class.

A subclass is a child class, an extended class, or a derived class.

A subclass inherits accessible data fields and methods from its superclass and may also add new data fields and methods.

Inheritance is a relationship. E.g.:- A pineapple is a fruit

34. How to  Declare, Create, Initialize and loop around Array?

Click Here For Answer

35. What is an Array of Objects?

Before learning about array of Object do know about Array from this link:Click Here

The array of Objects means it stores an array of objects.  Array stores values like String, integer, Boolean, etc but an Array of Objects stores objects which means objects are stored as elements of an array. An array of Objects is not the object itself that is stored in the array but the reference of the object.
In an array of objects, we need to initialize each element of the array i.e. each object/object reference needs to be initialized.

Two ways to initialize the array of objects:

  1. By using the constructors
  2. By using a separate member method
  1. By using the constructors is the most used one and we will try to explore the same
//Declaring an array of person and Allocating memory for 3 objects of type person
                Person[] persons = new Person[3];

// to assign objects we would need to createInitializing the element of the array
                persons[0] = new Person(1, "test1");
persons[1] = new Person(2, "test2");
persons[2] = new Person(3, "test3");


// Creating a person class with id and name as a attributes
class Person {
int id;
String name;

  // person class constructor
    Person(int id, String name)
    {
        this.id = id;
        this.name = name;
    }
}

36. How to generate a random string for data usage in Project?

Click Here For Answer with Code

37. What is Finally in Java?

  • The code in the finally block is executed whether an exception occurs in the try block or whether it is caught.
  •       The finally block always executes when the try block exits.
  •       Java finally block follows try or catch block.
  •       Finally is also a reserved keyword in java.
  • ￿The syntax for the finally clause:



try { Statements;
}
catch (TheException ex) { 
handling ex;
}
finally { finalstatements;
}

38. What is MAP and how we traverse through Map?

Click Here For Answer with Code

39. What will be the output for the below Increment/Decrement Operators?

             Question:   int i = 25;
int j = ++i;
System.out.println(i + " " + j);
 Abswer: OUTPUT: 26 26
               Question: int  i = 25;
int j = i++;// i value(25) is assigned to j, then incremented to 26
System.out.println(i + " " + j);
Answer: OUTPUT: 26 25

40. How to define SINGLETON in java?

Click Here For Answer with Code

41.  How to integrate Maven project with Jenkins?

Maven & Jenkins Integration

42. How to install JDK and set Java Home path in Windows and MacOs ?

Click here for Steps


Java Interview question Set-1:
SET-01 1-10

Java Interview question Set-2:

SET-02 10-20

Java Interview question Set-3:

SET-03 21-30


*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions



No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...