Wednesday, 31 October 2012

TCS Pattern Questions-6


PATTERN 41
 1) On planet korba, a solar blast has melted the ice caps on its equator. 9 years after the ice melts, tiny planetoids called echina start growing on the rocks. Echina grows in the form of circle, and the relationship between the diameter of this circle and the age of echina is given by the formula d = 4*√ (t-9) for t ≥ 9 where d represents the diameter in mm and t the number of years since the solar blast.Jagan recorded the radius of some echina at a particular spot as 7mm. How many years back did the solar blast occur?
a) 17 b)21.25 c)12.25 d)14.05
 Solution: radius =7mm, then diameter 2*radius,substitute diameter d in above equation u will get answer

 PATTERN 42
 1)A man goes 50Km north , then turned left walked 40Km, then turned right ? In which direction he is? a)North b)South c)East d)West

 PATTERN 43 
1)In T.Nagar the building were numbered from 1 to 100.Then how many 4‟s will be present in the numbers?
 a)18 b)19 c)20 d)21.
Solution:you have to count and answer but be prepare with answer

2)In T.Nagar the building were numbered from 1 to 100.Then how many 6‟s will be present in the numbers? a)18 b)19 c)20 d)21

3)In T.Nagar the building were numbered from 1 to 100.Then how many 1‟s will be present in the numbers? a)18 b)19 c)20 d)21 4)In T.Nagar the building were numbered from 1 to 100.Then how many 0‟s will be present in the numbers?
 a)18 b)19 c)20 d)11

PATTERN 44
 1) A number when divided by D leaves a remainder of 8 and when divided by 3D leaves a remainder of 21. What is the remainder left, when twice the number is divided by 3D?
a)13 b) cannot be determined c) 3 d) 42

 PATTERN 45
 1.) Ferrari S.P.A is an Italian sports car manufacturer based in Maranello, Italy. Founded by Enzo Ferrari in 1928 as Scuderia Ferrari, the company sponsored drivers and manufactured race cars before moving into production of street-legal vehicles in 1947 as Ferrari S.P.A. Throughout its history, the company has been noted for its continued participation in racing, especially in Formula One where it has employed great success .Rohit once bought a Ferrari. It could go 4 times as fast as Mohan's old Mercedes. If the speed of Mohan's Mercedes is 35 km/hr and the distance traveled by the Ferrari is 490 km, find the total time taken for Rohit to drive that distance.
 a)20.72 b) 3.5 c) 238.25 d) 6.18
Solution:speed of Ferrari =4*35=140,time=distance/velocity

 2) Ferrari S.P.A is an Italian sports car manufacturer based in Marane llo, Italy. Founded by Enzo Ferrari in 1928 as Scuderia Ferrari, the company sponsored drivers and manufactured race cars before moving into production of street-legal vehicles in 1947 as Ferrari S.P.A. Throughout its history, the company has been noted for its continued participation in racing, especially in Formula One where it has employed great success .Rohit once bought a Ferrari. It could go 4 times as fast as Mohan's old Mercedes. If the speed of Mohan's Mercedes is 46 km/hr and the distance traveled by the Ferrari is 953 km, find the total time taken for Rohit to drive that distance.
 a)20.72 b) 5.18 c) 238.25 d) 6.18

PATTERN 46
 1) A sheet of paper has statements numbered from 1 to 70. For all values of n from 1 to 70. Statement n says ' At least n of the statements on this sheet are false. „Which statements are true and which are false?
 a) The even numbered statements are true and the odd numbered are false.
b) The odd numbered statements are true and the even numbered are false.
c) The first 35 statements are true and the last 35 are false.
 d) The first 35 statements are false and the last 35 are false.

PATTERN 47
 1) A man goes north 37km.turns left goes 2km.turns right goes 17km.turns right goes 2km. find distance b/w starting ending point.
a) 54 b) 27 c) 81 d) 67

PATTERN 48
 1) If there are 30 cans out of them one is poisoned if a person tastes very little he will die within 14 hours so if there are mice to test and 24 hours to test, how many mices are required to find the poisoned can?
a) 3 b) 2 c) 6 d) 1

 PATTERN 49
 1) If a and b are mixed in 3:5 ration and b and c are mixed in 8:5 ration if the final mixture is 35 liters, find the amount of b?
a) 13.34 b) 15.73 c) 16.73 d) 9.45
Solution:solve for a:b:c,then b ratio is b/(a+b+c)*35

PATTERN 50 
1) If we subtract a number with y, we get 4 increase of number, once it got divided by y itself... Find that number??
 a) 13 b) 12 c) 14 d) 11

TCS Pattern Question-5


Pattern-31
 1. Entry ticket to an exhibition ranges from 1p to 31p. You need to provide exact change at the counter. You have 31p coin. In how many parts will u divide 31p so that u will provide the exact change required and carry as less coins as possible?
a)4 b)5 c)6 d)7
Solution: in btech we studied 8 4 2 1 code for binary system in digital logic proceed in that way for answer it is 16 8 4 2 1 if u add all we will get 31 so 5 coins required

Pattern 32 
1. Peter and Paul are two friends. The sum of their ages is 35 years. Peter is twice as old as Paul was when Peter was as old as Paul is now. What is the present age of Peter?
a)8 b)20 c)16 d)15

 Pattern 33
 1. 20 men handshake with each other without repetition. What is the total number of handshakes made? a)190 b)210 c)150 d)250

2.10 people are there, they are shaking hands together, how many hand shakes possible, if they are in no pair of cyclic sequence.
a)45 b)9 c)12 d)10

Pattern 34
1. If there are 2 wheelers and 4 wheelers parked in a school located at the heart of the city, find the number of 4 wheelers parked there if there were 20 two wheelers parked there
a)48 b)50 c)52 d)64
 Solution: proceed with answer is best in question they will give total no of wheels

2. If there are 2 wheelers and 4 wheelers parked in a school located at the heart of the city, find the number of 4 wheelers parked there if there were 58 wheels are parked there
 a)10 b)33 c)22 d)none

Pattern 35 
1. A man whose age is 45 yrs has 3 sons named John, Jill, jack. He went to a park weekly twice. He loves his sons very much. On a certain day he found the shop keepers selling different things. An apple cost 1penny, 2chocalate costs 1penny & 3 bananas cost 1 penny. He has bought equal number of apple, chocolate & banana for each son. If the total amount he invest is 7 penny then how many he has bought from each piece for his son?
a)1app,1cho,1 banana b)1 app,2cho,3 banana c)1app,2cho,1banana

2. One person had three children. He had 7 pennies. Find the distribution of the fruits among the three children. A melon costs 1 penny, 2 oranges cost 1 penny and 3 grapes cost 1 penny
a)2 melons, 1 orange, 1 grape b) 2 melons, 2 orange, 1 grape c) 1 melons, 2 orange, 1 grape.

PATTERN 36
 1) The age of the two friends were in the ration of 6:5.If the sum of their ages is 55.Then after how many years their ratio will become 8:7?
 a)11 b)7 c)10 d)12
Solution: 6x+5x=55, so x=5,put first ratio after substitution is (6*5)/(5*5) and second ratio is 40/35 So difference in numerators 40-30=10 years

2)The age of the two friends were in the ration of 6:5.If the sum of their ages is 66.Then after how many years their ratio will become 7:6?
 a)11 b)6 c)10 d)12

3) The age of the two friends were in the ration of 2:3.If the sum of their ages is 55.Then after how many years their ratio will become 4:5?
a)11 b)33 c)22 d)44

PATTERN 37
 1)A volume of 10936 l water is in a container of sphere.How many semisphere of volume 4l each will be required to tranfer all the water into the small semispheres?
 a)2812 b)8231 c)2734 d)4222

 PATTERN 38 
1)A person ismanufacturing a house.He bought 20 ropes of wire which has a density of 300 Kg/m3.The height of the building to be constructed is 40 m.If the capacity of the current passed in the wire is 20 A and the voltage capacity is 80 Volts.Then what will be the opposing force to the current if the wire is used ?
a)2 b)4 c)8 d)1600
Solution: ohms law V=IR,Opposing force of current is resistance,R=v/i

PATTERN 39
 1)A horse chases a pony 2 hours after the pony runs.Horse takes 3 hours to reach the pony.If the average speed of the horse is 81Kmph.Then what is the average speed of the pony?
 a)46.4 b)51 c)53.4 d)48.6
 Solution:Horse takes 3 hours to cover the distance Pony takes 3+2 =5 hours to cover the same distance,Velocity=distance/time,distance travelled by them is equal it is 81*3=243km,speed of pony=243/5=48.6

 2) A horse chases a pony 3 hours after the pony runs. Horse takes 4 hours to reach the pony. If the average speed of the horse is 35 kmph, what s the average speed of the pony?

3) A horse chases a pony 3 hours after the pony runs. Horse takes 4 hours to reach the pony. If the average speed of the horse is 35 kmph, what s the average speed of the pony

 PATTERN 40 
1)The difference between two no is 9 and the product of the two is 14.What is the square of their sum?
 a)120 b)130 c)137 d)145
Solution:a-b=9,ab=14,(a-b)2=a2+b2-2*a*b

2) The sum of two no is 5 and the product of the two is 14.What is the sum of their squares?

3) The sum of the squares of two no is 12 and their sum is 15.Find the product of the two no?

Tuesday, 30 October 2012

TCS Pattern Questions-4


Pattern 21: 
1. A Person buys a horse for 15 ponds, after one year he sells it for 20 pounds. After one year, again he buys the same horse at 30 pounds and sells it for 40 pounds. What is the profit for that person?
Solution: here we cannot consider depreciation or decay of item accto answer so go acc to answer Totally 5+10=15$profit

Pattern 22: 
1. John buys a cycle for 31 dollars and given a cheque of amount 35 dollars. Shop Keeper exchanged the cheque with his neighbor and gave change to John. After 2 days, it is known that cheque is bounced. Shop keeper paid the amount to his neighbor. The cost price of cycle is 19 dollars. What is the profit/loss for shop keeper?
 a)loss 23 b)gain 23 c)gain 54 d)Loss 54
Solution: loss =change of money given to john(4$)+actual cycle cost 19$=23$ loss

Pattern 23:
 1. A lady has fine gloves and hats in her closet- 18 blue, 32 red, and 25 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove. How many gloves must she take out to make sure she has a pair of each color?
a)50 b)8 c)60 d)42
Solution: i am not able to answer this if i go in procedure way so search in net by searching question .better see below website

http://www.m4maths.com/placement-puzzles.php?
http://www.allinterview.com/company/Tcs.html my answered questions may be answered there.


2. A lady has fine gloves and hats in her closet- 14 blue, 20 red, and 18 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove. How many gloves must she take out to make sure she has a pair of each color?

3. A lady has fine gloves and hats in her closet- 13 blue, 27 red, and 40 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove. How many gloves must she take out to make sure she has a pair of each color?

4. A lady has fine gloves and hats in her closet- 25blue, 7 red, and 9 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove. How many gloves must she take out to make sure she has a pair of each color?

 5. A lady has fine gloves and hats in her closet- 26 blue, 30 red, and 56 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove. How many gloves must she take out to make sure she has a pair of each color?

 Pattern 24: 
1. Sangakara and Ponting selects batting by using a dice, but dice is biased. So to resolve, Ponting takes out a coin. What is the probability that coin shows correct option?
 a)1/2 b)1/6 c)1/12 d)6/10
Solution is  ½.

 2. There is a die with 10 faces. It is not known that fair or not. 2 captains want to toss die for batting selection. What is the possible solution among the following?
a) If no. is odd it is head, if no. is even it is tail      
b) If no. is odd it is tail, if no. is even it is head
c) Toss a die until all the 10 digits appear on top face. And if first no. in the sequence is odd then consider it as tail. If it is even consider it as head.

Pattern 25: 
1. In a family there are some boys and girls. All boys told that they are having equal no of brothers and sisters and girls told that they are having twice the no. of brothers than sisters. How many boys and girls present in a family?
a)4 boys and 3 girls b)3 boys and 4 girls c)2 boys and 5 girls d)5 boys and 2 girls

Pattern 26
1. 10men and 10 women are there, they dance with each other, is there possibility that 2 men are dancing with same women and vice versa?
 a)22 b)20 c)10 d)none

2. There are 100 men and 100 women on the dance floor. They want to dance with each other. Then which of the following statements is always true:
 a) There are 2 men who danced with equal no. of women‟s
 b) There are 2 women who danced with equal no. of men
    a) both a and b
    b)only a
    c)only b
    d)none

Pattern 27: 
1. Middle- earth is a fictional land inhabited by hobbits, elves, dwarves and men. The hobbits and elves are peaceful creatures that prefer slow, silent lives and appreciate nature and art. The dwarves and the men engage in physical games. The game is as follows. A tournament is one where out of the two teams that play a match, the one that loses get eliminated. The matches are played in different rounds, where in every round; half of the teams get eliminated from the tournament. If there are 8 rounds played in knock out tournament, how many matches were played?
a)257 b)256 c)72 d)255
Solution:do not know perfect logic 28

2. A game is played between 2 players and one player is declared as winner. All the winners from first round are played in second round. All the winners from second round are played in third round and so on. If 8 rounds are played to declare only one player as winner, how many players are played in first round?
a)256 b)512 c)64 d)128

Pattern 28:
 1. Metal strip of width „x‟ cm. 2 metal strips are placed one over the other, then the combine length of 2 strips is „y‟. If „z‟ strips are placed in that manner. What is the final width of that arrangement?

2. A, B, C, D, E are there among A, B, C are boys and D, E are girls D is to the left of A and no girl sits at the middle and at the extemes. Then what is the order of their sittings.

Pattern 29: 
1. There is 7 friends (A1, A2, A3....A7).If A1 have to have shake with all without repeat. How many handshakes possible?
 a)6 b)21 c)28 d)7
Solution:For handshakes type question i am confirming u that if the there are n members are there Handshakes are given in linear manner =n-1(last person cannot give hand shake to first person) Handshakes are given in cyclic manner =n(last person can give hand shake to first person) But i do not know perfectly for repetition it is nc2

2. 49 members attended the party. In that 22 are males, 17 are females. The shake hands between males, females, male and female. Total 12 people given shake hands. How many such kinds of such shake hands are possible?
a)122 b)66 c)48 d)128

 Pattern 30: 
1. B is taller than j and 3 pillars. P is shorter than B and 2 pillars is j shorter/taller than P? a)yes b)no c)may be d)can‟t find 2. There are 1000 pillars for a temple. 3 friends Linda, Chelsey, Juli visited that temple. (Some unrelated stuff) Linda is taller than Chelsea and taller than 2 of 1000 pillars. Julia is shorter than Linda. Find the correct sentence?
 a) Linda is shorter among them b) Chelsea is taller than Julia
 c) Chelsea is shorter than Julia d) Cannot determine who is taller among Chelsea and Julia

Sunday, 28 October 2012

Routing Techniques

What Is Routing?
Routing is the act of moving information across an internetwork from a source to a destination. Along the way, at least one intermediate node typically is encountered. Routing is often contrasted with bridging, which might seem to accomplish precisely the same thing to the casual observer. The primary difference between the two is that bridging occurs at Layer 2 (the link layer) of the OSI reference model, whereas routing occurs at Layer 3 (the network layer). This distinction provides routing and bridging with different information to use in the process of moving information from source to destination, so the two functions accomplish their tasks in different ways.

The topic of routing has been covered in computer science literature for more than two decades, but routing achieved commercial popularity as late as the mid-1980s. The primary reason for this time lag is that networks in the 1970s were simple, homogeneous environments. Only relatively recently has large-scale internetworking become popular.


Routing Components
Routing involves two basic activities: determining optimal routing paths and transporting information groups (typically called packets) through an internetwork. In the context of the routing process, the latter of these is referred to as packet switching. Although packet switching is relatively straightforward, path determination can be very complex.

Path Determination
Routing protocols use metrics to evaluate what path will be the best for a packet to travel. A metric is a standard of measurement, such as path bandwidth, that is used by routing algorithms to determine the optimal path to a destination. To aid the process of path determination, routing algorithms initialize and maintain routing tables, which contain route information. Route information varies depending on the routing algorithm used.
Routing algorithms fill routing tables with a variety of information. Destination/next hop associations tell a router that a particular destination can be reached optimally by sending the packet to a particular router representing the “next hop” on the way to the final destination. When a router receives an incoming packet, it checks the destination address and attempts to associate this address with a next hop.

Routing tables also can contain other information, such as data about the desirability of a path. Routers compare metrics to determine optimal routes, and these metrics differ depending on the design of the routing algorithm used.

Routers communicate with one another and maintain their routing tables through the transmission of a variety of messages. The routing update message is one such message that generally consists of all or a portion of a routing table. By analyzing routing updates from all other routers, a router can build a detailed picture of network topology. A link-state advertisement, another example of a message sent between routers, informs other routers of the state of the sender’s links. Link information also can be used to build a complete picture of network topology to enable routers to determine optimal routes to network destinations.


Switching
Switching algorithms is relatively simple; it is the same for most routing protocols. In most cases, a host determines that it must send a packet to another host. Having acquired a router’s address by some means, the source host sends a packet addressed specifically to a router’s physical (Media Access Control [MAC]-layer) address, this time with the protocol (network layer) address of the destination host.

As it examines the packet’s destination protocol address, the router determines that it either knows or does not know how to forward the packet to the next hop. If the router does not know how to forward the packet, it typically drops the packet. If the router knows how to forward the packet, however, it changes the destination physical address to that of the next hop and transmits the packet.

The next hop may be the ultimate destination host. If not, the next hop is usually another router, which executes the same switching decision process. As the packet moves through the internetwork, its physical address changes, but its protocol address remains constant

The preceding discussion describes switching between a source and a destination end system. The International Organization for Standardization (ISO) has developed a hierarchical terminology that is useful in describing this process. Using this terminology, network devices without the capability to forward packets between subnetworks are called end systems (ESs), whereas network devices with these capabilities are called intermediate systems (ISs). ISs are further divided into those that can communicate within routing domains (intradomain ISs) and those that communicate both within and between routing domains (interdomain ISs). A routing domain generally is considered a portion of an internetwork under common administrative authority that is regulated by a particular set of administrative guidelines. Routing domains are also called autonomous systems.With certain protocols, routing domains can be divided into routing areas, but intradomain routing protocols are still used for switching both within and between areas.

Static vs. Dynamic Routing


There are two basic methods of building a routing table:
• Static Routing
• Dynamic Routing

A static routing table is created, maintained, and updated by a network administrator, manually. A   static route to every network must be configured on every router for full connectivity. This provides a granular level of control over routing, but quickly becomes impractical on large networks.

Routers will not share static routes with each other, thus reducing CPU/RAM overhead and saving bandwidth. However, static routing is not fault-tolerant, as any change to the routing infrastructure (such as a link going down, or a new network added) requires manual intervention. Routers operating in a purely static environment cannot seamlessly choose a better route if a link becomes unavailable.

Static routes have an Administrative Distance (AD) of 1, and thus are always preferred over dynamic routes, unless the default AD is changed. A static route with an adjusted AD is called a floating static route, and is covered in greater detail in another guide.

A dynamic routing table is created, maintained, and updated by a routing protocol running on the router. Examples of routing protocols include RIP (Routing Information Protocol), EIGRP (Enhanced Interior Gateway Routing Protocol), and OSPF (Open Shortest Path First). Specific dynamic routing protocols are covered in great detail in other guides.

Routers do share dynamic routing information with each other, which increases CPU, RAM, and bandwidth usage. However, routing protocols are capable of dynamically choosing a different (or better) path when there is a change to the routing infrastructure.

Do not confuse routing protocols with routed protocols:
• A routed protocol is a Layer 3 protocol that applies logical addresses to devices and routes data between networks (such as IP)
• A routing protocol dynamically builds the network, topology, and next hop information in routing tables (such as RIP, EIGRP, etc)


The following briefly outlines the advantages and disadvantages of static routing:

Advantages of Static Routing:

• Minimal CPU/Memory overhead
• No bandwidth overhead (updates are not shared between routers)
• Granular control on how traffic is routed

Disadvantages of Static Routing

• Infrastructure changes must be manually adjusted
• No “dynamic” fault tolerance if a link goes down
• Impractical on large network


The following briefly outlines the advantages and disadvantages of dynamic routing:

Advantages of Dynamic Routing
• Simpler to configure on larger networks
• Will dynamically choose a different (or better) route if a link goes down
• Ability to load balance between multiple links

Disadvantages of Dynamic Routing

• Updates are shared between routers, thus consuming bandwidth
• Routing protocols put additional load on router CPU/RAM
• The choice of the “best route” is in the hands of the routing protocol, and not the network administrator


Tuesday, 23 October 2012

Javascript Interview Questions

1) Explain in brief about Java script?
Java Script, originally supported by netscape navigator, is the most popular web scripting language. Java Script lets you embed programs right in your web pages and run these programs using the web browser. With the introduction of dynamic html necessity of Java Script is becoming more of a necessity.

2) Explain about the structured programming features of Java Script?
Java script supports most of the structured programming syntax present in programming language. It doesn't support scoping which is present in C programming in block style. It also supports various forms and methods of testing the type of an object which also includes the famous duck type testing.

3) Explain about inner functions and closures present in Function level programming?

Each time the outer function is invoked an inner function is created. Variables for the outer function still continue to exist as long as the inner function exists. This process continues until invocation exists. This is the how closures work within the JavaScript with all its functionalities.

4) Explain functions as object constructors?
If you prefix a new with a function call creates a new object and you can call that functions with a local keyword which is attached to that object. Object prototype property determines the functions prototype property. These functions act as object constructors along with their normal properties.

5) Explain functions as methods?

There is no big distinction between function definition and method definition. The only difference occurs when you actually call that function as a method which inturn is attached to an object. When the function is called in this manner its local keyword is bound to that object.

6) Explain about run time environment of Javascript?
Java script does not have a sophisticated run time of its own but it relies on the web browser of the client. It relies on this run time environment for its functions and methods to perform their duties by which scripts can interact with the user.

7) Explain about Variadic functions?
When you use variadic function in Javascript, an indefinite number of parameters can be passed onto the function. Inturn the function can access the parameters through formal parameters and local arguments. Variadic functions are much successful when you need to assign different number of parameters to functions.

8) State some simple usages with Javascript?

Some of the simple usages with Javascript are
1) A new pop up window can be made and changed according to the requirements such as no menus, scroll bars, etc.
2) Validation of input values submitted by the user through a web form.
3) Mouse over effects, scroll effects etc which can be changed by the scroll of the mouse pointer over a certain image, etc.

9) What is a JavaScript engine?
Java Script engine was first created by Netscape navigator. This engine interrupts the java script code and executes accordingly. The most common Java Script user interface is the web browser. Java script engine was created by Brendan.

10) Explain about the security functions presents in JavaScript?
As JavaScript uses Web as an interface it gives an ample scope for users to transfer malicious scripts. Most of the JavaScript related breaches and wrong doings are due to sandbox or same origin policy.

11) What are the precautions taken by the web browsers to contain malicious activity with Java Script?
Java script activities are restricted by web browsers in two ways they are.
1) First scripts run in sandbox which performs the most basic functions such as executing or running the code or script. This doesn't allow programming activities.
2) Scripts present in one site cannot have access to other sites; this is done with the help of same origin policy.

12) What are the rare cases when Java Script will not function?
These are the following cases when Java Script will not function.
1) An old browser which doesn't support DOM.
2) PDA or Mobile Phone will not execute Java Script.
3) Security reasons will not allow optimal performance of Jscript.
4) Speech browsers will not allow the functioning of Jscript.

13) Explain about Cross site scripting?

Cross site scripting raises security threats during execution and secured data transfer through web sites. It uses same origin policy. When a malicious script is made to run it discloses private information to the wrong person. This occurs because some one clicks on the request sent by the wrong doer.

14) Explain about arrays in Java Script?
Array maps everything from an integer to Values. Objects map everything from values to integers, Javascript specialize in certain special functions through which they can include integer indicies in their behavior. Large indicies can be removed if the length of the array specified is very small.

15) Explain about defining numbers in Java Script?

Java Script represents numbers in the form of IEEE-754 doubles. This form of representation provides accuracy upto 14-15 significant digits. They represent fractions but not the decimal numbers to an extent. To perform explicit numeric conversion you can use Number constructor.

16) Explain about strings in JavaScript?
Strings are represented as a sequence of characters in Javascript. Strings can be created when you place characters between double quotations or single quotations. Individual characters can be accessed by arrays.

17) Explain about the Boolean functions present in Javascript?

Three Boolean operators are present in Javascript they are
1) &&
2) II
3) /
All the operators are regarded as true unless the Javascript regards them as false. You can define these operators to make as statement false number 0 , null, undefined, or a string of length 0, etc. Boolean function performs these conversions explicitly. 

General Knowledge Quiz

Dear Viewers.........Answer the following questions.


1. Which Dutch painter cut off part of his ear?
2. In which country is the Great Barrier Reef?
3. What color is chlorophyll?
4. What is the capital of Thailand?
5. How many points are scored for a touchdown in American football?
6. Which soft green egg-shaped fruit comes from New Zealand?
7. Who was the youngest Beatle?
8. What language do the people of Brazil speak?
9. Who lives at number four, Privet Drive?
10. In which city is the cathedral of Notre Dame?
11. What color is the middle stripe of the French flag?
12. Who wrote a famous diary while hiding from the Nazis in Amsterdam?
13. Who directed, Jaws, Raiders of the Lost Ark, and ET?
14. Who was the leading actress in Sleepless in Seattle and You’ve Got Mail?
15. What is the family name of JFK?
16. How many players are there in a baseball team?
17. What is the national sport of Japan?
18. In which country was Buddha born?
19. What nationality was Picasso?
20. Whose nose grew longer every time he told a lie?
21. On what date did Osama Bin Laden's Al Queda organization attack America?
22. In which galaxy do we live?
23. In which year did the Titanic sink?
24. Who painted The Scream?
25. Who directed The Seven Samurai?
26. What is the smallest breed of dog?
27. Which French wine is released every year on the third Thursday of November?
28. What does Alice follow down a hole into Wonderland?
29. On what date do the people of England eat Christmas dinner?
30. Who sang Yellow Submarine?

Monday, 22 October 2012

PROBLEMS ON PROFIT AND LOSS-SHORTCUTS-TRICKS


What is Profit? 
When a person does a business transaction and gets more than what he had invested, then he is said to have profit. The profit he gets will be equal to the additional money he gets other than his investment. So profit can be understood as the extra money one gets other than what he had invested.
Eg: A person bought an article for Rs. 100 and sold it for Rs. 120. Then he got Rs. 20 extra and so his profit is Rs. 20.

What is Loss?
When a person gets an amount less than what he had invested, then he is said to have a loss. The loss will be equal to the deficit he got than the investment.
Eg: A person bought an article at Rs. 100 and sold it for Rs. 90. Then he got a deficit of Rs. 10 and so his loss is Rs. 10.

Cost Price (CP):
The money that the trader puts in his business is called Cost Price. The price at which the articles are bought is called Cost Price.
In other words, Cost Price is nothing but the investment in the business.

Selling Price (SP):

The price at which the articles are sold is called the Selling Price. The money that the trader gets from the business is called Selling Price.
In other words, Selling Price is nothing but the returns from a business.

Marked/Market/List Price (MP):
The price that a trader marks or lists his articles to is called the Marked Price.
This is the only price known to the customer.

Discount:
The waiver of cost from the Marked Price that the trader allows a customer is called Discount.

Note:
Profit or loss percentage is to be applied always to the Cost Price only.
Discount percentage is to be applied always to the Marked Price only.

Relationship Among CP, SP and MP:
A trader adds his profit to the investment and sells it at that increased price.
Also he allows a discount on Marked Price and sells at the discounted price.
So, we can say that,
                  SP = CP + Profit. (CP applied with profit is SP) 
                  SP = MP – Discount. (MP applied with discount is SP) 

Understanding Profit and Loss: 
So, by now we came to know that if CP is increased and sold it would result in profit and vice versa.
Also whatever increase is applied to CP, that increase itself is the profit.
For Rs. 10 profit, CP is to be increased by RS. 10 and the increased price becomes SP.
For 10% profit, CP is to be increased by 10% and it is the SP.
(we know that any value increased by 10% becomes 1.1 times.)
So, for 10% profit, CP increased by 10% => 1.1CP = SP.
SP = 1.1CP => SP/CP = 1.1 => 10% profit
SP = 1.07CP => SP/CP = 1.07 => 7% profit
SP = 1.545CP => SP/CP = 1.545 => 54.5% profit and so on.
Similarly,
SP = 0.9CP => SP/CP = 0.9 => 10% loss (Since 10% decrease)
SP = 0.76CP => SP/CP = 0.76 => 24% loss and so on.
So, to calculate profit % or loss %, it is enough for us to find the ratio of SP to CP.

Note: 
 If SP/CP > 1, it indicates profit
If SP/CP < 1, it indicates loss.

Multiple Profits or losses: 
A trader may sometimes have multiple profits or losses simultaneously. This is equivalent to having multiple changes and so all individual changes are to be multiplied to get the overall effect.

Examples: 
1. A trader uses a 800gm weight instead of 1 kg. Find his profit %.
Soln: (He is buying 800 gm but selling 1000 gm.
So, CP is for 800 gm and SP is for 1000 gm.)
SP/CP = 1000/800 = 1.25 => 25% profit.

2. A trader uses 1 kg weight for 800 gm and increases the price by 20%. Find his profit/loss %.
Soln: 1 kg weight for 800 gm => loss (decrease) => 800/1000 = 0.8
20% increase in price => profit (increase) => 1.2
So, net effect = (0.8) X (1.2) = 0.96 => 4% loss.

3. A milk vendor mixes water to milk such that he gains 25%. Find the percentage of water in the mixture.
Soln: To gain 25%, the volume has to be increased by 25%.
So, for 1 lt of milk, 0.25 lt of water is added => total volume = 1.25 lt
% of water = 0.25 / 1.25 X 100 = 20%.

4. A trader bought an item for Rs. 200. If he wants a profit of 22%, at what price must he sell it?
Soln: CP=200, Profit = 22%.
So, SP = 1.22CP = 1.22 X 200 = 244/-.

5. A person buys an item at Rs. 120 and sells to another at a profit of 25%. If the second person sells the item to another at Rs. 180, what is the profit % of the second person?
Soln: SP of 1st person = CP of 2nd person = 1.25 X 120 = 150.
SP of 2nd person = 180.
Profit % = SP/CP = 180/150 = 1.2 => 20%.

6. A milk vendor mixes water to 20 lt of milk such that the ratio of milk and water is 4:3. He sold the mixture at Rs. 12 per liter but bought the milk at Rs. 10 per liter. Find the profit % of the vendor.
Soln: milk : water = 4:3 => he bought 4 parts (milk) but sold 7 parts (mixture)
CP = 10 and SP = 12.
So, profit % = (SP/CP) X (SP/CP) = (7/4) X (12/10) = 2.1 => 110% gain.

7. A trader buys some apples at a price of 10 apples for Rs. 8 and sold them at a price of 8 apples for Rs. 10. Find his profit or loss %.
Soln: He bought 10 apples for Rs. 8 and sold 8 apples for Rs. 10 => clearly got profit
SP > CP => (SP/CP) X (SP/CP) = (10/8) X (10/8) = 100/64 = 1.5625 => 56.25 % gain.

8. A trader allows a discount of 25% on his articles but wants to gain 50% gain. How many times the CP should be marked on the items?
Soln: CP applied with profit = MP applied with discount = SP
1.5CP = 0.75MP (since 50% gain and 25% discount) => MP = 2CP.

9. By selling an item at a price a trader gains 40%. What is the profit / loss % if the item is sold at half the price?
Soln: SP =1.4CP => (SP/2) = 0.7CP => 30% loss.

10. A trader gets a profit of 25% on an article. If he buys the article at 10% lesser price and sells it for Rs. 2 less, he still gets 25% profit. Find the actual CP of the article.
Soln: 25% gain => SP = 1.25CP…..1.
Now, CP is 10% less => 0.9CP and SP is Rs. 2 less => (SP-2).
Still, profit is 25% => (SP-2)=1.25(0.9CP) , where SP = 1.25CP (From 1)
CP = Rs. 16.

11. A trader gets a discount of 20% from the dealer and marks it at 20% more price then the actual MP to the customer. Find his overall gain %.
Soln: Let MP be the price on the item.
Then, CP=0.8MP (20% discount) and SP = 1.2MP.
So, gain => SP/CP = 1.2/0.8 = 1.5 => 50%.

12. A trader allows a discount of 20% to the customer after marking the item up by 25%. Find his gain/loss% if he is given a commission of 20% of the MP by the dealer.
Soln: Trader’s SP = 0.8 X (1.25MP) = MP (since 20% discount on 25% raised price)
Trader’s CP = 0.8 MP (20% commission)
So, gain = SP/CP = MP/0.8MP = 1.25 => 25%.

Frequently asked Synonyms for placement

You can refer to GRE Barron’s most frequently used words list for a close recap


admonish = usurp (reprove)                        merry = gay
alienate = estrange (isolate)                       instigate = incite
dispel = dissipate (dismiss)                          belief = conviction
covet= crave (desire)                                  belated = too late 
solicit = beseech (seek)                               brim = border
subside = wane (drop)                                 renounce= reject
hover = linger (stay close)                           divulge = reveal
heap = to pile (collect)                                adhesive = tenacious
veer = diverge (turn)                                    hamper = obstruct
caprice = whim (impulse)                             to merit= to deserve
stifle = suffocate (smother)                          inert = passive        
latent = potential (inactive)                          latitude = scope
concur = acquiesce (accept)                        momentary = transient
tranquil = serene (calm)                               admonish = cautious
lethargy = stupor (lazy)                                 volume = quantity 
furtive= stealthy (secret)                               meager = scanty
cargo = freight(load)                                    baffle = frustrate
efface = obliterate(wipe out)                        misery = distress  
pretentious = ostentatious(affected)       discretion = prudence                        
compunction = remorse (regret)                   amiable = friendly
cajole = coax (wheedle – sweet talk)             incentive = provocation
Embrace = hug (hold-cuddle)                         latent = potential
Confiscate = appropriate (to take charge)     
emancipate = liberate                            
lament = mourn                                             
confiscate = appropriate                        
obstinate = stubborn                                     
acumen = exactness                                 
metamorphosis = transform                         
scrutiny = close examination                    
annihilate = to destroy                                  
fuse = combine                                        
whet = sharpen                                              
behest = request                                     
adage = proverb                                             
penitence = to repeat                               
ovation = applause                                         
overt = obvious                                       
Efface = obliterate                                         
spur=  spontaneous, impulsive,unplanned, impromptu, unpremeditated

XML Interview Questions-1


11. Why is XML such an important development?
It removes two constraints which were holding back Web developments:
1. Dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for;
2. The complexity of full SGML, whose syntax allows many powerful but hard to- program options.
3. XML allows the flexible development of user-defined document types. It provides a robust, non-proprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program.

12.Is it possible to write the contents of org.w3c.dom. Document object into an .xml file?
Yes its possible. One to achieve this is by using Xerces. Xerces is an XML parser. You would use the following code
org.apache.xml.serialize.OutputFormat format = new org.apache.xml.serialize.OutputFormat(myDocument);
org.apache.xml.serialize.XMLSerializer output = new org.apache.xml.serialize.XMLSerializer(new FileOutputStream(new File("test.xml")), format);
output.serialize(myDocument);

13.What is the difference between DOM and SAX? What would you use if an option is given?
DOM parses an XML document and returns an instance of org.w3c.dom.Document. This document object's tree must then be "walked" in order to process the different elements. DOM parses the ENTIRE Document into memory, and then makes it available to you. The size of the Document you can parse is
limited to the memory available. SAX uses an event callback mechanism requiring you to code methods to handle events thrown by the parser as it encounters different entities within the XML document. SAX throws events as the Document is being parsed. Only the current element is actually in memory, so there is no limit to the size of a Document when using SAX. The specific parser technology that will be used will be determined by the requirements of your application. If you need the entire document represented, you will most likely use DOM builder implementation. If you only care about parts of the XML document and/or you only need to parse the document once, you might be better served using SAX implementation.

14. What is SOAP?
The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls.

15. What is DOM?
The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily.

16. Can you walk us through the steps necessary to parse XML file?
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder domBuilder = factory.newDocumentBuilder();
Document doc = domBuilder.parse(XMLFile);

17. Is it necessary to validate XML file against a DTD?
Although XML does not require data to be validated against a DTD, many of the benefits of using the technology are derived from being able to validate XML documents against business or technical architecture rules.

18. What is XPath?
XPath stands for XML Path Language. XPath is a syntax for defining parts of an XML document. XPath is used to navigate through elements and attributes in an XML document XPath contains a library of standard functions. XPath is a major element in XSLT. XPath is designed to be used by both XSLT and XPointer
XPath is a W3C Standard.

19. What is XSL?
XSLT - a language for transforming XML documents. XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML. Normally XSLT does this by transforming each XML element into an (X)HTML element.

20. What is a DTD and a Schema?
The XML Document Type Declaration contains or points to markup declarations that provide a grammar for a class of documents. This grammar is known as a document type definition or DTD. The DTD can point to an external subset containing markup declarations, or can contain the markup declarations directly in an internal subset, or can even do both.

XML Schemas express shared vocabularies and allow machines to carry out rules made by people. They provide a means for defining the structure, content and semantics of XML documents.
Schemas are a richer and more powerful of describing information than what is possible with DTD’s.

XML Interview Questions


1. Describe the differences between XML and HTML.
It's amazing how many developers claim to be proficient programming with XML, yet do not understand the basic differences between XML and HTML. Anyone with a fundamental grasp of XML should be able describe some of the main differences outlined in the table below.
                XML                                                                                         HTML
- User definable tags                                                     - Defined set of tags designed for web  display
- Content driven                                                           -  Format driven
- End tags required for well formed  documents             - End tags not required
- Quotes required around attributes values                     - Quotes not required
- Slash required in empty tags                                        -  Slash not required

2. Describe the role that XSL can play when dynamically generating HTML pages from a relational database.
Even if candidates have never participated in a project involving this type of architecture, they should recognize it as one of the common uses of XML. Querying a database and then formatting the result set so that it can be validated as an XML document allows developers to translate the data into an HTML table using XSLT rules. Consequently, the format of the resulting HTML table can be modified without changing the database query or application code since the document rendering logic is isolated to the XSLT rules.

3. Give a few examples of types of applications that can benefit from using XML.
There are literally thousands of applications that can benefit from XML technologies. The point of this question is not to have the candidate rattle off a laundry list of projects that they have worked on, but, rather, to allow the candidate to explain the rationale for choosing XML by citing a few real world examples. For instance, one appropriate answer is that XML allows content management systems to store documents independently of their format, which thereby reduces data redundancy. Another answer relates to B2B exchanges or supply chain management systems. In these instances, XML provides a mechanism for multiple companies to exchange data according to an agreed upon set of rules. A third common response involves wireless applications that require WML to render data on hand held devices.

4. What is DOM and how does it relate to XML?
The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily Any developer that has worked extensively with XML should be able to discuss the concept and use of DOM objects freely. Additionally, it is not unreasonable to expect advanced candidates to thoroughly understand its internal workings and be able to explain how DOM differs from an event-based interface like SAX.

5. What is SOAP and how does it relate to XML?
The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.

6. Can you walk us through the steps necessary to parse XML documents?
Superficially, this is a fairly basic question. However, the point is not to determine whether candidates understand the concept of a parser but rather have them walk through the process of parsing XML documents step-by-step. Determining whether a non-validating or validating parser is needed, choosing the appropriate parser, and handling errors are all important aspects to this process that should be included in the candidate's response.

7. Give some examples of XML DTDs or schemas that you have worked with.
Although XML does not require data to be validated against a DTD, many of the benefits of using the technology are derived from being able to validate XML documents against business or technical architecture rules. Polling for the list of DTDs that developers have worked with provides insight to their general exposure to the technology. The ideal candidate will have knowledge of several of the commonly used DTDs such as FpML, DocBook, HRML, and RDF, as well as experience designing a custom DTD for a particular project where no standard existed.


8. Using XSLT, how would you extract a specific attribute from an element in an XML document?
Successful candidates should recognize this as one of the most basic applications of XSLT. If they are not able to construct a reply similar to the example below, they should at least be able to identify the components necessary for this operation: xsl:template to match the appropriate XML element, xsl:value-of to select the attribute value, and the optional xsl:apply-templates to continue processing the document.
Example 1:
<xsl:template match="element-name">
Attribute Value:
<xsl:value-of select="@attribute"/>
<xsl:apply-templates/>
</xsl:template>

9. When constructing an XML DTD, how do you create an external entity reference in an attribute value?
Every interview session should have at least one trick question. Although possible when using SGML, XML DTDs don't support defining external entity references in attribute values. It's more important for the candidate to respond to this question in a logical way than than the candidate know the somewhat obscure answer.

10. How would you build a search engine for large volumes of XML data?
The way candidates answer this question may provide insight into their view of XML data. For those who view XML primarily as a way to denote structure for text files, a common answer is to build a full-text search and handle the data similarly to the way Internet portals handle HTML pages. Others consider XML as a standard way of transferring structured data between disparate systems. These candidates often describe some scheme of importing XML into a relational or object database and relying on the database's engine for searching. Lastly, candidates that have worked with vendors specializing in this area often say that the best way the handle this situation is to use a third party software package optimized for XML data. Obviously, some important areas of XML technologies were not included in this list -- namespaces, XPointer, XLink, and so on -- and should be added to the interviewer's set of questions if applicable to the particular position that the candidate is applying for. However, these questions in conjunction with others to assess soft skills (communication skills, ability to work on teams, leadership ability, etc.) will help determine how well candidates understand the fundamental principles of XML.

TCS Pattern Questions-3

Pattern 11:
 1. Simple question but big one on average age. sth like a, b, c weighted separately 1st a, b, c ,then a& b, then b &c ,then c & a at last abc, the last weight was 167,then what will be the average weight of the 7 reading?
a)95         b)95.428           c)95.45        d)94
Solution: last weight abc is 167 i.e three persons weight is 167 .in first 6 combinations a,b,c,ab,bc,ac i.e a checked weight for 3 times totally like that band c also so total weight in all 7 combinations is (4*167) Average is (668/7)=95.42

Pattern 12: 
1. A toy train produces 10 different sounds when it moves around a circular toy track of radius 5 m at 10 m per min. However, the toy train is defective and it now produces only 2 different tunes at random. What are the odds that the train produces for consecutive music tones of the same type?
a) 1 in 16             b)1 in 4          c)1 in 8         d)1 in 32
 Solution: Initially it produces 10 sounds and the defect came and now it produces only 2 different sounds and consecutively so there are totally 2 sounds and we have to select on sound and the probability is ½ and it produces the same sound consecutively for 2 times so the probability becomes ½*1/2 i.e.,  ¼

 2. A car manufacturer produces only red and blue models which come out of the final testing area at random. What are the odds that five consecutive cars of same color will come through the test area at any one time?
a)1 in 16          b)1 in 125         c)1 in 32         d)1 in 25

Pattern 13: 
1. A triangle is made from a rope. The sides of the triangle are 25 cm, 11 cm and 31 cm. What will be the area of the square made from the same rope?
 a)280.5625         b)240.5625        c)280.125       d)240
Solution:    Add all sides 25+11+31 to get rope length rope length =67,rope is made in to as square So side of square is 67/4=16.75 and so area is 16.75*16.75=280.5625

 2. A triangle is made from a rope. The sides of the triangle are 21 cm, 24 cm and 28 cm. What will be the area of the square made from the same rope?
 a)280.5625         b)333.0625          c)333.0125          d)400

Pattern 14:
1. What is the distance between the z-intercept from the x-intercept in the equation ax+by+cz+d=0
 Solution: intercept form equation

2. What is the distance of the z-intercept from the x-intercept in the equation ax+by+cz=d (I do not remember the values of a, b, c, d).

 Pattern 15: 
1. A scientist was researching on animal behavior in his lab. He was very interested in analyzing the behavior of bear. For some reason he travelled 1mile in north direction & reached at North Pole. There he saw a bear. He then followed the bear around 1 hr with a speed of 2km/hr in east direction. After that he travelled in south direction & reached at his lab in2 hrs. Then what is the color of the bear?
 a)white     b)black        c)gray       d)brown
Solution is :White .above all the matter is nonsense

 Pattern-16: 
1. Out of 7 children the youngest is boy then find the probability that all the remaining children are boys a)1/64       b)1/32      c)1/128          d)1/256

Pattern 17: 
1. Usha bought a linen cloth and rope to build a tent. If the rope is 153 m long and it is to be cut into pieces of 1m length, then how many cuts are to be made to cut the ropes into 153 pieces?
a)153           b)152          c)154           d)155
Solution: to make it 153 pieces we have to cut 152 times so obviously after last cut we got 153rd piece

2. A person has to make 146 pieces of a long bar. He takes 4 seconds to cut a piece. What is the total time taken by him in seconds to make 146 pieces?
a)584        b)580                c)730           d)725
Solution:146 pieces means 145 cuts so for each cut it takes 4 seconds means total time 145*4=580

 3. A person has to make 141 pieces of a long bar. He takes 2 seconds to cut a piece. What is the total time taken by him in seconds to make 141 pieces?
a)560             b)280              c)112           d)324

Pattern 18:
 1. Spores of a fungus, called late blight, grow and spread infection rapidly. These pathogens were responsible for the Irish potato famine of the mid-19th century. These seem to have attacked the tomato crops in England this year. The tomato crops have reduced and the price of the crop has risen up. The price has already gone up to $45 a box from $27 a box a month ago. How much more would a vegetable vendor need to pay to buy 27 boxes this month over what he would have paid last month?
a) $27             b)$18                  c)$45           d)$ 486
 Solution: see last 3 lines only answer is 45-27=18

Pattern 19: 
1. A Person buys a horse for 15 ponds, after one year he sells it for 20 pounds. After one year, again he buys the same horse at 30 pounds and sells it for 40 pounds. What is the profit for that person?
 Solution: here we cannot consider depreciation or decay of item accto answer so go acc to answer Totally 5+10=15$profit

Pattern 20:
 1. John buys a cycle for 31 dollars and given a cheque of amount 35 dollars. Shop Keeper exchanged the cheque with his neighbor and gave change to John. After 2 days, it is known that cheque is bounced. Shop keeper paid the amount to his neighbor. The cost price of cycle is 19 dollars. What is the profit/loss for shop keeper?
a)loss 23 b)gain 23 c)gain 54 d)Loss 54
Solution: loss =change of money given to john(4$)+actual cycle cost 19$=23$ loss

Sunday, 21 October 2012

TCS Pattern Questions-2

Pattern 6 
1. Susan made a block with small cubes of 8 cubic cm volume to make a block ,3 small cubes long, 9 small cubes wide and 5 small cubes deep. She realizes that she has used more small cubes than she really needed. She realized that she could have glued a fewer number of cubes together to lock like a block with same dimensions, if it were made hollow. What is the minimum number of cubes that she needs to make the block?a) 114        b) 135         c) 21         d) 71
Solution: I do not know perfectly but I got some solutions from internet I do not know correctly whether it is true or not,((3*9*5))-((3-2)*(9-2)*(5-2))  so answer is 114.

2. A boy wants to make cuboids of dimension 5m, 6m and 7m from small cubes of .03 m3. Later he realized he can make same cuboids by making it hollow. Then it takes some cubes less. What is the number of the cubes to be removed?
a) 2000      b) 5000           c) 3000       d) 7000

3. Smita was making a cube with dimensions 5*5*5 using 1*1*1 cubes. What is the number of cubes needed to make a hollow cube looking of the same shape?
a) 98            b) 104          c) 100         d) 61

 4. Leena cut small cubes of 10 cm dimension each. She joined it to make a cuboid of length 100 cm, width 50 cm and depth 50 cm. How many more cubes does she need to make a perfect cube?
 a)500          b)250         c)750        d)650

 5. Leena cut small cubes of 3 cubic cm each. She joined it to make a cuboid of length 10 cm, width 3 cm and depth 3 cm. How many more cubes does she need to make a perfect cube?
a) 910         b) 250          c) 750        d) 650

6. A lady builds 9cm length, 10cm width,3cm height box using 1 cubic cm cubes. What is the minimum number of cubes required to build the box?
 a) 730          b) 270          c) 720          d) 310

 Pattern 7:
1. (40*40*40 – 31*31*31)/(40*40+40*31+31*31)=?
 a)8        b)9        c )71         d)51
 Solution: a3 -b3 =(a-b)*(a2+a*b+b2)
so from this formula we will find (a-b) value

2. (98*98*98 – 73*73*73)/( 98*98*98 – 73*73*73)=?
a).171      b).4        c).420         d).415


3. (209*144)^2 + (209*209)+(209*144)+(144*144) = ?
 a)905863729      b)905368729      c)905729368      d)65

Pattern 8:
1. ((4x+3y)+(5x+9y))/(5x+5y) = ? as (x/2y) = 2
a)8      b)none      c)16      d)15
Solution: substitute x=4y  in above we can find solution

2. x/2y = 2a,then 2x/x-2ay=?
a)4     b)8     c)16     d)2

 3. 3X/5Y = 5Y/3X…..Find the value of X/Y
a)3/5     b)5/3    c)2/5     d)5/2

 4. What is the value of (3X+8Y)/(X-2Y), if X/2Y=2
 a)8      b)none    c)10    d)13

5. (4x+3y)+(5x+9y))/(5x+5y) = ? as (x/2y) = 2 a)48/5 b)46/5 c)47/5 d)49/5 6. ((4x+2y)/(4x-2y)= ? as (x/2y) = 2
a)8/7     b)9/7     c)11/7     d)6/7

Pattern 9:
1. A girl has to make pizza with different toppings. There are 8 different toppings. In how many ways can she make pizzas with 2 different toppings?
 a)16 b)56 c)112 d)28
Solution: 8c2

2. A pizza shop made pizzas with many flavors. There are 10 different flavors, in that 7 flavors are taken to make pizza. In how many ways they can arrange?
 a)240    b)120    c)65    d)210

 3. A pizza shop made pizzas with many flavors. There are 9 different flavors, in that 2 flavors are taken to make pizza. In how many ways they can arrange?
a)16    b)26     c)36     d)46

 Pattern 10:
1. 3, 22, 7, 45, 15,? , 31
 a)91    b)151    c)90    d)5

2. 8 6 17 14 35 31 75 _ 143?

3. Inspired by Fibonacci series Sangeet decided to create his own series which is 1, 2, 3, 7, 7, 22, 15, 67, 31, _, 63?
a)202    b)31    c)76    d)49

 4. 3, 12, 7, 26, 15, ?
a)54    b)27    c)108    d)31

5. 1! + 2! + ……. + 50!=?
a)3.1035*10^64      b)2.1021*10^65      c)3.1035*10^63       d)3.1035*10^62

6. 1, 2, 3, 6, 7, 14, _, 32?

7. 5, 9, 12, 18, 26, 36, 47, 72, _?
a)75     b)135      c)100     d)55

8. 3, 15, x, 51, 53,159,161
a)17     b)34       c)54       d)112

Sunday, 14 October 2012

SQL Basics-1


SQL - What are Subqueries: Advanced Queries
             Subqueries can be performed inside of existing queries. This expands the capabilities of SQL in a number of ways providing a 3rd dimension to the language you might say. Again, we will discuss subqueries in more detail in a later lesson. Feel free to familiarize yourself with what a subquery may look like using the example below.
SQL Code: 
SELECT * FROM table_one WHERE unique_column = (SELECT unique_column FROM table_two WHERE id_column = 1)
Above is a look at where you might cross subqueries. The logic behind the entire query is fairly confusing at this point, try and stay with us and focus on the syntax of the query and subquery.

SQL - Syntax
           SQL follows a general syntax, there are not many quotations or other symbols to throw into your statements. Generally we follow a Do what To what syntax, meaning first we decide what we want to do, then we decide what we want to do it to, and finally we end the whole thing with a semicolon (;).
           A statement begins with a clause. Clauses are commands in the SQL world and the backbone of any script. The first clause of a statement gives a general idea of what type of action a script is taking. A few basic clauses are SELECT, INSERT, or CREATE.
            We will look at each of these clauses a little more in depth on the next few pages but it may be obvious to you already what each of those clauses does. SQL statements end with a semicolon as most with most programming languages. A basic statement might look like this:
SQL Code:
SELECT * FROM table_name;

                Above we have a SELECT clause asking for all columns and values (*) from our database table. As shown above, a good habit is to capitalize your clauses. Later on when we have larger statements and subqueries it will make life much easier to go back and debug your code.
                 Formating your statements in a similar fashion will also aid your debugging efforts. The common formatting technique is to begin each line with a clause or to break up and list columns or tables as needed. More on this in a moment.
SQL Code: 
SELECT * FROM table_name; 

The advantage of this isn't apparent with this example. Each are fairly easy to read. However the example below shows an example where this format shines.
SQL Code: 
SELECT column_one, column_two 
FROM table_name
WHERE ( 
column_one, 
column_two, 
column_three, )
 = (SELECT column_one,
 column_ two
FROM column_ two
WHERE table_one.id = 'table_two.id');

As you can see, when subqueries are thrown into the mix things become a little more complicated. A one line statement will not fit across your screen. Both statements are neither right nor wrong, each are easier to follow. Parentheses generally depict order of operations but it is not an exact science. Quotations are not found until the predicate of the statement.

SQL - Data Types
SQL recognizes 4 general types of data. As the database designer you will be selecting which type of data that can be placed in each table column. Before we look at each type of table column we will elaborate on specific data types and how they are handled in SQL.

Character Strings - ('Words or numbers')
Numbers - (3, 3.423, -17)
Booleans - (True / False)
Nulls - (empty fields)

SQL - NULL Values
A null value may be the most foreign to new programmers. Stating that a value has a null value indicates that nothing exists in that table field. When the table is created you may either allow a table to have a null value or may disallow null values for each table column.
SQL Code:
 CREATE TABLE weekly_payroll (employee_id VARCHAR(10) PRIMARY KEY, total_hours INT NULL, hourly_rate MONEY NOT NULL,);

SQL - Numeric Data
Dates, time stamps, integers, and money are all numeric data types. The advantage of working with numbers is that SQL has built in functions such as the AVG() or SUM() functions that will return the average or the sum of a numeric column.
Numbers:
rate_of_pay
27
26.66
28.40


SQL - Boolean Data
Boolean values are either yes/no (true/false) types of data. Others use a 1/0 (1 for yes 0 for no) approach. Either something is or something is not.

Boolean Values:
admin
1
1
0

SQL - Character Strings
Character strings are sentences, symbols, or a combination of both. Math functions can not be performed with character strings.
Character Strings:
employee_id
TS_0036
TS_0078
CL_1099




SQL Basics


SQL - What's a Database?
A database is nothing more than an empty shell, like a vacant warehouse. It offers no real functionality what so ever, other than holding a name. Tables are the next tier of our tree offering a wide scope of functionality. If you follow our warehouse example, a SQL table would be the physical shelving inside our vacant warehouse. Each SQL table is capable of housing 1024 columns(shelves). Depending on the situation, your goods may require reorganization, reshelving, or removal. SQL tables can be manipulated in this same way or in any fashion the situation calls for.

SQL - Platforms
A SQL platform acts as the stage for building and developing your databases. Several different platforms exist including:
- IBM's DB2
- MySQL
- PostgreSQL
- Oracle
- Microsoft's SQL Server

SQL - MySQL and PostgreSQL
MySQL and PostgreSQL are open source database programs rich in functionality and flexibility. They are often the choice of web developers and small businesses simply because they get the job done for a very reasonable price. Also they will go anywhere and can operate on nearly every operating system available.

SQL - SQL Server
Microsoft's SQL Server is steadily on the rise in the commercial world gaining popularity slowly. This platform has a GUI "Windows" type interface and is also rich with functionality. A free trial version can be downloaded at the Microsoft web site, however it is only available to Windows users.

SQL - DB2 and Oracle
By far the selection of choice for large corporations is either Oracle or DB2. Companies that have large ties to IBM stick to their DB2 software whereas others have made the switch to Oracle. These systems run on personal computers as well as large corporate mainframes.

SQL - Queries
Queries are the backbone of SQL. Query is a loose term that refers to a widely available set of SQL commands called clauses. Each clause (command) performs some sort of function against the database. For instance, the create clause creates tables and databases and the select clause selects rows that have been inserted into your tables. We will dive deeper in detail as this tutorial continues but for now let's take a look at some query structure. Query construction begins with one of the following clauses:
Add
Drop
Create
Insert
Select
Update
Replace
Delete

Queries are loosely typed into your SQL prompt. Spacing and line breaks are not very important as we will discuss further in our SQL Syntax lesson. We now know that a query begins with a clause, what comes next depends on the clause we select and we will be covering all the clauses as the tutorial progresses. For now, let's take a look at some syntax.


SQL - Query Syntax
The syntax of a query is loose, meaning you are free to place line breaks where you please without injuring the code. Few instances require parentheses, including the insert statement listed below. Parentheses will also be covered during our Functions lesson. Be sure to end all query statements with a semicolon (;).

SQL Code: 
                    SELECT * FROM table_name; 

The above code selects every row and every column from a hypothetical table (table_one) and prints it to our prompt. Here's a look at a few more queries that should become second nature to you as the tutorial continues.

SQL Code: 
INSERT INTO table_name (column_one,column_two) VALUES(value_one,value_two);

SQL Code:  
UPDATE table_name SET column_one = value_one, column_two = value_two;

Queries are how you communicate to your database program. Nearly everything typed at a SQL command prompt is a query.