Search This Blog

Popular Posts

Saturday, December 24, 2011

Aspire – Java Assignment-2 - Solutions

1. Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
Solution:-
import java.util.*;
class Washingmachine
{
Scanner s=new Scanner(System.in);
public void switchOn()
{
System.out.println("Switched on");
}
public void start()
{
System.out.println("Machine started");
}
public void acceptDetergent()
{
System.out.println("Accept detergent");
start();
}
public int acceptClothes()
{
System.out.println("Enter number of clothes::");
return (s.nextInt());
}
public void switchOff()
{
System.out.println("Machine switched OFF");
}
public static void main(String args[])
{
Washingmachine ob=new Washingmachine();
ob.switchOn();
int n=ob.acceptClothes();
ob.acceptDetergent();
ob.switchOff();
System.out.println("the number of clothes washed are ::"+n);
}
}
------------------------------------------------------------------------------------------------------------
2. Create a calculator class which will have methods add, multiply, divide & subtract
Solution:-
import java.util.*;
public class Calculator
{
public double add(double a, double b)
{
return a+b;
}
public double subtract(double a, double b)
{
return a-b;
}
public double multiply(double a, double b)
{
return a*b;
}
public double divide(double a, double b)
{
return a/b;
}



public static void main(String args[])
{
Calculator ob=new Calculator();
Scanner s=new Scanner(System.in);
System.out.println("Enter the choice for the following computation to be performed :-");
System.out.println("1.Addition \n 2.Subtraction \n 3.Multiplication \n 4.Division");
int ch=s.nextInt();
System.out.print("Enter the two operands ::");
int a=s.nextInt();
int b=s.nextInt();
switch (ch)
{
case 1:
System.out.println("The sum of "+a+"+"+b+" = "+ob.add(a,b));
break;
case 2:
System.out.println("The subtraction of "+a+"-"+b+" = "+ob.subtract(a,b));
break;
case 3:
System.out.println("The multiplication of "+a+"x"+b+" = "+ob.multiply(a,b));
break;
case 4:
System.out.println("The division of "+a+"/"+b+" = "+ob.divide(a,b));
break;
default:
System.out.println("Wrong choice!!!");
}

}
}
------------------------------------------------------------------------------------------------------------
3. Create a class called Student which has the following methods:
i. Average: which would accept marks of 3 examinations & return whether the student has passed or failed depending on whether he has scored an average above 50 or not.
ii. Inputname: which would accept the name of the student & returns the name.
Solution:-
import java.util.*;
public class Student
{
Scanner s=new Scanner(System.in);
public String Average()
{
System.out.println("Enter Marks1: ");
double m1=s.nextDouble();
System.out.println("Enter Marks2: ");
double m2=s.nextDouble();
System.out.println("Enter Marks3: ");
double m3=s.nextDouble();
double tm=m1+m2+m3;
double avg=tm/3;
if(avg<50)
{
return "Failed";
}
if(avg>50)
{
return "Passed";
}
return " ";
}
public String Inputname()
{
System.out.println("Enter Name: ");
String name=s.nextLine();
return Average();
}
public static void main(String args[])
{
Student ob=new Student();
System.out.println(ob.Inputname());
}
}
------------------------------------------------------------------------------------------------------------
4. Create a Bank class with methods deposit & withdraw. The deposit method would accept attributes amount & balance & returns the new balance which is the sum of amount & balance. Similarly, the withdraw method would accept the attributes amount & balance & returns the new balance ‘balance – amount’ if balance > = amount or return 0 otherwise.
Solution:-
import java.util.*;
public class Bank
{
int bal;
Bank(int bal)
{
this.bal=bal;
}
int deposit(int amt)
{
if(amt<0)
{
System.out.println("Invalid Amount");
return 1;
}
System.out.println("Money deposited !!!");
return (bal+amt);

}
int withdraw(int amt)
{
if(bal {
System.out.println("Not Sufficient balance.");
return 0;
}
if(amt<0)
{
System.out.println("Invalid Amount");
return 0 ;
}
bal=bal-amt;
System.out.println("Withdrawal done !!!");
return bal;
}

public static void main(String args[])
{
Scanner s=new Scanner(System.in);
Bank ob=new Bank(1000);
System.out.print("Enter 1.for Deposit \n 2.for Withdrawal :: ");
int ch=s.nextInt();
System.out.println("Enter the amount ::");
int amt=s.nextInt();
if(ch==1)
{
System.out.println("The new balance is :: "+ob.deposit(amt));
}
else
{
int ret=ob.withdraw(amt);
if(ret>0)
{
System.out.println("The new balance is :: "+ret);
}
}
}
}
------------------------------------------------------------------------------------------------------------
5. Create an Employee class which has methods netSalary which would accept salary & tax as arguments & returns the netSalary which is tax deducted from the salary. Also it has a method grade which would accept the grade of the employee & return grade.
Solution:-
import java.util.*;
class Employee
{
static Scanner s=new Scanner(System.in);
public double netSalary(double salary, double tax)
{
return (salary-tax);

}
public static String grade( )
{
System.out.print("Enter Grade: ");
return (s.next());
}
public static void main(String[] args)
{
Employee ob=new Employee();
System.out.print("Enter Salary: ");
double sal=s.nextDouble();
System.out.print("Enter Tax : ");
double tax=s.nextDouble();
String g=ob.grade();
double net=ob.netSalary(sal,tax);
System.out.println("Net Salary is: "+net);
System.out.println("Grade is: "+g);
}
}

------------------------------------------------------------------------------------------------------------
6. Create Product having following attributes: Product ID, Name, Category ID and UnitPrice. Create ElectricalProduct having the following additional attributes: VoltageRange and Wattage. Add a behavior to change the Wattage and price of the electrical product. Display the updated ElectricalProduct details.
Solution:-
import java.lang.*;
import java.util.*;
class Product
{
int productid;
String name;
int categoryid;
double unitprice;
public Product(int pid,String naam,int catid,double uniprice)
{
this.productid=pid;
this.name=naam;
this.categoryid=catid;
this.unitprice=uniprice;
}
}

class Electricalproduct extends Product
{
int voltagerange;
int wattage;
static Scanner s=new Scanner(System.in);

public Electricalproduct(int pid,String naam,int catid,double uniprice,int voltrange,int watt)
{
super(pid,naam,catid,uniprice);
this.voltagerange=voltrange;
this.wattage=watt;
}
public void display()
{
System.out.println("Product ID: "+productid);
System.out.println("Name: "+name);
System.out.println("Category ID: "+categoryid);
System.out.println("Price: "+unitprice);
System.out.println("Voltage Range: "+voltagerange);
System.out.println("Wattage: "+wattage);
}
public void behaviour()
{

System.out.print("Enter the new wattage::");
this.wattage=s.nextInt();
System.out.print("Enter new price::");
double price=s.nextDouble();

super.unitprice=price;
display();
}
public static void main(String []args)
{

System.out.println("Enter Product ID: ");
int pid=s.nextInt();
System.out.println("Enter Name: ");
String name=s.next();
System.out.println("Enter Catagory ID: ");
int cid=s.nextInt();
System.out.println("Enter Price: ");
double price=s.nextDouble();
System.out.println("Enter Voltage Range: ");
int vrange=s.nextInt();
System.out.println("Enter Wattage: ");
int wattage=s.nextInt();
System.out.println("****Details of Electrical Product****");
System.out.println();
Electricalproduct p=new Electricalproduct(pid,name,cid,price,vrange,wattage);
p.display();
System.out.println("*************************************************************");
System.out.println("Would u like to reenter the price and wattage(Press 1.for yes or 2 for No)::");
int ch=s.nextInt();
if(ch==1)
{p.behaviour();}
}
}

------------------------------------------------------------------------------------------------------------
7. Create Book having following attributes: Book ID, Title, Author and Price. Create Periodical which has the following additional attributes: Period (weekly, monthly etc...) .Add a behavior to modify the Price and the Period of the periodical. Display the updated periodical details.
Solution:-
import java.lang.*;
import java.util.*;
class Book
{
int bookid;
String title;
String author;
double price;
public Book(int bid,String tit,String auth,double price)
{
this.bookid=bid;
this.title=tit;
this.author=auth;
this.price=price;
}
}

class Periodical extends Book
{
String period;
static Scanner s=new Scanner(System.in);
public Periodical(int bid,String tit,String auth,double price,String period)
{
super(bid,tit,auth,price);
this.period=period;
}
public void display()
{
System.out.println("Book ID: "+bookid);
System.out.println("Title: "+title);
System.out.println("Author: "+author);
System.out.println("Price: "+price);
System.out.println("Period: "+period);
}
public void behaviour()
{

System.out.print("Enter the new period::");
this.period=s.next();
System.out.print("Enter new price::");
double price=s.nextDouble();

super.price=price;
display();
}
public static void main(String []args)
{

System.out.println("Enter Book ID: ");
int bid=s.nextInt();
System.out.println("Enter Title: ");
String tit=s.next();
System.out.println("Enter Author: ");
String auth=s.next();
System.out.println("Enter Price: ");
double price=s.nextDouble();
System.out.println("Enter Period: ");
String period=s.next();
System.out.println("*****Details*****");
Periodical p=new Periodical(bid,tit,auth,price,period);
p.display();
System.out.println("*************************************************************");
System.out.println("Would u like to reenter the price and Period(Press 1.for yes or 2 for No)::");
int ch=s.nextInt();
if(ch==1)
{p.behaviour();}
}
}
------------------------------------------------------------------------------------------------------------
8. Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional attributes:loading capacity( 100 tons…).Add a behavior to change the color and loading capacity. Display the updated truck details.
Solution:-
import java.lang.*;
import java.util.*;
class Vehicle
{
int vehicleno;
String model;
String manufacturer;
String color;
public Vehicle(int vno,String mod,String manu,String colr)
{
this.vehicleno=vno;
this.model=mod;
this.manufacturer=manu;
this.color=colr;
}
}

class Truck extends Vehicle
{
int loadingcapacity;
static Scanner s=new Scanner(System.in);
public Truck(int vno,String mod,String manu,String colr,int loadcap)
{
super(vno,mod,manu,colr);
this.loadingcapacity=loadcap;
}
public void display()
{
System.out.println("Vehicle number :: "+vehicleno);
System.out.println("Model :: "+model);
System.out.println("Manufacturer :: "+manufacturer);
System.out.println("Color :: "+color);
System.out.println("Loading Capacity:: "+loadingcapacity);
}
public void behaviour()
{

System.out.print("Enter the new color::");
super.color=s.next();
System.out.print("Enter new loading capacity::");
int ldcap=s.nextInt();

this.loadingcapacity=ldcap;
display();
}
public static void main(String []args)
{

System.out.println("Enter Vehicle No: ");
int vno=s.nextInt();
System.out.println("Enter Model: ");
String mod=s.next();
System.out.println("Enter Manufacturer: ");
String manu=s.next();
System.out.println("Enter Color: ");
String col=s.next();
System.out.println("Enter Loading Capacity: ");
int ldcap=s.nextInt();
System.out.println("*****Details*****");
Truck p=new Truck(vno,mod,manu,col,ldcap);
p.display();
System.out.println("*************************************************************");
System.out.println("Would u like to reenter the color and loading capacity(Press 1.for yes or 2 for No)::");
int ch=s.nextInt();
if(ch==1)
{p.behaviour();}
}
}
------------------------------------------------------------------------------------------------------------
9. Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results.
Solution:-
import java.util.*;
import java.text.*;
class Powerprg
{
public static void main(String[] args)
{
DecimalFormat df=new DecimalFormat("##.##");
Scanner input=new Scanner(System.in);
System.out.print("Enter Number: ");
double num=input.nextDouble();
System.out.print("Number raised to power: ");
double pow=input.nextDouble();
double value=Math.pow(num,pow);
System.out.println("Result is: "+df.format(value));
}
}
------------------------------------------------------------------------------------------------------------
10. Write a function Model-of-Category for a Tata motor dealers, which accepts category of car customer is looking for and returns the car Model available in that category. the function should accept the following categories "SUV", "SEDAN", "ECONOMY", and "MINI" which in turn returns "TATA SAFARI" , "TATA INDIGO" , "TATA INDICA" and "TATA NANO" respectively.
Solution:-
import java.util.*;
class Tata
{
String category;
String model;
Tata(String category,String model)
{
this.category=category;
this.model=model;
}
public String getCategory()
{
return category;
}
public String getModel()
{
return model;
}
public static void ModelOfCategory(ArrayList list)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter Category: (SUV/SEDAN/ECONOMY/MINI)");
String category=input.nextLine();
System.out.println();
System.out.print("Model is: ");
for (Tata tm : list)
{
if(tm.getCategory().equals(category))
{
System.out.print(tm.getModel());
}
}
}
public static void main(String[] args)
{
ArrayList list=new ArrayList();
list.add(new Tata("SUV","TATA SAFARI"));
list.add(new Tata("SEDAN","TATA INDIGO"));
list.add(new Tata("ECONOMY","TATA INDICA"));
list.add(new Tata("MINI","TATA NANO"));
ModelOfCategory(list);
}
}


------------------------------------------------------------------------------------------------------------

Aspire – Java Assignment-1 - Solutions

Aspire – Java Assignment-1 - Solutions

1. Write a program to find the difference between sum of the squares and the square of the sums of n numbers?

import java.io.*;
import java.util.Scanner;
class Difference
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the value of n:");
int n=s.nextInt();
int a[]=new int[n];
int i,sqr,diff,sum=0,add=0;
System.out.print("The "+n);
System.out.println(" Numbers are: ");
for(i=0;i {
a[i]=s.nextInt();
sum+=(a[i]*a[i]);
add+=a[i];
}
sqr=add*add;
diff=sqr-sum;
System.out.println("");
System.out.print("Sum of Squares given "+n);
System.out.println(" numbers is :"+sum);
System.out.print("Squares of Sum of given " +n);
System.out.println(" numbers is :" +sqr);
System.out.println("");
System.out.println("Difference between sum of the squares and the square of the sum of given "+n);
System.out.print(" number is :"+diff);
System.out.println("");
}
}

2. Develop a program that accepts the area of a square and will calculate its perimeter.

import java.util.Scanner;
public class SquarePeri
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("Area of Square:");
double a=s.nextDouble();
double p=4*Math.sqrt(a);
System.out.println("");
System.out.print("Perimeter of the Square:"+p);
System.out.println("");
}
}

3. Develop the program calculate Cylinder Volume., which accepts radius of a cylinder’s base disk and its height and computes the volume of the cylinder.

import java.io.*;
import java.util.Scanner;
class CylinderVolume
{
public static void main(String args[]) throws IOException
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the radius:");
double rad=s.nextDouble();
System.out.println("Enter the height:");
double ht=s.nextDouble();
double vol=Math.PI*rad*rad*ht;
System.out.println("");
System.out.println("Volume of the Cylinder is: "+vol);
}
}
4. Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%.Define the program calculate Tax which determines the tax on the gross pay. Define calculate NetPay that determines the net pay of an employee from the number of hours worked. Assume an hourly rate of $12.

import java.util.Scanner;
public class Tax
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the no of working days in the year: ");
int d=s.nextInt();
System.out.println("Enter the no of working hours in a day:");
int h=s.nextInt();
System.out.println("Enter the no of hours worked in over time:");
int ot=s.nextInt();
System.out.println("Enter the no of hours took leave: ");
int l=s.nextInt();
double gross=((d*h)+ot-l)*12;
double tax=gross*0.15;
double net=gross-tax;
System.out.println("");
System.out.println("Gross Pay (in $) : "+gross);
System.out.println("Tax (in$) : "+tax);
System.out.println("Net Pay (in $) : "+net);
}
}

5. An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee.Develop the program calculate TotalProfit that consumes the number of attendees (of a show) and calculates how much income the show earns.
import java.util.Scanner;
public class TotalProfit
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the no of attendees of a show: ");
int n=s.nextInt();
double profit=(n*5)-(20+(n*0.5));
System.out.println("");
System.out.println("Total Profit of the theater per show (in $) is : "+profit);
}
}

6. Develop the program calculate Cylinder Area, which accepts radius of the cylinder’s base disk and its height and computes surface area of the cylinder.

import java.util.Scanner;
public class CylinderArea
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the base radius:");
double rad=s.nextDouble();
System.out.println("Enter the height:");
double ht=s.nextDouble();
double area=2*Math.PI*rad*(rad+ht);
System.out.println("");
System.out.println("Surface Area of the Cylinder is :" + area);
}
}
7. Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accepts three values: the pipes inner radius, its length, and the thickness of its wall.

import java.util.Scanner;
public class PipeArea
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the inner radius: ");
double rad=s.nextDouble();
System.out.println("Enter the length: ");
double len=s.nextDouble();
System.out.println("Enter the thickness: ");
double thick=s.nextDouble();
double area=2*Math.PI*(rad+thick)*len;
System.out.println("");
System.out.println("Surface Area of The Pipe is: "+area );
}

8. Develop the program calculateHeight, which computes the height that a rocket reaches in a given amount of time.If the rocket accelerates at a constant rate g, it reaches a speed of g • t in t time units and a height of 1/2 * v * t where v is the speed at t.

import java.util.Scanner;
public class Height
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the time (in seconds) : ");
double t=s.nextDouble();
double v=9.8*t;
double ht=0.5*v*t;
System.out.println("");
System.out.println("Height reached (in meters) is : " +ht);
}
}
9. Develop a program that computes the distance a boat travels across a river, given the width of the river ,the boat’s speed perpendicular to the river, and the river’s speed. Speed is distance/time, and the Pythagorean Theorem is c2 = a2 + b2.

import java.util.Scanner;
public class BoatDistance
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the width of the river (in meters): ");
double rw=s.nextDouble();
System.out.println("Enter the river's speed (in meter/sec) : ");
double rs=s.nextDouble();
System.out.println("Enter the boat's speed (in meter/sec) : ");
double bs=s.nextDouble();
double time=rw/bs; //time takes to traverl from shore to shore straight by the boat
double w2=time*rs; //distance due to down stream
double bd=Math.sqrt((rw*rw)+(w2*w2));
System.out.println("");
System.out.println("The distance travelled by boat (in meters) is : "+bd);
}
}
10. Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional deposits or withdrawals are made and that a month is 1/12 of a year. Total interest is the product of the principal, the annual interest rate expressed as a decimal, and the number of years.

import java.util.Scanner;
public class Balance
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the principal amount : ");
double p=s.nextDouble();
System.out.println("Enter the annual interest rate: ");
double r=s.nextDouble();
System.out.println("Enter the no of months: ");
double m=s.nextDouble();
double si=(p*(m/12)*r)/100;
double bal=p+si;
System.out.println("");
System.out.print("Balance after " +(int)m);
System.out.println(" month(s) is: "+bal);
}
}

Wednesday, December 21, 2011

Basic of programming SOLUTIONS 2 TCS ASPIRE

class Problem1 /* creating a class problem1 */

{ /* opening braces for class problem1 */

int[] a; /* declaring an array of integer */

int nElems; /* declaring an variable of data type integer */

public void ArrayBub(int max) /* ArrayBub is defining a new parameterised method */

{

a = new int[max]; /* to initialize the array with 'max' as size of the array */

}

public void insert(int value) /* defining the insert method to insert values in the array */

{

a[nElems] = value; /* assigning the value to array at current position */

nElems++; /* incrementing the position counter */

}

public void Sort() /* defining the method to sort the array */

{

int out, in; /* out & in are two variables of type integer */

for(out=nElems-1; out>1; out--) /* outer loop starting from lenght of array - 1 to last element */

/* when outer loop's condition become true then control pass to innner loop. inner loop will execute
till the condition of inner loop will be true. */

for(in=0; in
if( a[in] > a[in+1] ) /* checking condition Is element of a[in] is greater than a[in+1]*/
/* if condition is true swap the value by calling swap function .
if condition is false control goes to outer loop */

swap(in, in+1); /* calling method swap & passing arguments */

}

public void swap(int one, int two) /* creating method swap with two parameters of type integer */

{

long temp = a[one]; /* taking varibale temp & storing value of a[one] */

a[one] = a[two]; /* value of a[two] is stoder in a[one] */

a[two] = temp; /* now temp is stored in a[two]. value is swaped now and temp is free */

}

Basic of programming SOLUTIONS 1 TCS ASPIRE

//Improve the understandability of the below given code:



import java.util.*; /* it is importing all class in java.util package */

class problem3 /* creating a class problem3 */

{ /* opening braces for class problem3 */

int[] numArray = new int[10]; /* declaring an array of integer named numArray & is assigned with 10 element */

public static void incrementElements (int[] integerArray) /* a method named incrementElements whose return type
void it means it is not returning any value.
Static means it can be automaticaly called.
public means it can be called anywhere in the program.
passing parameter array of integer */

{ /* opening braces for method incrementElements */

int arraylen = integerArray.length; /* arraylen is any variable of data type integer which
calculated lenght of array by using integerArray.length */

for (int i = 0; i < arraylen; i ++) /* a loop stating from i=0 to lenght of array and increment every time
by +1 */

{

System.out.println(integerArray[i]); /* printing present integer value of array */

}

for (int i = 0; i < arraylen; i ++) /* same foor loop is called */

{

integerArray[i] = integerArray[i] + 10; /* printing value by increamenting 10 in each present value of array */

}

for (int i=0; i < arraylen; i ++) /* same foor loop is called */

{

System.out.println(integerArray[i]); /* last printed value will be reprint */

}

}

Database assignment solutions TCS ASPIRE

Question 1: Provide the create table syntax to Create a Table Employee whose details are as below.
Employee(EmployeeID, LastName, FirstName, Address, DateHired)
Answer:
CREATE TABLE Employee (EmployeeID int(10) , LastName varchar(45),
FirstName varchar(45), Address varchar(45), DateHired datetime,
PRIMARY KEY (EmployeeID) );

Question 2: Provide the INSERT query to be used in Employee Table to fill the Details.
Answer:
insert into Employee values(1,'dwivedi','anand','lucknow','2011-12-20');

Question 3: When we give SELECT * FROM EMPLOYEE .How does it Respond?
Answer: it gives all the records of employee table.

Question 4: Create a Table CLIENT whose details are as below.
Client(ClientID, LastName, FirstName, Balance, EmployeeID)
Answer:
CREATE TABLE CLIENT(ClientID integer(10),
LastName varchar(45), Balance float(45), EmployeeID integer(10),
PRIMARY KEY (ClientID));

Question 5: Provide the INSERT query to be used in CLIENT Table to fill the Details.
Answer: insert into CLIENT values(1,'abc',100.04,25);

Question 6: When we give SELECT * FROM CLIENT .How does it Respond?
Answer: It returns all records from CLIENT table.

Question 7: Choose the correct answer. The SQL command to create a table is:
a. Make Table
b. Alter Table
c. Define Table
d. Create Table

Answer: d

Question 8: Choose the correct answer. The DROP TABLE statement:
a. deletes the table structure only
b. deletes the table structure along with the table data
c. works whether or not referential integrity constraints would be violated
d. is not an SQL statement

Answer: b

Question 9: What are the different data types available in SQL server?
Answer: Data types in SQL Server are organized into the following categories:
1. Exact numerics
2. Approximate numerics
3. Date and time
4. Character strings
5. Unicode character strings
6. Binary strings
7. Others


Question 10: Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
Answer:
DDL: Data Definition Language is the subset which is used to manipulate Oracle database structures. i.e. Create, Alter, Drop

DML statements manipulate only data within the data structures already created by DDL statements.

Question 11: What operator performs pattern matching?
Answer: "like" is the operator used in pattern matching.

Question 12: What operator tests column for the absence of data?
Answer: "is null" operator
Example: select employeeID from Employee where Address is null

Question 13: Which command executes the contents of a specified file?
Answer: START or @.

Question 14: What is the parameter substitution symbol used with INSERT INTO command?
Answer: & is substitution symbol used with insert into command.

Question 15: Which command displays the SQL command in the SQL buffer, and then executes it?
Answer: Run

Question 16: What are the wildcards used for pattern matching?
Answer:
_ for single character substitution
% for multi-character substitution
[charlist] wildcard

Question 17: State whether true or false.
EXISTS, SOME, ANY are operators in SQL.
Answer: True

Question 18: State whether true or false.
!=, <>, ^= all denote the same operation.
Answer: True

Question 19: What are the privileges that can be granted on a table by a user to others?
Answer: Insert, update, delete, select, references, index, execute, alter, all

Question 20: What command is used to get back the privileges offered by the GRANT command?
Answer:
"revoke" is the command which revokes access privileges for database objects previously granted to other users.


Question 21: Which system tables contain information on privileges granted and privileges obtained?
Answer: user_tab_privs_made , user_tab_privs_recd

Question 22: Which system table contains information on constraints on all the tables created?
Answer:
USER_CONSTRAINTS (show all constraints created by the user who has logged in)
ALL_CONSTRAINTS (accessible for dba user only)

Question 23: What is the difference between TRUNCATE and DELETE commands?
Answer:
1. TRUNCATE is a DDL command whereas DELETE is a DML command.
2. TRUNCATE is much faster than DELETE.
3.You cannot rollback in TRUNCATE but in DELETE you can rollback.
TRUNCATE removes the record permanently.
4.In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE ,Trigger get fired.
5.You cannot use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause

Question 24: What command is used to create a table by copying the structure of another table?
Answer: Select * into newtablename from oldtablename

Monday, December 19, 2011

Web Technology Quiz in TCS ASPIRE

1.What is the correct syntax of the declaration which defines the XML version?
Option: a. < ? xml version="1.0" ? >
b. < xml version="1.0" />
c. < xml version="1.0"? />
d. None of the above
e. < ? xml version="1.0" ? />
Ans: a

2.What is the correct syntax for referring to an external script called "xxx.js"?
option: a. None
b. < script type="text/javascript" name="xxx.js" >
c. < script type="text/javascript" href="xxx.js" >
d. < script type="text/javascript" src="xxx.js" >
ans: d

3. What is the correct HTML for referring to an external style sheet?
option : a. < stylesheet>mystyle.css
b. None of the above
c. < style src="mystyle.css" />
d. < link ="stylesheet" type=text/css/script href="mystyle.css" >
e. < link rel="stylesheet" type="text/css" href="mystyle.css" />
Ans: e

4. What can you use to replace like with hate in I like Eminem?
Option : a. preg_replace("/like/", "/hate/", "I like Eminem")
b. preg_replace("hate", "like", "I like Eminem")
c. preg_replace("/like/", "hate", "I like Eminem")
d. None of the above
e. preg_replace("like", "hate", "I like Eminem")
ans: e

5. What are the genral syntax for inline image?
Option: a. None of the above
b. img=file
c. img src=file
d. src=image
e. image src=file
Ans: e

Database Concepts Quiz TCS ASPIRE

1. Which of following represent logical storage of data?
Option :
a. Table
b. View
c. None.
d. Index
Ans: b

2. Which SQL statement is used to extract data from a database?
option:
a. SELECT
b. EXTRACT
c. OPEN
d. GET
Ans: a

3. With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?
Options:
a. SELECT * FROM Persons SORT 'FirstName' DESC
b. SELECT * FROM Persons SORT BY 'FirstName' DESC
c. SELECT * FROM Persons ORDER BY FirstName DESC
d. None of the above
e. SELECT * FROM Persons ORDER FirstName DESC

Ans: c

4. With SQL, how can you return the number of records in the "Persons" table?
Options:
a. SELECT COUNT(*) FROM Persons
b. SELECT COLUMNS(*) FROM Persons
c. None of the above
d. SELECT COLUMNS() FROM Persons
e. SELECT COUNT() FROM Persons
Ans : a
5. How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?
Options:
a. UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen'
b. MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'
c. MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen
d. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'
Ans: d

Saturday, December 17, 2011

Quiz on Software Engineering (Assignment 2) TCS ASPIRE

1.Which of the following is closer to machine Code ?
Choose one answer.
a. Machine language
b. High level language
c. None of the above
d. Assembly language
e. All of the above

ans : d

2.Software genetic development process contains three genetic phrases namely.
Choose one answer.
a. Development, Definition, Testing
b. Software engineering, Definition, Coding
c. Definition, development, maintenance.
d. Design, Coding, Development
e. Coding, design, Software engineering

ans : c


3.The following are characteristics of software expects
Choose one answer.
a. Software does not wear out
b. Software have don’t have spare parts instead it has backup
c. It is developed or engineered.
d. Software consists of physical devices.
e. Software are custom made

ans : d

4.Which is the last step in classic life cycle paradigm?
Choose one answer.
a. Analysis
b. System engineering
c. Coding
d. Design
e. Maintenance.

ans : e

5.The following are properties of Modularity except
Choose one answer.
a. It has a single entry and exit point.
b. It implement a single independent function
c. It is entirely constructed of modules.
d. None of the above.
e. It performs a single logical task.

ans : d



6.The following are characteristics of software expects
Choose one answer.
a. Software are custom made
b. Software consists of physical devices.
c. It is developed or engineered.
d. Software does not wear out
e. Software have don’t have spare parts instead it has backup

ans : b

Software Engineering Quiz Solution (Assignment 1) TCS ASPIRE

1.Which of the following Construct in formal model in software engineering execute each statement in succession.
Choose one answer.
a. Iteration Construct.
b. Statement Construct.
c. Selection Construct.
d. Business Construct.
e. Sequence Construct.

Ans : e

2.What is software engineering?
Choose one answer.
a. Software engineering implement a single independent function
b. Set of computer programs, procedures and possibly associated document concerned with the operation of data processing.
c. None of the above
d. Software engineering is the establishment and use of sound engineering practice in order to produce economical and reliable software that will perform efficiently on real machine
e. Software engineering is Design, Coding, Development


ans : d


3.What is a software?

Choose one answer.
a. A mathematical formulae
b. A set of compiler instructions.
c. None of the above
d. Set of computer programs, procedures and possibly associated document concerned with the operation of data processing.
e. All of the above

ans : d


4.Which of the following translators convert high-level language on statement-by-statement basis?
Choose one answer.
a. Interpreter.
b. Assembler
c. Machine level language converter
d. Compiler

ans : a


5.Which of the following is not an example of Prototype in engineering paradigm?
Choose one answer.
a. Paper prototype.
b. Software prototype.
c. Existing prototype.
d. Engineering prototype.
e. Working prototype.

ans : a

Know Your TCS Quiz in TCS ASPIRE

1.Which Geography gives the maximum revenue for TCS?
Choose one answer.
a. Africa
b. India
c. Asia Pacific
d. North America
Ans : d

2.Which of the following is not an ISU?

Choose one answer.
a. BFSI
b. IT IS
c. Retail
d. Telecom

ans: b

3.What is TCS revenue in FY 2010 in USD Billions?
Choose one answer.
a. 10
b. 6.8
c. 7.5
d. 6.3

ans : d

4.Which service area generated the maximum revenue?
Choose one answer.
a. BPO
b. Consulting
c. IT IS
d. ADM
ans: d

5.How many ISU are there in TCS?
Choose one answer.
a. 10
b. 14
c. 12
d. 11
e. 13
ans: c