Manual
test cases for file uploading:
When upload file upload button must be
disable until file
is selected.
is selected.
check for the Upload button whether it opens
a my documents dialogue box to select a file
check for the blank file, files without any
content
should not be uploaded-should get error message
should not be uploaded-should get error message
Check image upload with image size greater
than the max allowed size. Proper error message should be displayed
Check to get error message when unsupported
file type is uploaded
Check Once uploaded the file name shows next
to it
how much time it will take to upload the same
size of file
Image upload progress bar should appear for
large size images
Check if cancel button functionality is
working in between upload process
Check multiple file upload functionality
Check image quality after upload. Image quality should not be changed after upload
Check image quality after upload. Image quality should not be changed after upload
Write
a program to find the length of the string and print only the alphabetical
characters out of it. String was "A:B:C:D"
public String getStringOfLettersOnly(String s) {
//using a
StringBuilder instead of concatenate Strings
StringBuilder sb =
new StringBuilder();
for(int i = 0; i
< s.length(); i++) {
if
(Character.isLetter(s.charAt(i))) {
//adding
data into the StringBuilder
sb.append(s.charAt(i)); }
}
//return the
String contained in the StringBuilder
return
sb.toString();}
Write a SQL query to write
the date in a given format.
SELECT DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');
+---------------------------------------------------------+
| DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y') |
+---------------------------------------------------------+
| Saturday October 1997
Have you used String,
StringBuffer, StringBuilder classes in Java. Is String class mutable or
immutable?
String class is mutable
The StringBuffer and StringBuilder classes are used when there is a
necessity to make a lot of modifications to Strings of characters.
Unlike
Strings objects of type StringBuffer and Stringbuilder can be modified over and
over again with out leaving behind a lot of new unused objects. each method in StringBuffer is synchronized that is StringBuffer is thread safe
String
StringBuffer StringBuilder
----------------------------------------------------------------------------------
Storage Area | Constant String Pool Heap Heap
Modifiable | No (immutable) Yes( mutable ) Yes( mutable )
Thread Safe | Yes Yes No
Performance | Fast Very slow Fast
----------------------------------------------------------------------------------
Storage Area | Constant String Pool Heap Heap
Modifiable | No (immutable) Yes( mutable ) Yes( mutable )
Thread Safe | Yes Yes No
Performance | Fast Very slow Fast
Product manager,
scrum master and team
Product Back logs or
epics make into small product backlogs or user stories based on their priorties
Estmate the product
back log in points, decide sprint duration,sprint planning, estimate the hours
of work, devide the req to tasks, sprint meetings, daily defect track meetings,
post its, what work done, any dependencies, what u r working on …track down the
progress using burndown chart
based
on what features to go divided to release back logs- again make into sprints
based on time and priorities
each sprint, last 2 to 4 weeks, product owner, scrum master,
monitor the progress using burn down charts, based on velocity of chart will determine the release dates
in each sprint will find bugs and fix and by end of sprint, a complete feature will be released
each sprint, last 2 to 4 weeks, product owner, scrum master,
monitor the progress using burn down charts, based on velocity of chart will determine the release dates
in each sprint will find bugs and fix and by end of sprint, a complete feature will be released
What is Regular expression. Also
asked me to write the regular expression for some date
special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern.
special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern.
Date: (1[012]|[19]):[0 5][09 ](am|pm)
( start with
[ 012] after 1 it can
start with 10 or 11 or 12
| or
[19] can start with 1 to 9
Am or pm..
(//s) add space
Program to implement a LinkList:
import java.util.*;
public class LinkedListDemo {
public static void main(String args[]) {
// create a linked list
LinkedList ll = new LinkedList();
// add elements to the linked list
ll.add("F");
ll.add("B");
ll.add("D");
ll.add("E");
ll.add("C");
ll.addLast("Z");
ll.addFirst("A");
ll.add(1, "A2");
System.out.println("Original contents of ll: " + ll);
// remove elements from the linked list
ll.remove("F");
ll.remove(2);
System.out.println("Contents of ll after deletion: "
+ ll);
// remove first and last elements
ll.removeFirst();
ll.removeLast();
System.out.println("ll after deleting first and last: "
+ ll);
Program to open a file and write
or read something in file using java:
import java.io.*;
public class FileRead{
public static void main(String args[])throws IOException{
File file = new File("Hello1.txt");
// creates the file
file.createNewFile();
// creates a FileWriter Object
FileWriter writer = new FileWriter(file);
// Writes the content to the file
writer.write("This\n is\n an\n example\n");
writer.flush();
writer.close();
//Creates a FileReader Object
FileReader fr = new FileReader(file);
char [] a = new char[50];
fr.read(a); // reads the content to the array
for(char c : a)
System.out.print(c); //prints the characters one by one
fr.close();
}
}
Reading from a file plain text:
import java.io.*;
public class Test {
public static void main(String
[] args) {
String fileName =
"temp.txt";
String line = null;
try {
// FileReader reads
text files in the default encoding.
FileReader fileReader
=
new FileReader(fileName);
BufferedReader
bufferedReader =
new
BufferedReader(fileReader);
while((line =
bufferedReader.readLine()) != null) {
System.out.println(line);
}
bufferedReader.close();
}
catch(FileNotFoundException ex) {
System.out.println(
"Unable to
open file '" +
fileName +
"'"); }
catch(IOException ex) {
System.out.println(
"Error
reading file '"
+ fileName +
"'");
ex.printStackTrace();
} }}
In order to read from binary files use
FileInputStream inputStream =
new FileInputStream(fileName);
while((nRead = inputStream.read(buffer)) != -1) {
System.out.println(new String(buffer));
total += nRead;
Writing to File:
import java.io.*;
public class Test {
public static void main(String [] args) {
// The name of the file to open.
String fileName = "temp.txt";
try {
// Assume default encoding.
FileWriter fileWriter =
new FileWriter(fileName);
// Always wrap FileWriter in BufferedWriter.
BufferedWriter bufferedWriter =
new BufferedWriter(fileWriter);
// Note that write() does not automatically
// append a newline character.
bufferedWriter.write("Hello there,");
bufferedWriter.write(" here is some text.");
bufferedWriter.newLine();
bufferedWriter.write("We are writing");
bufferedWriter.write(" the text to the file.");
// Always close files.
bufferedWriter.close();
}
catch(IOException ex) {
System.out.println(
"Error writing to file '"
+ fileName + "'");
// Or we could just do this:
// ex.printStackTrace();
}
}
}
To write binary files to java
FileOutputStream outputStream =
new FileOutputStream(fileName);
outputStream.write(buffer);
Hash map:
The
HashMap class uses a hashtable to implement the Map interface. This allows the
execution time of basic operations, such as get( ) and put( ), to remain
constant even for large sets.
The
HashMap class supports four constructors
It has a number
of "buckets" which it uses to store key-value pairs in. this is very
efficient for looking up key-value pairs in a map
HashMap works on the principle of hashing
put(key, value): HashMap stores both key and value object as
Map.Entry. Hashmap applies hashcode(key) to get the bucket. if there is
collision ,HashMap uses LinkedList to store object.
get(key): HashMap uses Key Object's hashcode to find
out bucket location and then call keys.equals() method to identify correct node
in LinkedList and return associated value object for that key in Java HashMap
In Java,
when the “==” operator is used to compare 2 objects, it checks to see if the
objects refer to the same place in memory
String obj1 = new String("xyz");
String obj2 = new String("xyz");
if(obj1 == obj2)
System.out.println("obj1==obj2 is TRUE");
else
System.out.println("obj1==obj2 is FALSE");
o/p false
String obj1 = new String("xyz");
String obj2 = obj1;
if(obj1 == obj2)
System.out.println("obj1==obj2 is TRUE");
else
System.out.println("obj1==obj2 is FALSE");
o/p true
String obj1 = new String("xyz");
String obj2 = new String("xyz");
if(obj1.equals(obj2))
System.out.printlln("obj1==obj2 is TRUE");
else
System.out.println("obj1==obj2 is FALSE");
Output true
Design pattern: Design patterns are useful because they provide a pre-formulated
solution to problems based on the experience of other programmers. This can
save you a lot of time.
how to solve a
problem in different situations.
Singleton
pattern is one of the design patterns that is utilized for restricting
instantiation of a class to one or few specific objects................
Process pattern:
Methods, best practices, techniques for developing an Object-Oriented software
comprises a process pattern..
Access modifiers in java:
·
Visible to the package. the default. No modifiers are needed.
·
Visible to the class only (private).
·
Visible to the world (public).
·
Visible to the package and all subclasses (protected).
Class and interfaces cannot be private.
Using the private modifier is the main way that an object
encapsulates itself and hide data from the outside world.
The main() method of an application has to be public.
Otherwise, it could not be called by a Java interpreter (such as java) to run
the class.
The protected access modifier cannot be applied to class and
interfaces. Methods, fields can be declared protected, however methods and
fields in a interface cannot be declared protected.
What is data provider in
testNG
TestNG
lets you pass parameters directly to your test methods in two different ways:
·
With testng.xml
·
With Data Providers
·
When you need to
pass complex parameters use Data
Providers
·
A Data Provider is
a method annotated with @DataProvider.
This annotation has only one string attribute: its name. If the name is not
supplied, the Data Provider’s name automatically defaults to the method’s name.
A Data Provider returns an array of objects.
Unix
commands like list all the file names which have some particular text present
in them
$ grep check * -lR
$ grep check * -lR
r for recursive, looking
for word ‘check’
look for all files except
txt or pdf formats I is for ignore case
ls -I "*.txt" -I "*.pdf" -R
Vending machine
test cases:
functional
testing
check
proper change
check
improper change
check
proper itrem and improper item
no
item is there .
more
than available items stuffed in the tray
machine
does not have change.?
instability
testing
check
if vending machine can be inztalled properly with proper connection
check
if it is movable.
usability
testing
check
if vending machine has proper buttons
check
if it has 0-9 numbers to select
check
if it has coin return
dispenser/provision for hands to fit in to take the product
buttons
are not too rough
check
for the height of the operationabilty.
performance
how
quickly it drops
test
on differnt plugs and power 110 v 220 v 440v
test
on incremental loads of coins and keep selecting
keep
inserting coins continously for 1 hr then select
Stress
shake
the machine
switch on/switch off machine alternatingly and
select it.
in
severe cold/hot atmosphere does it work.
keep
inserting coins continously for 1 hr then select
insert
nothing and keep pressing
compatibility
different coins/dollars
takes a 1 dollr 5 dollar 100 dollar etc....
can vending machine work properly outside
capability
testing
what can vending machine do other than vending solid items ?keep liquid and solid items
can it be used just for vending coins?(this is a useful feature for taking quarters!!)
equivalence
partioning /boundary value.
valid: correct amount correct
selection of an item
invalid : no amount -item selection
no item -amount inserted and verify if the system takes it.
o Unit testing: I had
candidate going really deep in the circuitry of the machine, testing each individual
transistors. Most go to a higher level and test each individual functional
component.
o Functional testing: Some
candidate approach functional testing through the actual mechanics of the
machine (buttons, display etc.) while some other approach it from a software
angle, leaving aside the mechanics. The best tester covers both.
o White box/Black box: Again, your
mileage may vary and you really see where your candidate is the most
comfortable.
o Performance/reliability testing: How fast can
I get my coffee? How many coffee can I deliver in rush hours, MTBF etc. You can
have a lot of fun in this area.
o Usability: So much to do
in the area but most candidate forget about it.
o Localization testing: Again, most
candidate don’t think about this one.
o Security testing: Most
candidate don’t go there but it’s always a good sign if they do. I had
candidate forcing the door to get money, throwing water on it to see how far
they can go until a power surge, sending 300v in the thing to understand how it
would react etc.
If the log file is really
big , how to check last few logs of log file :
Grep test /etc/logfile
| tail
-l
first n lines Syntax: head -n N FILENAME
$ head -n 15 /var/log/maillog
Ignore last 250 lines:$ head -n -250 /var/log/secure
Last n lines: $ tail -n 50 /var/log/messages
To view newer contents: $ tail -f /var/log/syslog
How to remotely access other
linux machine
Configure
remote access in the ubantu machine
In
windows install vnc programme and add the remote machine address in it
In
ubantu install ssh and make the port open 22
In
windows install ssh client software i.e putty and enter login pwd and start
accessing linux
what is rowid in Oracle database
ROWID is the physical location of a row. Consequently it is
the fastest way of locating a row,
It is address of the row..
what is primary key and
unique constrain
A primary key is a unique field on a table but it is
special in that the table considers that row its key. That means that other
tables can use this field to create foreign key relationships to themselves.
A unique
constraint simply means that a particular field must be unique.
What
are the prerequisites to run Java code on your local machine:
download java and run the .exe to install Java on your machine
you would need to set environment variables to point to correct
installation directories:
·
Right-click on 'My Computer' and select 'Properties'.
·
Click on the 'Environment variables' button under the 'Advanced'
tab.
·
Now, alter the 'Path' variable so that it also contains the path
to the Java executable. Example, if the path is currently set to
'C:\WINDOWS\SYSTEM32', then change your path to read
'C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin'.
Write java program in notepad or eclpse…and save as xxx.java
public class MyFirstJavaProgram {
/* This is my first java program.
* This will print 'Hello World' as the output
*/
public static void main(String []args) {
System.out.println("Hello World"); // prints Hello World
}
}
·
Open a command prompt window and go o the directory where you
saved the class. Assume it's C:\.
·
Type ' javac MyFirstJavaProgram.java ' and press enter to compile
your code. If there are no errors in your code, the command prompt will take
you to the next line (Assumption : The path variable is set).
·
Now, type ' java MyFirstJavaProgram ' to run your program.
·
You will be able to see ' Hello World ' printed on the window.
For all class names the first letter should be in Upper Case.
·
All method names should start with a
Lower Case letter. Name
of the program file should exactly match the class name Examples of legal identifiers: age, $salary, _value,
__1_value
·
Examples of illegal identifiers: 123abc, -salary
Java programme:
import java.io.*;
public class Employee{
String name;
int age;
String designation;
double salary;
// This is the constructor of the class Employee
public Employee(String name){
this.name = name;
}
// Assign the age of the Employee to the variable age.
public void empAge(int empAge){
age = empAge;
}
/* Assign the designation to the variable designation.*/
public void empDesignation(String empDesig){
designation = empDesig;
}
/* Assign the salary to the variable salary.*/
public void empSalary(double empSalary){
salary = empSalary;
}
/* Print the Employee details */
public void printEmployee(){
System.out.println("Name:"+ name );
System.out.println("Age:" + age );
System.out.println("Designation:" + designation );
System.out.println("Salary:" + salary);
}
}
As
mentioned previously in this tutorial, processing starts from the main method.
Therefore in-order for us to run this Employee class there should be main
method and objects should be created. We will be creating a separate class for
these tasks.Save the following code in EmployeeTest.java file
import java.io.*;
public class EmployeeTest{
public static void main(String args[]){
/* Create two objects using constructor */
Employee empOne = new Employee("James Smith");
Employee empTwo = new Employee("Mary Anne");
// Invoking methods for each object created
empOne.empAge(26);
empOne.empDesignation("Senior Software Engineer");
empOne.empSalary(1000);
empOne.printEmployee();
empTwo.empAge(21);
empTwo.empDesignation("Software Engineer");
empTwo.empSalary(500);
empTwo.printEmployee();
}
}
Now, compile both the classes and then run EmployeeTest to see the result as follows:
C :> javac Employee.java
C :> vi EmployeeTest.java
C :> javac EmployeeTest.java
C :> java EmployeeTest
Name:James Smith
Age:26
Designation:Senior Software Engineer
Salary:1000.0
Name:Mary Anne
Age:21
Designation:Software Engineer
Salary:500.0
2) What is the difference
in the versioning format in Java (Eg:- 1.5 vs 5.0)
Where there was 1.5.0
now make into 5.0
Thread:All Java programs have at least one thread,
known as the main thread, which is created by the JVM at the program’s start,
when the main() method is invoked with the main thread. In Java, creating a thread
is accomplished by implementing an interface and extending a class. Every Java
thread is created and controlled by the java.lang.Thread class.
When a thread is created, it is assigned a priority. The thread with higher priority is executed first, followed by lower-priority threads
When a thread is created, it is assigned a priority. The thread with higher priority is executed first, followed by lower-priority threads
Collections:
Sort
array of strings:
String []
strs=(“ggg”,”jkj”,”jkjkj”);
Arrays.sort(strs);
Sort chars in string:
// put the characters into an array
Character[] chars = new Character[str.length()];
for (int i = 0; i < chars.length; i++)
chars[i] = str.charAt(i);
// sort the array
Arrays.sort(chars, new Comparator<Character>() {
public int compare(Character c1, Character c2) {
int cmp = Character.compare(
Character.toLowerCase(c1.charValue()),
Character.toLowerCase(c2.charValue())
);
if (cmp != 0) return cmp;
return Character.compare(c1.charValue(), c2.charValue());
}
});
// rebuild the string
StringBuilder sb = new StringBuilder(chars.length);
for (char c : chars) sb.append(c);
str = sb.toString();
(or)
1. import java.util.Arrays;
2.
3. public class SortStringArrayExample {
4.
5.
public static void main(String args[]){
6.
7.
//String
array
8.
String[] strNames = new String[]{"John", "alex", "Chris", "williams","Mark", "Bob"};
9.
10.
/*
11.
* To sort String array
in java, use Arrays.sort method.
12.
* Sort method is a
static method. *
13.
*/
14.
15.
//sort
String array using sort method
16.
Arrays.sort(strNames);
17.
18.
System.out.println("String
array sorted (case sensitive)");
19.
20.
//print
sorted elements
21.
for(int i=0; i < strNames.length; i++){
22.
System.out.println(strNames[i]);
23.
}
24.
25.
/*
26.
* Please note that, by
default Arrays.sort method sorts the Strings
27.
* in case sensitive
manner.
28.
*
29.
* To sort an array of
Strings irrespective of case, use
30.
* Arrays.sort(String[]
strArray, String.CASE_INSENSITIVE_ORDER) method instead.
31.
*/
32.
33.
//case
insensitive sort
34.
Arrays.sort(strNames);
35.
36.
System.out.println("String
array sorted (case insensitive)");
37.
//print
sorted elements again
38.
for(int i=0; i < strNames.length; i++){
39.
System.out.println(strNames[i]);
40.
}
41.
42.
}
43. }
reverse a string:
new StringBuilder(“meeraja”).reverse().toString();
String s = "sample";
String result = new StringBuffer(s).reverse().toString();
import java.util.*;
class ReverseString
{
public static void main(String args[])
{
String original, reverse = "";
Scanner in = new Scanner(System.in);
System.out.println("Enter a string to reverse");
original = in.nextLine();
int length = original.length();
for ( int i = length - 1 ; i >= 0 ; i-- )
reverse = reverse + original.charAt(i);
System.out.println("Reverse of entered string is: "+reverse);
}
}