Monday, May 15, 2017

Linux Interview Questions

Linux Interview Questions

What is awk?
awk (also written as Awk and AWK) is a utility that enables a programmer to write tiny but effective programs in the form of statements that define text patterns that are to be searched for in each line of a document and the action that is to be taken when a match is found within a line.
What is SED?
sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file, or input from a pipeline). ... But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
Stream EDitor is used to perform basic transformations on text read from a file or a pipe. The result is sent to standard output. The syntax for the sed command has no output file specification, but results can be saved to a file using output redirection.
What is the use of cat command in Unix?
UNIX Basic commands: cat. The cat command reads one or more files and prints them to standard output. The operator > can be used to combine multiple files into one. The operator >> can be used to append to an existing file.
#cat proc/cpuinfo //gives the cpu info or  
#dmidecode also gives the cpu info
#cat proc/meminfo //gives the mem info
What is the grep?
grep is a command-line utility for searching plain-text data sets for lines matching a regular expression. Its name comes from the ed command g/re/p (globally search a regular expression and print), which has the same effect: doing a global search with the regular expression and printing all matching lines.
Diff between find and grep?
grep is used to search for string in a file
find is used to searche files or directories

Data Structures

WAP to implement Dynamic Stack


package com.java2novice.ds.stack;

public class MyDynamicStack {

    private int stackSize;
    private int[] stackArr;
    private int top;

    /**
     * constructor to create stack with size
     * @param size
     */
    public MyDynamicStack(int size) {
        this.stackSize = size;
        this.stackArr = new int[stackSize];
        this.top = -1;
    }

    /**
     * This method adds new entry to the top
     * of the stack
     * @param entry
     * @throws Exception
     */
    public void push(int entry){
        if(this.isStackFull()){
            System.out.println(("Stack is full. Increasing the capacity."));
            this.increaseStackCapacity();
        }
        System.out.println("Adding: "+entry);
        this.stackArr[++top] = entry;
    }

    /**
     * This method removes an entry from the
     * top of the stack.
     * @return
     * @throws Exception
     */
    public int pop() throws Exception {
        if(this.isStackEmpty()){
            throw new Exception("Stack is empty. Can not remove element.");
        }
        int entry = this.stackArr[top--];
        System.out.println("Removed entry: "+entry);
        return entry;
    }
 
    /**
     * This method returns top of the stack
     * without removing it.
     * @return
     */
    public long peek() {
        return stackArr[top];
    }

    private void increaseStackCapacity(){
     
        int[] newStack = new int[this.stackSize*2];
        for(int i=0;i<stackSize;i++){
            newStack[i] = this.stackArr[i];
        }
        this.stackArr = newStack;
        this.stackSize = this.stackSize*2;
    }
 
    /**
     * This method returns true if the stack is
     * empty
     * @return
     */
    public boolean isStackEmpty() {
        return (top == -1);
    }

    /**
     * This method returns true if the stack is full
     * @return
     */
    public boolean isStackFull() {
        return (top == stackSize - 1);
    }

    public static void main(String[] args) {
        MyDynamicStack stack = new MyDynamicStack(2);
        for(int i=1;i<10;i++){
            stack.push(i);
        }
        for(int i=1;i<4;i++){
            try {
                stack.pop();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}

Horton works

horton works


https://www.glassdoor.co.in/Interview/Hortonworks-QA-Automaiton-Engineer-Interview-Questions-EI_IE489054.0,11_KO12,34.htm


1) word sorting in a file 

2)kill process in remote servers. 
taskkill.exe/S SYSTEM /U USERNAME /P PASSWORD /IM PROCESS
eg: taskkill.exe /S wtn1 /U joe /P ddd1234 /PID 196
taskkill.exe /S wtn1 /U joe /P ddd1234 /PID 196 /F (forcefully terminate)
# pidof <processname> //gives the pidof process specified.
#kill -9 <pid of process> //-9 is special way of killing process.

3) Question about past experience on QA Automation and they asked details about QA Automaiton framework.



1)Java Code to print words in a file, and display in alphabetical order 

2)Better data structures that could be used & their time complexity 
3)Unix Questions on sed, grep, find 
4)Writing test cases for codes above 
5)Palndrome, String reversal code  


Mirror image of binary tree

Matrix row and column wise sorted find a given number
math related questions to be solved with equations
First unique word in the file
hashing a dictionary and designing the hash function
Binary search tree related ques and complexities and many more. Cannot recollect all  

Monday, May 1, 2017

Non-Tech


Why should we hire you?

Sample:
As you can see from my resume, I have the necessary qualifications and several years of experience, but that does not capture the unique advantages I can provide to the company. At my last job, I was given the opportunity to advance my skill set, even getting some experience with positions that were above my work level. I am confident that I can bring something to the table that no other candidate will.

N:
I have a skillset that matches your requirement and I continuously think on making things better and better.
I grow and let the team also grow which is pretty much required for any organization to grow.
These are the main qualities that any successful organization looks at.
Having said this, I have come to the current discussion with you clearing all the levels, it means that even your people think that I am right for this role.



What Is Your Biggest Regret And Why?


  • The hiring manager understands that everyone makes mistakes, so don’t worry about appearing perfect. Follow these tips to keep the interview running smoothly:
  • Do not use events of a personal nature in the interview.
  • Do not fail to show how a negative experience had a positive outcome.
  • Do not blame any past mistakes solely on others.
  • Avoid saying that you have no regrets.

  • Sample:Several years ago, my advertising team and I failed to land a large project from a major client. This particular individual had done some great work with us before, so I think we took it for granted that the client would choose our pitch. We didn’t put as much effort into researching the product and understanding the client’s needs, so frankly, she chose a better-prepared team. Since then, I make sure every project embodies professional excellence and dedication.

    N: Few years back I was managing a QA-Automation grp and my team, has to give a POC to existing customer whom I already know. I thought the earlier  relation, bidding, and the poc that my team has done will impress the customer. But it failed, reason behind the framework we developed requires good automation skills to maintain it. But on the other hand, they tried some other clients as well, they have shown BDD which doesnt require coding at all. So I feel this is the biggest regret, that I haven't read the customer well and was under assumption that with the relation we had, they will be satisfied with my POCs.


    Are you a leader or follower?

    N: It depends upon the task. If the task is completely new to me, I am a follower of a leader who better knows the subject than me. If I am expert in the task then, I am a leader.
    When a group needed a leader, I was more than capable of handling that role, but at the same time, I recognize when it is better to take a step back and take direction from someone who is more knowledgeable than I am.