Download the SourceTree app from https://www.sourcetreeapp.com/ for this tutorial to work.

1)   Setting up for the first time

Add username/password by clicking on settings (gear) > Accounts icon

Picture1

 

Click on Add button. Click on Connect button

Picture2

 

Login to bitbucket

Picture3

 

Follow the steps and your username/password will be saved.

 

2)   First Time Checking out (aka Cloning)

Go to SourceTree Application

Picture5

Follow the Clone Wizard

Picture6

Picture7

Once successful, you will see the repo in the list below.

Picture8

 

 

 

3)   Import in Eclipse and Run on Server

Instructions have been posted before on this. If you can not locate this, add a comment below.

4)   Checking in (aka Commit and Push)

Change a file

Go to SourceTree Application

Picture9

 

Commit

Picture10

Push

Picture11

Picture12

You are all set. You can verify your changes on bitbucket website

 

 

 

 

Posted in Uncategorized | Leave a comment

One to many relationship example using Hibernate – Step by Step Instruction

One to many relationship example using Hibernate

One to many relationship using Hibernate can be super useful for any practical purposes. Here are step by step instructions on how to do the same:
In this example There is a one to many relationship between User and User Purchase.
1. Create User Table

	CREATE DATABASE IF NOT EXISTS training; 
	CREATE TABLE IF NOT EXISTS
	training.User ( id INT NOT NULL AUTO_INCREMENT , 
	username VARCHAR(250) NOT NULL , 
	password VARCHAR(250) NOT NULL , 
	email_address VARCHAR(250) NULL ,
	PRIMARY KEY (id) , UNIQUE INDEX
	username_UNIQUE (username ASC) );

2. Create User Purchase Table

	CREATE TABLE `training`.`user_purchase` (
		  `iduser_purchase` INT NOT NULL,
		  `user_id` INT NULL,
		  `item` VARCHAR(45) NULL,
		  `price` FLOAT NULL,
		  PRIMARY KEY (`iduser_purchase`),
		  INDEX `user_id_idx` (`user_id` ASC),
		  CONSTRAINT `user_id`
		    FOREIGN KEY (`user_id`)
		    REFERENCES `training`.`User` (`id`)
		    ON DELETE CASCADE
		    ON UPDATE CASCADE);

3. Create UserPurchase Class

package com.st.model;


public class UserPurchase {
	private Integer purchaseId;
	private User user;
	private float price;
	private String item;

	public Integer getPurchaseId() {
		return purchaseId;
	}

	public void setPurchaseId(Integer purchaseId) {
		this.purchaseId = purchaseId;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public String getItem() {
		return item;
	}

	public void setItem(String item) {
		this.item = item;
	}
}

4. Create User Class

package com.st.model;

import java.util.HashSet;
import java.util.Set;

/**
@author asinha
 *
 */
public class User {
	private int id;

	private String emailAddress;
	private String username;
	private String password;
	
	//Create a new variable to indicate collection of UserPurchase
	//This shows one to many relationship between User and UserPurchase
	private Set userPurchases = new HashSet();
	
	

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set getUserPurchases() {
		return userPurchases;
	}

	public void setUserPurchases(Set userPurchases) {
		this.userPurchases = userPurchases;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", emailAddress=" + emailAddress + ", username=" + username + ", password=" + password
				+ "]";
	}

}

4. Create user-purchase.hbm.xml

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
	<class name="com.st.model.UserPurchase" table="user_purchase">
		<id name="purchaseId" column="iduser_purchase">
			<generator class="increment" />
		</id>

		<property name="price" type="float" column="price"></property>
		<property name="item" type="string" column="item"></property>
		
		<many-to-one name="user" class="com.st.model.User"
			fetch="select">
			<column name="user_id" not-null="true" />
		</many-to-one>

	</class>
</hibernate-mapping>

4. Create user.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
	<class name="com.st.model.User" table="User">
		<id name="id">
			<generator class="increment" />
		</id>

		<property name="username" type="string" column="username"></property>
		<property name="password" type="string" column="password"></property>
		<property name="emailAddress" type="string" column="email_address"></property>
		
		<set name="userPurchases" table="user_purchase" inverse="true"
			lazy="true" fetch="select">
			<key>
				<column name="id" not-null="true" />
			</key>
			<one-to-many class="com.st.model.UserPurchase" />
		</set>
		
	
	</class>
</hibernate-mapping>

4. Update hibernate.cfg.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<!--<property name="connection.url">jdbc:mysql://localhost:3306/sansa_ads</property> -->
		<property name="connection.url">jdbc:mysql://localhost:3306/training</property>
		<property name="connection.username">root</property>
		<property name="connection.password">password</property>
		<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
		<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
		<!-- thread is the short name for org.hibernate.context.ThreadLocalSessionContext 
			and let Hibernate bind the session automatically to the thread -->
		<property name="current_session_context_class">thread</property>

		<!-- this will show us all sql statements -->
		<property name="hibernate.show_sql">true</property>

		<!-- mapping files -->


		<mapping resource="user.hbm.xml" />
		<mapping resource="user-purchase.hbm.xml" />



	</session-factory>
</hibernate-configuration>

4. Create a method in UserDAO Class

package com.st.dao;

import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import com.st.model.SocialClub;
import com.st.model.User;
import com.st.model.UserPurchase;

public class UserDAO {

	static Session session;

	static void createSession() {
		SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
		session = sessionFactory.openSession();
	}


	public static boolean testCreateOneToMany() {
		boolean status = false;
		createSession();
		
		Transaction tx = session.beginTransaction();
		
		User user = new User();

		user.setEmailAddress("a@apple.com2");
		user.setUsername("a_user2");
		user.setPassword("a_pass2");
		session.save(user);
		
		UserPurchase userPurchase = new UserPurchase();
		userPurchase.setItem("Iphone");
		userPurchase.setPrice(695.00f);
		
		userPurchase.setUser(user);
		user.getUserPurchases().add(userPurchase);
		session.save(userPurchase);
		
		
		tx.commit();
		status = true;

		return status;

	}
	
	public static void main(String[] args) {


		testCreateOneToMany();

	}

}

10. That’s it. You should see an output like below to show that data has been inserted in the tables

Hibernate: select max(id) from User2
Hibernate: select max(iduser_purchase) from user_purchase
Hibernate: insert into User2 (username, password, email_address, id) values (?, ?, ?, ?)
Hibernate: insert into user_purchase (price, item, user_id, iduser_purchase) values (?, ?, ?, ?)

Also, Verify this in the database using a tool such as MySQL Workbench:

SELECT * FROM training.user_purchase;
'1','6','Iphone','695'

Posted in Coding Challenges, Computers and Internet, Interview Preparation, IT Jobs | Tagged | Leave a comment

Many to many relationship example using Hibernate – Step by Step Instructions

Many to many relationship using Hibernate can be super useful for any practical purposes. Here are step by step instructions on how to do the same:
In this example There is a many to many relationship between User and Social Club. A user can belong to many social clubs and a Social Club can have many users

Many to many relationship example using Hibernate

1. Create User Table

	CREATE DATABASE IF NOT EXISTS training; 
	CREATE TABLE IF NOT EXISTS
	training.User ( id INT NOT NULL AUTO_INCREMENT , 
	username VARCHAR(250) NOT NULL , 
	password VARCHAR(250) NOT NULL , 
	email_address VARCHAR(250) NULL ,
	PRIMARY KEY (id) , UNIQUE INDEX
	username_UNIQUE (username ASC) );

2. Create SocialClub Table

CREATE TABLE `training`.`socialclub` (
  `club_id` INT NOT NULL,
  `name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`club_id`));

3. Create User_SocialClub Table

CREATE TABLE `training`.`user_socialclub` (
  `user_id` INT NOT NULL,
  `club_id` INT NOT NULL,
  PRIMARY KEY (`user_id`,`club_id`),
  CONSTRAINT `fk_user_id`
    FOREIGN KEY (`user_id`)
    REFERENCES `training`.`User2` (`id`),
    
  CONSTRAINT `fk_club_id`
    FOREIGN KEY (`club_id`)
    REFERENCES `training`.`socialclub` (`club_id`)
)

4. Create SocialClub Class

package com.st.model;

import java.util.HashSet;
import java.util.Set;

//CREATE TABLE `training`.`socialclub` (
//		  `club_id` INT NOT NULL,
//		  `name` VARCHAR(45) NOT NULL,
//		  PRIMARY KEY (`club_id`));

public class SocialClub {
	private Integer clubId;
	private String name;
	private Set users = new HashSet();

	public SocialClub(String name) {
		
		
		this.name = name;
		
	}

	public SocialClub(Integer clubId, String name, Set users) {
		super();
		this.clubId = clubId;
		this.name = name;
		this.users = users;
	}

	public Integer getClubId() {
		return clubId;
	}

	public void setClubId(Integer clubId) {
		this.clubId = clubId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set getUsers() {
		return users;
	}

	public void setUsers(Set users) {
		this.users = users;
	}

}


5. Create User Class

package com.st.model;

import java.util.HashSet;
import java.util.Set;

/**
@author asinha
 *
 */
public class User {
	private int id;

	private String emailAddress;
	private String username;
	private String password;
	
	private Set userPurchases = new HashSet();
	
	
	private Set clubs = new HashSet();

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set getUserPurchases() {
		return userPurchases;
	}

	public void setUserPurchases(Set userPurchases) {
		this.userPurchases = userPurchases;
	}

	public Set getClubs() {
		return clubs;
	}

	public void setClubs(Set clubs) {
		this.clubs = clubs;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", emailAddress=" + emailAddress + ", username=" + username + ", password=" + password
				+ "]";
	}

}

6. Create socialclub.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
	<class name="com.st.model.SocialClub" table="socialclub">
		<id name="clubId" column="club_id">
			<generator class="increment" />
		</id>


		<property name="name" type="string" column="name"></property>
		
		<set name="users" table="user_socialclub" inverse="true" lazy="true"
			fetch="select">
			<key>
				<column name="club_id" not-null="true" />
			</key>
			<many-to-many entity-name="com.st.model.User">
				<column name="user_id" not-null="true" />
			</many-to-many>
		</set>

	</class>
</hibernate-mapping>

7. Create user.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
	<class name="com.st.model.User" table="User2">
		<id name="id" column="id">
			<generator class="increment" />
		</id>

		<property name="username" type="string" column="username"></property>
		<property name="password" type="string" column="password"></property>
		<property name="emailAddress" type="string" column="email_address"></property>
		
		<set name="userPurchases" table="user_purchase" inverse="true"
			lazy="true" fetch="select">
			<key>
				<column name="id" not-null="true" />
			</key>
			<one-to-many class="com.st.model.UserPurchase" />
		</set>
		
		<set name="clubs" table="user_socialclub" inverse="false"
			lazy="true" fetch="select" cascade="all">
			<key>
				<column name="user_id" not-null="true" />
			</key>
			<many-to-many entity-name="com.st.model.SocialClub">
				<column name="club_id" not-null="true" />
			</many-to-many>
		</set>
	</class>
</hibernate-mapping>

8. Update hibernate.cfg.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<!--<property name="connection.url">jdbc:mysql://localhost:3306/sansa_ads</property> -->
		<property name="connection.url">jdbc:mysql://localhost:3306/training</property>
		<property name="connection.username">root</property>
		<property name="connection.password">password</property>
		<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
		<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
		<!-- thread is the short name for org.hibernate.context.ThreadLocalSessionContext 
			and let Hibernate bind the session automatically to the thread -->
		<property name="current_session_context_class">thread</property>

		<!-- this will show us all sql statements -->
		<property name="hibernate.show_sql">true</property>

		<!-- mapping files -->


		<mapping resource="user.hbm.xml" />
		<mapping resource="user-purchase.hbm.xml" />
		<mapping resource="socialclub.hbm.xml" />


	</session-factory>
</hibernate-configuration>

9. Create a method in UserDAO Class

package com.st.dao;

import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import com.st.model.SocialClub;
import com.st.model.User;


public class UserDAO {

	static Session session;

	static void createSession() {
		SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
		session = sessionFactory.openSession();
	}



	public static boolean testCreateManyToMany() {
		boolean status = false;
		createSession();
		
		Transaction tx = session.beginTransaction();
		User user = new User();

		user.setEmailAddress("a@apple.com2");
		user.setUsername("a_user2" + new Date().getTime());
		user.setPassword("a_pass2");
		//session.save(user);
		

		Set clubs = new HashSet(); 
		clubs.add(new SocialClub("CHESS CLUB"));
		clubs.add(new SocialClub("BOOK CLUB"));
		user.setClubs(clubs);
		session.save(user);
		
		
		tx.commit();
		status = true;

		return status;

	}
	
	public static void main(String[] args) {


		testCreateManyToMany();

	}

}

10. That’s it. You should see an output like below to show that data has been inserted in the tables

Hibernate: insert into User (username, password, email_address, id) values (?, ?, ?, ?)
Hibernate: insert into socialclub (name, club_id) values (?, ?)
Hibernate: insert into socialclub (name, club_id) values (?, ?)
Hibernate: insert into user_socialclub (user_id, club_id) values (?, ?)
Hibernate: insert into user_socialclub (user_id, club_id) values (?, ?)

Also, Verify this in the database using a tool such as MySQL Workbench:

SELECT * FROM training.socialclub;
club_id, name
'1','BOOK CLUB'
'2','CHESS CLUB'


SELECT * FROM training.user_socialclub;
user_id, club_id
'10','5'
'10','6'


Posted in Coding Challenges, Computers and Internet, IT Jobs | Tagged | Leave a comment

Test Your Java Skills

In case you are feeling itchy to asses your Java skills, here is a wonderful test. Please send me the solution at contact@sansatechnology.com – Will be happy to evaluate and send my comments.

Total Score: 120

1. [20 Marks] Create a method that will take a String as an input and return capitalized String in reverse.

E.g., Provided an input as abcd, it will return DCBA.

Call this method from main method and share the screen shot of input and output.

2. [20 Marks] Create a class called User.

User has following attributes:

firstName

lastName

username

password

Override toString and equals method

Call toString and equals method method from main method and share the screen shot of input and output.

3. [20 Marks] Create a method that reads list of User (User class is defined above) data from a file and returns an ArrayList of Users.

File looks like:

John, Wick, john_user, john123

<has many records>

Mark, Keaten, mark_user, m123

Call this method from main method and share the screen shot of input and output.

4. [20 Marks] How do you iterate through a HashMap. Build and example.

Call this method from main method and share the screen shot of input and output.

5. [20 Marks] Emulate the File System functionality. Allow user to list, rename, move, copy a file or folder

6. [20 Marks] Write an application that can take name, title and price of a movie and create a record in the database. User should also be allowed to choose a movie and edit its title and price. He can also delete the movie. He should also be able to display the list of movie by a search condition, such as show all movies whose title starts wit “T”.

Posted in Coding Challenges, Computers and Internet, Interview Preparation, IT Jobs, Uncategorized | Leave a comment

5 Ways to maximize your salary at the next Job

Maximize your salary

Maximize your salary

1. Research what are you worth – Look at the job portals, industry publications and check with your friends to get an idea on what your skills and experience is worth. e.g., It is not uncommon to see Java developers are paid anywhere from $40 to $90 or even higher depending upon their experience, skills and job locations.

2. Let the employer give you an offer first – You do not want to be the one who gives the number, as your salary expectation may be under par. Specially, employees coming from some outsourcing companies have salary on the lower side of the market rate. You should let the employer give you an offer first.

3. Ready to provide a counter offer – If your research suggests that you can get a better deal, be open to convey it in a polite manner. You should also have a strategy on what happens is the employer does not accept your counter offer.

4. Don’t be lazy – Sometimes people take whatever comes their way. Please spend some time to explore where you want your career to go and if the new compensation fits with your career path and goals.

5. Don’t overlook extras – If you can not get the base salary changed, explore if there is an opportunity to get better deals on bonus, insurance, healthcare, flexible work hours and other perks.

 

 

Posted in Uncategorized | Tagged , | Leave a comment

Questions Testers often ask

We get many questions asked from new Quality Assurance testers. I have compiled the list of top questions I hear from them:
1. What does the QA person do and where does it fit in the SDLC phase?
QA person tests a product before it can be released to production.
In a typical SDLC, here are typical steps:
1. Requirement Phase: Product Manager gets/ writes Biz Req Document
2. Analysis Phase: Tester creates test cases
3. Development Phase: Developers get use cases from BRD and write code
4. Validation Phase: Testers execute test cases and report bugs and revalidate the fixes

2. What’s a typical timeline of a Project?
Here is a hypothetical project:
Jan 1st, 2017: Project kicks off
March 1st, 2017: BRD is delivered
March 2nd onwards: You work on defining test cases
March 2nd to April end: Developers are starting to build
May 1st onwards: You can test

3. What is testing?
While there are many definitions of testing, a very simple definition that you look at the
actual result and compare it with the expected result. If both match your functionality is working, otherwise there is a bug.

4. What am I required to do in a Black box testing?
You should be able to do the following:
1. Should be able to convert use cases (BRD – Business Req Document) to test cases
2. You should know how to document and how to use Test Case repositories
3. If you have to report bugs, how and where to report bugs (Jira)
4. Automate – Use Selenium IDE to automate some use cases
5. Load testing – Load runner
6. SVN – How to check incheck out
7. Continuous Integration tool – Jenkins

5. What do you do as a White Box Tester?
In addition to the above, you will also work on
1. Looking at the code, and
2. Writing JUnit test cases

Posted in Uncategorized | Leave a comment

Java Files: Important Interview Coding Questions

One of our consultants recently went for an interview at “a very big company” in San Francisco, and she was asked to write Java implementation of File System function, such as list, create file, create folder etc.

We strongly recommend you to prepare yourself to be able to whiteboard these solutions for an interview.

Here is the solution (If you like this solution, please leave a comment – Thanks in advance):

 

/**
 * 
 */
package com.training.package3.q6;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * Emulate the following File system functions using File class: A. Create a
 * Folder (similar to mkdir command) B. Create a File C. Delete a Folder or File
 * (similar to rm command) D. Rename a File E. Read the content of a File and
 * Display the content (similar to cat command) F. Display the list of files and
 * folder under a Folder(similar to ls command)
 *
 * 
 */
public class FileSystemEmulator {

	/**
	 * A. Create a new folder at the base URL
	 * 
	 * @param baseURL
	 * @param folderName
	 * @return
	 */
	public boolean createFolder(String baseURL, String folderName) {
		File file = new File(baseURL, folderName);
		boolean status = false;
		try {
			status = file.mkdir();

		} catch (Exception e) {

			e.printStackTrace();
		}

		return status;
	}

	/**
	 * B. Create a File
	 * 
	 * @param baseURL
	 * @param folderName
	 * @return
	 */
	public boolean createFile(String baseURL, String fileName) {
		File file = new File(baseURL, fileName);
		boolean status = false;

		try {
			status = file.createNewFile();

		} catch (IOException e) {

			e.printStackTrace();
		}

		return status;
	}

	/**
	 * C. Delete a Folder or File (similar to rm command)
	 * 
	 * @param baseURL
	 * @param folderName
	 * @return
	 */
	public boolean deleteFile(String baseURL, String fileName) {
		File file = new File(baseURL, fileName);
		boolean status = false;

		try {
			status = file.delete();

		} catch (Exception e) {

			e.printStackTrace();
		}

		return status;
	}

	/**
	 * D. Rename a File
	 * 
	 * @param baseURL
	 * @param folderName
	 * @return
	 */
	public boolean renameFile(String baseURL, String fileName, String newName) {
		File file = new File(baseURL, fileName);
		boolean status = false;

		try {
			status = file.renameTo(new File(baseURL, newName));

		} catch (Exception e) {

			e.printStackTrace();
		}

		return status;
	}

	/**
	 * E. Read the content of a File and Display the content (similar to cat
	 * command)
	 * 
	 * @param baseURL
	 * @param folderName
	 * @return
	 */
	public boolean readAndDisplayContent(String baseURL, String fileName) {
		File file = new File(baseURL, fileName);
		boolean status = false;

		try {
			FileReader myFR = new FileReader(file);
			BufferedReader in = new BufferedReader(myFR);
			String str;

			while ((str = in.readLine()) != null) {

				System.out.println(str);
			}

			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

		return status;
	}

	/**
	 * F. Display the list of files and folder under a Folder(similar to ls
	 * command)
	 * 
	 * @param baseURL
	 * @param folderName
	 * @return
	 */
	public boolean listFilesFolder(String baseURL, String fileName) {
		File file = new File(baseURL, fileName);
		boolean status = false;

		try {
			File[] files = file.listFiles();
			for (int i = 0; i < files.length; i++) {
				System.out.println(files[i].getName());
			}

		} catch (Exception e) {

			e.printStackTrace();
		}

		return status;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		String baseURL = "/Users/amitesh.sinha/data";
		new FileSystemEmulator().createFolder(baseURL, "myFolder");
		new FileSystemEmulator().createFolder(baseURL, "myFile.txt");

		new FileSystemEmulator().readAndDisplayContent(baseURL, "myFile.txt");
		new FileSystemEmulator().listFilesFolder(baseURL, "myFile.txt");

		new FileSystemEmulator().deleteFile(baseURL, "myFile.txt");
		new FileSystemEmulator().renameFile(baseURL, "myFile.txt", "newName.txt");

	}
}

Posted in Coding Challenges, Computers and Internet, Interview Preparation, IT Jobs | Tagged , , | Leave a comment

Top 10 Java Interview Programming Questions with Solutions

screen-shot-2016-10-05-at-11-18-07-pm

Wonder how to prepare for the interview programming questions?Here is a great way to get started. These ten questions will warm you up to get started with a successful interview.

Without much further ado, here are the questions:

1. Write a method that uses a for loop to display numbers in descending order in the step of 5 starting from 100. Call your method from the main method.

e.g., The output should be:

100

95

90

5

0
2. Write a method that uses a while loop. This method would replace every vowel in the String with X. Call your method from the main method.

e.g., the String
Java is Fun
should become
JXvX Xs FXn
3. Write a method that uses a do while loop. This method would reverse a String. Call your method from the main method.

e.g., the String
Java
should become
avaJ

4. Write a method that checks if a String is a Palindrome. Call your method from the main method.

5. Write a method that prints the multiplication table of the user provided number. Call your method from the main method.

e.g., If the user enters the value of 9
should become, the program prints
9
18
27
36


81
90

6. Write a method that checks if a number is a Prime number. Call your method from the main method.

7. Write a method that accepts two numbers are returns the maximum of Two. Call your method from the main method.

8. Create a method that accepts two numbers and returns the minimum of Two. Call your method from the main method.

9. Write a method that accepts two numbers and returns the average of Two. Call your method from the main method.
10. Write a method that calls all the above methods. Log the time at the begining of this method and at the end. Print how many milliseconds elapsed in executing all the above methods Call your method from the main method.

Solution:

Solution is located at our tutorial website http://sansatechnology.com/tutorials/java/ten-interview-loop-questions.php

 

Have questions? Contact us:
Email: contact@sansatechnology.com
Web: http://www.sansatechnology.com

Need a boost for your professional career? Try our professional training courses: http://www.sansatechnology.com/training
We are hiring! Check out our current job openings at: http://www.sansatechnology.com/career.php

Posted in Uncategorized | Tagged , | Leave a comment

5 things a Job Seeker should learn from the Olympics

  1. 2016_summer_olympics_logo Aim for Higher, Bigger & Better – As someone has said that you are competing with no one but yourself to get better. Keep aiming for higher, bigger and better goals.

 

  1. Never Stop Learning – Most of the players at Olympics never stop learning. They are at that level as they have practiced everyday and have never stopped learning. Look at the mistakes you have made in the previous interviews and rectify them before the next one.

 

  1. Be consistent – Olympians are consistently great. They plan, they practice, they repeat the same routine over and over, as they know what is the end goal. You also need to be consistent – keep doing what you believe in and keep giving consistent performance.

 

  1. Have a winner’s mentality and Never Quit – Sometimes it feels that there is no light at the end of the tunnel, and some people decide to quit their dreams. Perseverance is the key to your success.

 

  1. Today can be your lucky day – Do your best. Today could be your lucky day. If you have already prepared, had a good night sleep, today could be the day you get the success.

 

Posted in Uncategorized | Tagged , | Leave a comment

Which skills should I possess as a White Box Tester or SDET (Software Development Engineer in Test)

While it really depends upon what your potential employer is looking for, when we hire some this is what we are generally looking for:

Technology

 

  • Really Strong in Core Java
  • Hands on with Coding, Knowledge of Shell Scripting and Unix, SQL
  • Should have worked on Automation using Selenium Web Driver
  • Should have worked on Application Testing projects and not Platform Testing
  • JUnit

Process

  • Experience in automation of test cases for applications built for Performance & Scale, SaaS & Cloud
  • Design, develop and debug tests in a complex environment using tools such as Selenium,
  • Execute tests, report results and open bugs as needed per organizational standards
  • Worked in projects executed in Agile methodology

Other Skills

  • Should have clear communication and ability to express issues and ideas
  • Should be a team player

Let us know if you have more questions. We are happy to help you with your questions.

 

Posted in Uncategorized | Leave a comment