Day 1 - Start with the Fundamentals

Day 1 -  Start with the Fundamentals

  • Introduction to Java & Its Features
  • Java Virtual Machine (JVM)
  • Setting Up the JAVA Environment
  • Hello World Program in JAVA
  • Integrated Development Environments (IDEs) for JAVA

Java Programming Language

Java is one of the most popular and widely used programming languages.

  • Java has been one of the most popular programming languages for many years.
  • Java is Object Oriented. However, it is not considered as pure object-oriented as it provides support for primitive data types (like int, char, etc)
  • The Java codes are first compiled into byte code (machine-independent code). Then the byte code runs on Java Virtual Machine (JVM) regardless of the underlying architecture.
  • Java syntax is similar to C/C++. But Java does not provide low-level programming functionalities like pointers. Also, Java codes are always written in the form of classes and objects.
  • Java is used in all kinds of applications like Mobile Applications (Android is Java-based), desktop applications, web applications, client-server applications, enterprise applications, and many more.
  • When compared with C++, Java codes are generally more maintainable because Java does not allow many things which may lead to bad/inefficient programming if used incorrectly. For example, non-primitives are always references in Java. So we cannot pass large objects (like we can do in C++) to functions, we always pass references in Java. One more example, since there are no pointers, bad memory access is also not possible.
  • When compared with Python, Java kind of fits between C++ and Python. The programs are written in Java typically run faster than corresponding Python programs and slower than C++. Like C++, Java does static type checking, but Python does not.

 

Java programming language is named JAVA. Why?

After the name OAK, the team decided to give a new name to it and the suggested words were Silk, Jolt, revolutionary, DNA, dynamic, etc. These all names were easy to spell and fun to say, but they all wanted the name to reflect the essence of technology. In accordance with James Gosling, Java the among the top names along with Silk, and since java was a unique name so most of them preferred it.

Java is the name of an island in Indonesia where the first coffee(named java coffee) was produced. And this name was chosen by James Gosling while having coffee near his office. Note that Java is just a name, not an acronym.

Java Terminology

Before learning Java, one must be familiar with these common terms of Java.

1.  Java Virtual Machine(JVM):  This is generally referred to as JVM. There are three execution phases of a program. They are written, compile and run the program.

  • Writing a program is done by a java programmer like you and me.
  • The compilation is done by the JAVAC compiler which is a primary Java compiler included in the Java development kit (JDK). It takes the Java program as input and generates bytecode as output.
  • In the Running phase of a program, JVM executes the bytecode generated by the compiler.

Now, we understood that the function of Java Virtual Machine is to execute the bytecode produced by the compiler. Every Operating System has a different JVM but the output they produce after the execution of bytecode is the same across all the operating systems. This is why Java is known as a platform-independent language.

2. Bytecode in the Development process:  As discussed, the Javac compiler of JDK compiles the java source code into bytecode so that it can be executed by JVM. It is saved as .class file by the compiler. To view the bytecode, a disassembler like javap can be used.

3. Java Development Kit(JDK): While we were using the term JDK when we learn about bytecode and JVM. So, as the name suggests, it is a complete Java development kit that includes everything including compiler, Java Runtime Environment (JRE), java debuggers, java docs, etc. For the program to execute in java, we need to install JDK on our computer in order to create, compile and run the java program.

4. Java Runtime Environment (JRE): JDK includes JRE. JRE installation on our computers allows the java program to run, however, we cannot compile it. JRE includes a browser, JVM, applet supports, and plugins. For running the java program, a computer needs JRE.




String Manipulation Interview questions?

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

String concat,replace, substring, trim, lowercase, uppercase? Selenium, Automation core java interview questions?


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

public class StringManipulation {

    public static void main(String[] args) {
        // Strings are immutable
        String str3 = "java";
        str3.concat("oops");
        System.out.println(str3); // java

        // The result should be assigned to a new reference variable (or same
        // variable) can be reused.
        String concat = str3.concat("value2");
        System.out.println(concat); // value1value2

        // -----------------------String methods-------------------------------------
        String str = "abcdefghijk";

        // char charAt(int paramInt)
        System.out.println(str.charAt(2)); // prints a char - c

        // String concat(String paramString)
        System.out.println(str.concat("lmn"));// abcdefghijklmn

        System.out.println("ABC".equalsIgnoreCase("abc"));// true
        System.out.println("ABCDEFGH".length());// 8

        // String replace(char paramChar1, char paramChar2)
        System.out.println("012301230123".replace('0', '4'));// 412341234123

        // String replace(CharSequence paramCharSequence1, CharSequence
        // paramCharSequence2)
        System.out.println("012301230123".replace("01", "45"));// 452345234523

        // All characters from index paramInt
        // String substring(int paramInt)
        System.out.println("abcdefghij".substring(3)); // defghij
        // 0123456789

        // All characters from index 3 to 6
        System.out.println("abcdefghij".substring(3, 7)); // defg
        // 0123456789

        System.out.println("ABCDEFGHIJ".toLowerCase()); // abcdefghij

        System.out.println("abcdefghij".toUpperCase()); // ABCDEFGHIJ

        System.out.println("abcdefghij".toString()); // abcdefghij

        // trim removes leading and trailings spaces
        System.out.println(" abcd  ".trim()); // abcd
    }
}
 

___________________________________________________________________

What we know about the "STRING"?

 

MCQ on String for concepts and interview preparation QAE - SDET - AUTOMATION QA 2022


1. What is the output for below?

String str1 = "test";
String str2 = "one";

String str3 = str1.concat(str2);


Ans:

a) testone

b) test

c) one

d) Let me check in IDE :)


2. What is the output for below?

String str1 = "test";
String str2 = "test";

String str3 = new String("test");


System.out.println(str1.equals(str2));

System.out.println(str1.equals(str3));


Ans:

a) true,true

b) false, true

c) false, false

d) Let me check in IDE :)


3. What is the output for below?

String str1 = "test";

String str2 = "test";

String str3 = new String("test");


System.out.println(str1==str2));

System.out.println(str1==str3);


a) true, true

b) true, false

c) false, true

d) false, false


4. What is the output for below?

String str = "test";

System.out.println(str1.charAt(2)); 


a) s

b) e

c) error

d) es


5. What is the output for below?

System.out.println("012301230123".replace(55, "45"));

 System.out.println("012301230123".replace("01""45"));


a) compile error, 452345234523

b) 452345234523, 452345234523

c) error, error

d) Let me check in IDE :)


6. What is the output for below?

System.out.println("tes".substring(3));

System.out.println("test".substring(3));



a) error, error

b) error, t

c)  , t

d) t, t


7. How many ways we can create String Object in Java?


a) String s = "abc"; String s1 = new String("abc");

b) Literal, Keyword

c)  Both A and B

d)  Not sure


8. Is String thread safe?


a) true

b) false

c) Not sure


9. What is the output for below?

String str8 = new StringBuilder("test").reverse().toString();

System.out.println(str8);


a) test

b) tset

c) Not sure


10. Which one is thread safe: StringBuffer or StringBuffer ?


a) Both

b) StringBuffer

c) StringBuilder

d) None of the options




Below are the answers for all the questions on STRING:


1. a)testone


2. a)true,true

3. b)true, false

4. a)S

5. a) compile error, 452345234523

6. c)  , t

7. c)  Both A and B

8. a) true

9. b) tset

Top 21 GIT Interview Questions and Answers for SDET - DevOps - Automation QA


How to Switch to previous branch:

Ans: git switch @{-1}

How to create repository in bitbucket and push code for automation project?
Ans: Below are the sequence of commands to use:

First go to your bitbucket path and get access to create repository.
Create a repository with a self defined name, let name is "Automaters"
Then open cmd in the laptop where you have kept your automation project
cd existing-project
git init
git add --all
git commit -m "InitialCommit"
git remote add origin "https://path....Automaters.git"
git push -u origin master

If you get SSL certificate error to push then use below:

git config --global http.sslVerify false

How to Push a local branch for the first time:
Ans: git push --set-upstream origin <branch>

How to Push a local branch to a different remote branch:
Ans: git push origin <local_branch>:<remote_branch>

How to undo commits?
AnsThe following command will undo your most recent commit and put those changes back into staging, so you don't lose any work:
$ git reset --soft HEAD~1
The next one will completely delete the commit and throw away any changes. Be absolutely sure this is what you want:
$ git reset --hard HEAD~1

Fetch changes from both origin and upstream in the same shot:
Ans: git fetch --multiple origin upstream

How to Delete a remote branch on origin:
Ans: git push origin : <remote_branch>

Difference between rebase and merge?
Ansgit merge apply all unique commits from branch A into branch B in one commit 
 git rebase gets all unique commits from both branches and applies them one by one.
 git rebase rewrites commit history but doesn't create extra commit for merging.

Unstash those changes and bring them back into your working directory
Ans: git stash pop

Difference between soft, mixed, and hard resets?
Ans: --soft: Uncommit changes but leave those changes staged
--mixed (the default): Uncommit and unstage changes, but changes are left in the working directory
--hard: Uncommit, unstage, and delete changes

Listing the existing tags in Git is straightforward
Ans: $ git tag

How to create tag?
Ans: git tag <tagname>

Command to delete the file from your working directory and stages the deletion?
Ans: git rm [fileName]

Unstash your changes without popping them off the stack.
Ans: git stash apply

How to know about the history?
git log
To know more about git log : https://git-scm.com/docs/git-log

How to know all the details of changes to a commit?
git show <commitID>
To know more about git show : https://git-scm.com/docs/git-show
 
How to know the last commit details and see a log where each commit is one line?
To know the last commit details : git log -1
see log each commit in one line: git log --pretty=oneline

What git add and git commit command does
Git add--> add the changes to index area
Git commit--> add changes to local repo

How to compare two branch in GIT?
git diff branch1...branch2

How to view current state and any merge conflits?
git status
    The git status command displays the state of the working directory and the staging area.

How to undo last commit and rewrite history?
git reset --hard HEAD~1
 
Difference between soft, mixed, and hard resets?
--soft: Uncommit changes but leave those changes staged
--mixed (the default): Uncommit and unstage changes, but changes are left in the working directory
--hard: Uncommit, unstage, and delete changes

How to reset a file back to how it was before changes?
git restore <filename>     # new syntax (as of Git 2.23)
git checkout -- <filename> # old syntax

How to unstage changes or restore files?
Maybe you accidentally staged some files which we don't want to commit.
git restore test.js
git restore .
Git Official Docs

Top 10 tech skills that are a must to hit in 2021

Required technical skills that can boost your career in 2021 and beyond.

The world of technology continues to change rapidly. The demand for professionals with advanced skills IT has never been higher.

With technology roles dominating the "best jobs" or "most in-demand" lists of the future, we're looking at some of the most in-demand tech skills of 2021 that will help increase demand in the tech market and your value as an employee.

 

Cybersecurity is one of the hottest technology trends in 2020 due to the importance of companies that collect customer and user information to keep their networks safe from attacks.

A The shortage of cybersecurity skills among professionals IT has created a sought-after market for those with skills in cybersecurity, information security, network security, and vulnerability assessment skills.


DevOps professionals have revolutionized the way businesses meet the growing demands of their customers and the best DevOps professionals are those that are able to work with other areas across the business.

Being able to speed up processes and development cycles all while maintaining a high degree of accuracy and not compromising on security is what talented DevOps professionals are all about.



Easy steps to create Requirement Traceability Matrix (RTM)

A Traceability Matrix is a document that co-relates any two-baseline documents that require a many-to-many relationship to check the completeness of the relationship.
It is used to track the requirements and to check the current project requirements are met.



Advantages of Requirement Traceability Matrix (RTM):
  1. Gives Overview of ALL the requirements
  2. Shows how requirements are linked to Test Cases
  3. Makes sure 100% coverage of requirements
  4. Easy to prepare
  5. No special tool is required

How to prepare Requirement Traceability Matrix (RTM):
  1. Get all available requirement documents. For eg. Business Requirement Document(BRD), Functional Requirement Document(FSD), Technical Requirement Document(TSD)
  2. First list down All the requirements from BRD one by one with requirement ID#
  3. Now go to FSD, and list all respective functional requirements for each Business Requirements
  4. Open Test Scenario or Test Case document and link available TC IDs to respective Functional Requirements
Let’s take an example:

Business Requirement Document (BRD) :


This document is provided by the Client with high-level business Requirements. Suppose for Flight Booking Application it shows below 2 requirements
BR_1  Reservation Module :
It should allow the user to book one or more tickets, one way or a round way for future dates
BR_2  Payment Module:
User should able to make payment for booked tickets via Credit / Debit Card or through Reward Points

Functional Specification Document (FSD) :

This document is prepared by the Technical team which further elaborate business requirements into functional requirements that can be implemented in software.
Suppose above 2 business requirements in BRD have more detailed functional requirements:
BR_1  Reservation Module :
  • FR_1 : One Way Ticket booking
    • It should allow user to book one-way ticket
  • FR_2 : Round Way Ticket
    • It should allow user to book round way ticket
  • FR_3: Multicity Ticket booking
    • It should allow user to book one way or round way ticket for multiple cities
BR_2  Payment Module:
  • FR_4: By Credit Card
    • It should allow user to make payment by Credit Cards
  • FR_5 By Debit Card
    • It should allow user to make payment by Debit Cards
  • FR_6 By Reward Points
    • It should allow user to make payment by Reward Points

And you have written some test cases or test scenarios for each functional requirement.
   
So if we prepare simple Requirements Traceability Matrix (RTM) for the above example it would like as below:
Requarements Treaceability Matrix
You can also add Execution Status and Defects columns in RTM to view the overall status of all requirements along with Test Cases.