Top 5 sql interview questions and answers

Top 5 sql interview questions and answers

What is DDL, DML, DCL, TCL in SQL ?

DDL refers to Data Definition language. DDL is used to create/modify the structure of Database. e.g. CREATE, ALTER, DROP statement..

DML refers to Data Manipulation language. DML is used to retrieve, modify, delete, insert and update data in database. e.g. SELECT, UPDATE, INSERT statement

DCL refers to Data Control Language. DCL is used to create roles, permissions, and control access to database. e.g. GRANT, REVOKE statement.

TCL refers to Transactional Control Language. TCL is used to manage different transactions occurring within a database. e.g COMMIT, ROLLBACK statement

What is the difference between UNION vs UNION ALL?

          UNION and UNION ALL are used for merging two tables which has similar structure.

the difference between UNION and UNION ALL is that the UNION removes the duplicates while merging tables but UNION ALL do not and retain all duplicates.

UNION is slower in performance  as it has additional task of removing duplicates which causes more time in  execution.

What is the difference between query and subquery?

A Query is a code written to fetch information from the database where as subquery is a query within another query.  Basically subquery is an inner query. SubQuery is designed to executed first. The result of subquery is passed on to the main query which then process using the subquery output.

What is a stored procedure?

Stored Procedure is a function having several SQL statements. Stored procedure can be executed to process all SQL statements in it.

What is the difference between WHERE clause and HAVING clause?

Both WHERE and HAVING are used for filtering out records based conditions. WHERE clause can only be applied for static non-aggregated column whereas HAVING for aggregated columns.
SELECT * FROM Cricketbat WHERE batlenght > 2 feet
SELECT COUNT(Cricketbat)
FROM Bat
GROUP BY Team
HAVING COUNT(Cricketbat) > 2 feet;

What is DELETE and TRUNCATE commands?

DELETE command is used to remove selected rows from a table. A WHERE clause can be used to specify the rows to be deleted

 

What is difference between select and select distinct

Top 5 Salesforce Interview questions

Top 5 Salesforce Interview questions

1. What is object in salesforce?

Objects are database tables used to store specific data. There are two types of objects. 1. Standard objects 2. Custom objects.

2. What are different types of relationship in salesforce?

There are two different types of relationship in salesforce.
1. Master detail relationship
2. Lookup relationship

3. What is a trigger in salesforce ?

A Trigger is a code that is executed before or after a record is inserted or updated.

4. How many reports can be added to salesforce dashboard ?

20

5. What is validation rule ?

While creating or modifying a record, based on certain conditions validation rule helps to display error message.

6. What are escalation rules in sales force?

Escalation rules can be created on sales force case object and based on priority escalation emails can be sent.

Top 20 sql interview questions and answers

Top 20 sql interview questions and answers

What is DDL, DML, DCL, TCL in SQL ?

DDL refers to Data Definition language. DDL is used to create/modify the structure of Database. e.g. CREATE, ALTER, DROP statement..

DML refers to Data Manipulation language. DML is used to retrieve, modify, delete, insert and update data in database. e.g. SELECT, UPDATE, INSERT statement

DCL refers to Data Control Language. DCL is used to create roles, permissions, and control access to database. e.g. GRANT, REVOKE statement.
TCL refers to Transactional Control Language. TCL is used to manage different transactions occurring within a database. e.g COMMIT, ROLLBACK statement

What is the difference between UNION vs UNION ALL?

          UNION and UNION ALL are used for merging two tables which has similar structure.

the difference between UNION and UNION ALL is that the UNION removes the duplicates while merging tables but UNION ALL do not and retain all duplicates.

UNION is slower in performance  as it has additional task of removing duplicates which causes more time in  execution.

What is the difference between query and subquery?

A Query is a code written to fetch information from the database where as subquery is a query within another query.  Basically subquery is an inner query. SubQuery is designed to executed first. The result of subquery is passed on to the main query which then process using the subquery output.

What is a stored procedure?

Stored Procedure is a function having several SQL statements. Stored procedure can be executed to process all SQL statements in it.

What is the difference between WHERE clause and HAVING clause?

Both WHERE and HAVING are used for filtering out records based conditions. WHERE clause can only be applied for static non-aggregated column whereas HAVING for aggregated columns.
SELECT * FROM Cricketbat WHERE batlenght > 2 feet
SELECT COUNT(Cricketbat)
FROM Bat
GROUP BY Team
HAVING COUNT(Cricketbat) > 2 feet;

What is DELETE and TRUNCATE commands?

DELETE command is used to remove selected rows from a table. A WHERE clause can be used to specify the rows to be deleted

What is TRUNCATE commands?

TRUNCATE is used for removing all rows from the table. Truncate operation cannot be reversed but but delete can be reversed/rollback.

What is Log Caches of SQL Server?

Log cache is a memory pool allocated to read/write the log pages. A group of cache pages are available in each log cache.

What is Inner join?

Inner join is used for returning rows when there is at least one match of rows between the tables used in the inner join query.

What is Full Join?

Full join is used for returning all the rows from the left side table and all the rows from the right side table.

What is Right Join?

Right join return all rows of Right hand side table and matched rows in left hand table. Non matched rows will show null values for left had side.
Simply, it returns all the rows from the right hand side table even though there are no matches in the left hand side table.

What is Left Join?

Left join return all rows of Left hand side table and matched rows in right hand table. Non matched rows will show null values for right hand side.

What are the SQL MAX() and MIN() Functions?

The MAX() function returns the largest value in the selected column.

The MIN() function returns the smallest value in the selected column.

SELECT MAX(Weight) AS LargestWeight

FROM CricketBats;

SELECT MIN(Weight) AS SmallestWeight

FROM CricketBats;

What are the SQL AVG(), COUNT() and SUM() Functions

The SQL AVG() function returns the average value in a numeric values column.

e.g.

SELECT AVG(Weight)

FROM Cricketbats;

The SQL COUNT() function returns the number of rows count that matches with a specified criteria.

SELECT COUNT(ProductID)

FROM Cricketbats;

The SQL SUM() function returns the total sum of a numeric values in a specific column.

e.g

SELECT SUM(Weight)

FROM Cricketbats;

What is SQL UPDATE Statement?

The SQL UPDATE statement is used for modifying the existing records in the selected table.

e.g as below:

UPDATE Users

SET UserContactName=’First name Last name’, City=’City1′

WHERE UserID=1;

What is SQL ORDER BY Keyword?

The purpose of ORDER BY keyword is to sort the results in ascending or descending order.

example for ascending order

SELECT * FROM Users

ORDER BY State ASC;

or

SELECT * FROM Users

ORDER BY State;

example for descending order

SELECT * FROM Users

ORDER BY State DESC;

What is a NULL Value in SQL?

NULL values can not be compared using operators =, <, or <> so we will need to use the “IS NULL” or “IS NOT NULL” operators instead.

SELECT UserName, UserContactName, Address FROM Persons

WHERE Address IS NULL;

SELECT UserName, UserContactName, Address FROM Persons

WHERE Address IS NOT NULL;

What is SQL INSERT INTO Statement?

The INSERT INTO statement is used for inserting new records to a table.

e.g.

INSERT INTO Users (UserName, UserContactName, UserAddress, City, ZipCode, State, Country)

VALUES (‘Test1′,’Firstname last name’,’address 1, 2,3 ‘,’City namer’,’99999′,’Statename’,’Countryname’);

What is SQL INSERT INTO SELECT Statement?

The SQL INSERT INTO SELECT statement is used for copying data from one table and then to insert to someother table.

e.g. as below:

INSERT INTO Users (UserName, UserCity, Country)

SELECT VendorName, VendorCity, Country FROM Vendors;

What is the SQL DELETE Statement?

The SQL DELETE statement is used for deleting the existing records in the selected table.

e.g as below:

DELETE FROM Users

WHERE UserName=’Firstname1 Lastname1′;

What is AND, OR and NOT Operators in SQL?

AND, OR, and NOT operators are combined with the WHERE clause to get the desired filtered results.

e.g

SELECT * FROM Users

WHERE State =’illinois’ AND City=’Chicago’;

SELECT * FROM Users

WHERE City=’Chicago’ OR City=’New York’;

SELECT * FROM Users

WHERE NOT State =’Chicago’;

What is SQL WHERE Clause?

SQL WHERE clause is used to filter records and its added as below

e.g.

SELECT States FROM Users where Usersgroup = ‘1’;

What is the SQL SELECT TOP Clause ?

The SELECT TOP clause is used to specify the number of records to return.

e.g as below:

SELECT TOP 100 * FROM Users;

How to send email at every build with Jenkins

How to send email at every build ?

Jenkins default configuration setting allows to send email notification for build failure, someone breaks the build etc.

  1. To send email for every build Install Email-ext plugin
  2. Once it is installed, click on Configure System
  3. Then in “Jenkins Location” section & “Extended E-mail Notification” – enter your email ids
  4. In “E-mail Notification” section, enter the SMTP server name to “SMTP server”
  5. Click “Advanced”, Click “Use SMTP Authentication” to enter required information
  6. verify “Test configuration by sending test e-mail”
  7. Configure a project to send email at every build
  8. Click “Add post-build action” and then Click “Editable Email Notification”
  9. Go to  “Advanced Settings” to “Add Trigger”
  10. then Click “Always” , Save

Jenkins reset user password

Jenkins reset user password :

First stop the Jenkins service if you are already running jenkins

Go to the folder where jenkin’s config.xml file is stored (generally C:\jenkins\.jenkins\config.xml)

Open config.xml file using notepad++ or any text editor

Search for <useSecurity>true</useSecurity> and change that to <useSecurity>false</useSecurity>, Save the file.

re-start Jenkins service (using Java -jar jenkins.war in commandline)

You should not be seeing login prompt but directly accessing jenkins home page when you type localhost:8080 in browser.

To run Jenkins locally click here

How to run selenium tests in jenkins

How to run selenium tests in Jenkins

Jenkins configuration:

To run selenium scripts in Jenkins, Jenkins needs to started.

To make Jenkins server start, please use the following command in the Jenkins folder of your machine when Jenkins.war file is downloaded from internet…

  1. “java -jar jenkins.war” in DOS / command prompt mode.
  2. Then you need to bring the browser up and type “localhost:8080” to see jenkins web UI ready.
  3. Then navigate to Jenkins >> Manage Jenkins and click on “Configure system”
  4. Then scroll down to see the “JDK installations” section in the pag
  5. There you enter “JAVA_HOME” for “JDK name” field.
  6. Provide the Java-JDK file folder path for “JAVA_HOME” field.

Note:  Java-JDK file folder path is usually “C:\Program files\Java\JDK….”

Note: Disable “Install Automatically” check box else it will update with new Java versions and your selenium program might get conflicts

Selenium script development:

  1. create a package and class in Eclipse
  2. and then create a small test script – like print some message based on UI or Browser title name etc
  3. you could create a TestNG project
  4. Then TestNG.xml file will be created in Eclipse

Note: to get the XML folder path in project home directory, you could go to Eclipse project and right click to see properties.

Note: you also need to put all the jar files required for selenium testing under the lib folder(you may need to create”lib” folder)

Just to test your TestNG scripts are working, you can navigate to Project home directly (XML located) through DOS/Command prompt and then type as below:

Note: before that you need to set class path as bin directory of Project home folder. Command : “set classpath=C:\Selenium\project\bin;” as an example for binary file

Note1: similarly lib files, Command : “set classpath=C:\Selenium\project\lib\*” as an example

or command: set classpath=C:\Selenium\project\bin;C:\Selenium\project\lib\*;

Then execute testng.xml file through command prompt

command : java org.testng.TestNG testng.xml

Batch file creation for Jenkin execution

Create a batch file using notepad – steps

  1. Type the below contents in Notepad without quotes.

‘ java -cp bi;lib/* org.testng.TestNG testng.xml ‘

2) save the notepad as “runSelenium.bat” which will create a bat file. Place it in project home directory.

Jenkins job creation:

  1. Open Jenkins, then click on “New item”
  2. Enter item name as “JenkinSeleniumTest”
  3. Select “Freestyle project” , click Ok
  4. Then click on “Advance” button under the “Advance projects options”
  5. Then select “Use custom workspace”, then give the project home directory path in “Directory” field.
  6. Then “Add build setup” under “Build” and select “Execute Windows batch Command”
  7. Then type “runSelenium.bat” in the command field, click apply and save it.
  8. Then in the “JenkinSeleniumTest”, then click on “Build Now” which will call the batch file and then Selenium script internally.
  9. Verify the “Console output” in “JenkinSeleniumTest” which will show the Selenium execution results.

Java quick reference

Java quick reference

Java is object oriented(OOP) programming language. It is platform independent and can be run on any Operating system (OS) and it requires java interpreter (for bytecode to machine code transfer) in the system.

Java applets are one type of java program which is used within a web page however JSP is used to create web applications like PHP, ASP, JSP for the purpose of creating dynamic web pages. JavaBeans is like VB and it is reusable component and the purpose is to create advanced applications. J2EE is another Java program mainly used for data transfer e.g XML structured data.

Java Object:

Java object is a real world representation with its different state & behavior

Java Class:

Class is representation of objects or it is a template for objects.

Class has data members(attributes) and methods

Java constructors:

Java constructors are for initializing the objects of a class. Constructor name is same as class name and Constructors are invoked when objects are created. every class needs constructor and if we did not create one then the compiler will create default constructor. Java modifiers are not allowed for constructors. constructors cannot return values.

e.g. for parameterized constructor

class abc

{

public abc(int numb, String strval)

 {

  System.out.println(“abc is a parameterized constructor of class abc”);

 }

}

e.g. for default constructor

class abc

{

public abc()

 {

  System.out.println(“abc is a default constructor of class abc”);

 }

}

Java packages:

Java packages are group of similar classes or interfaces. Java packages are kind of containers for java classes.

Accessing a package is done by a) import package.*; or  b) import package.classname; etc

compile java files by “javac -d filename.java”

What is the difference between Web Layer (Presentation Tier) vs Application Layer (Logic Tier) vs Database Layer (Data Tier)

1. Presentation Layer is the interface to outside world e.g. web site.

2. Application Layer is a framework to create the interface to the Web site or Presentation Tier

3. Database Layer is the database and associated logic needed to query details.

Web Layer (Presentation Tier)

Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux

Contains Apache web Server, Apache tomcat, Sun Java Web Server or MS Internet Information Services (IIS)

Application Layer (Logic Tier)

Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux

Contains Apache tomcat, Red Hat JBoss, BEA Web Logic or IBM WebSphere app server

Database Layer (Data Tier)

Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux

Contains SQL or Oracle

String reverse using java script split method

Assume given string ‘str’ value is “welcome”
 
function stringRev(str) {
var splitString = str.split(“”);// Use the reverse() method to reverse the array
var arrayReverse = splitString.reverse(); // equals to [“e”, “m”, “o”, “c”, “l”, “e”, “w”]// Use join() method to join the elements of the array into a string as below in comments
var joinArray = arrayReverse .join(“”); //  [“e”, “m”, “o”, “c”, “l”, “e”, “w”] to “emoclew”//Return the reversed string
return joinArray; // “emoclew”
}stringRev(‘welcome’);

Java quick reference

Java is object oriented(OOP) programming language. It is platform independent and can be run on any Operating system (OS) and it requires java interpreter (for bytecode to machine code transfer) in the system.

Java applets are one type of java program which is used within a web page however JSP is used to create web applications like PHP, ASP, JSP for the purpose of creating dynamic web pages. JavaBeans is like VB and it is reusable component and the purpose is to create advanced applications. J2EE is another Java program mainly used for data transfer e.g XML structured data.

 

Java Object:

Java object is a real world representation with its different state & behavior

Java Class:

Class is representation of objects or it is a template for objects.

Class has data members(attributes) and methods

Java constructors:

Java constructors are for initializing the objects of a class. Constructor name is same as class name and Constructors are invoked when objects are created. every class needs constructor and if we did not create one then the compiler will create default constructor. Java modifiers are not allowed for constructors. constructors cannot return values.

 

e.g. for parameterized constructor

 

class abc

{

public abc(int numb, String strval)

 {

  System.out.println(“abc is a parameterized constructor of class abc”);

 }

}

e.g. for default constructor

 

class abc

{

public abc()

 {

  System.out.println(“abc is a default constructor of class abc”);

 }

}

Java packages:

Java packages are group of similar classes or interfaces. Java packages are kind of containers for java classes.

 Accessing a package is done by a) import package.*; or  b) import package.classname; etc

compile java files by “javac -d filename.java”

How to print alphabets using java programming:

First Method:

char cAlpha = ‘A’;

do {
System.out.println(cAlpha );
cAlpha ++;
} while (cAlpha <= ‘Z’);

Second method :

char cAlpha = ‘a’;

while (cAlpha <= ‘z’) {
System.out.println(cAlpha);
cAlpha ++;
}

Third Method :

class PrintAlphabets
{
public static void main(String args[])
{
char chAlpha;

for( chAlpha= ‘a’ ; chAlpha<= ‘z’ ; chAlpha++ )
System.out.println(chAlpha);
}
}

 

How to Use WhatsApp in a Web Browser?

Solution:

1) Go to web.whatsapp.com in a web browser on a computer.
2) Then, on your iOS/Android/Windows mobile phone, open WhatsApp and press the Options on top right corner side
3) then press WhatsApp Web from the options.
4) use iOS/Android/Windows mobile phone to scan the QR code shown on the browser on your computer.

Whatsapp tricks & cheats

How to locate important messages in Whatsapp easily?

Solution: WhatsApp selected messages can be starred.

How to do: Hold down the message and select the star icon on top of whatsapp.

Then You can see all your starred messages directly from your WhatsApp homescreen(View contact >> started message)

How to Use WhatsApp in a Web Browser

1) go to web.whatsapp.com in a web browser on a computer.

2) Then, on your iOS/Android/Windows mobile phone, open WhatsApp and press the Options on top right corner side

3) then press WhatsApp Web from the options.

4) use iOS/Android/Windows mobile phone to scan the QR code shown on the browser on your computer.

How to restrict the view on profile photo and personal status in Whatsapp

Solution: Settings > Account > Privacy and press the right sub-menus for profile photo, status etc.

How to turn it off / hide the Last seen time in WhatsApp?

Follow the path Settings > Account > Privacy > Last Seen

How to turn it off / hide the Read Receipts indication.

Settings > Account > Privacy > Read Receipts

How to reference an old message in WhatsApp and wanted to respond to that.

Hold down the message, then press the left arrow on Android/’reply’ button on iOS. Then type the message that you wanted to display as a response to the old message. This is helpful when multiple conversations are happening in a group chat and you want to respond to a particular message.

How to hide the WhatsApp message previews?

Solution: Go to Settings > Notifications > Show Preview, change the settings.

WhatsApp – how to format the text message

             -it-  => it

             *it* =>    it

            ~it~ =>   it

WhatsApp- Sending voice message instead of typing

            In Android phones – tap on mic icon in WhatsApp and record your voice or use Google’s speech to text engine

            In iPhone phones – tap on mic icon in WhatsApp and record your voice

   ...   ...   ...   ...   ...   ...  ...   ...   ...