Monday, 8 October 2012

TCS Pattern questions-1

Pattern 3: 

1. 6 persons standing in queue with different age group, after two years their average age will be 43 and seventh person joined with them. Hence the current average age has become 45. Find the age of seventh person?
 a) 43 b)69 c)52 d)31
 Solution: Total age of 6 persons is x hours,after two years total age of 6 persons is x+12
 Average age of 6 persons is after two years is 43
 So (x+12)/6=43,then solve x,
After 7th person is added then (x+7th person age)/7=45
 So we will get 7th person age easily

 2. In a market 4 men are standing. The average age of the four before 4years is 45, after some days one man is added and his age is 49. What is the average age of all?
 a) 43 b)45 c)47 d)49

3. In a shopping mall with a staff of 5 members the average age is 45 years. After 5 years a person joined them and the average age is again 45 years. What‟s the age of 6th person?
 a) 25 b)20 c)45 d)30

 4. In a market 4 men are standing .The average age of the four before 2 years is 55, after some days one man is added and his age is 45. What is the average age of all?
a) 55 b)54.5 c)54.6 d)54.7

Pattern 4: 

1. In the reading room of a library, there are 23 reading spots. Each reading spot consists of a round table with 9 chairs placed around it. There are some readers such that in each occupied reading spot there are different numbers of readers. If in all there are 36 readers, how many reading spots do not have even a single reader?
a)8 b)none c)16 d)15
 Solution: 23 reading spots, Each reading spot consists of 9 chairs placed around it so There are some readers such that in each occupied reading spot there are different numbers of readers.
 For each table different no of persons are sat,so for first table 1 person is sit,2nd table 2 persons are sit 36 readers means(1+2+3+4+5+6+7+8 so 8 tables are filled so 23-8=15 reading spots does not have single reader.

 2. In the reading room of a library, there are 10 tables, 4 chairs per table. In each table there are different numbers of people seated. How many tables will be left out without at least 1 person?
a) 8 b)6 c)2 d)7

3. In the reading room of a library, there are 10 tables, 4 chairs per table. In each table there are different numbers of people seated. How many ways they will sit in the library so that no chair would be blank?
a) 8 b)6 c)2 d)7

Pattern 5: 

1. A man jogs at 6 mph over a certain journey and walks over the same route at 4 mph. What is his average speed for the journey?
 a) 2.4 mph b) 4.8 mph c) 4 mph d) 5 mph
 Solution: average speed=(2*x*y)/(x+y)

2. A man travels from A to B at 4 mph over a certain journey and returns over the same route to A, at 5 mph. What is his average speed for the journey?
 a) 4.44 mph b) 4.8 mph c) 4.887 mph d)5 mph

 3. A person is rock climbing at an altitude of 800 m. He go up by 7 mph. and come down by 9 mph. what was his average speed?
 a) 7.875 mph b) 7.125 mph c) 7mph d) 7.5 mph

4. Find average speed if a man travels at speed of 24kmph up and 36kmph down at an altitude of 200m?
 a) 28.8 mph b) 27.8 mph c) 27.5mph d) 30 mph

5. Person travels to a hill, if he goes from A to B with speed of 4kmph and returns back to B with speed of 5kmph. What is his average speed of journey?
a) 4.5kmph b) 4.44kmph c) 9kmph d) 4.245kmph

 6. A man travels from A to B at 70 mph over a certain journey and returns over the same route to A, at 80 mph. What is his average speed for the journey?
a) 74.66 b)75 c)74.33 d)74.99

7. Find average speed if a man travels at speed of 24kmph up and 36kmph down at an altitude of 200m.
 a) 28.8 b)28 c)27 d)28.6

Java Interview Question-1


Data types,variables and Arrays

1) What is meant by variable?
Ans: Variables are locations in memory that can hold values. Before assigning any value to a variable, it must be declared.

2) What are the kinds of variables in Java? What are their uses?
Ans: Java has three kinds of variables namely,
 1) the instance variable 
 2) the local variable
 3) the class variable
- Local variables are used inside blocks as counters or in methods as temporary variables and are used to store information needed by a single method.
- Instance variables are used to define attributes or the state of a particular object and are used to store information needed by multiple methods in the objects.
- Class variables are global to a class and to all the instances of the class and are useful for communicating between different objects of all the same class or keeping track of global states.

3) How are the variables declared?
Ans: Variables can be declared anywhere in the method definition and can be initialized during their declaration.They are commonly declared before usage at the beginning of the definition.
Variables with the same data type can be declared together. Local variables must be given a value before usage.

4) What are variable types?
Ans: Variable types can be any data type that java supports, which includes the eight primitive data types, the name of a class or interface and an array.

5) How do you assign values to variables?
Ans: Values are assigned to variables using the assignment operator =.

6) What is a literal? How many types of literals are there?
Ans: A literal represents a value of a certain type where the type describes how that value behaves.
There are different types of literals namely number literals, character literals, boolean literals, string literals,etc.

7) What is an array?
Ans: An array is an object that stores a list of items.

8) How do you declare an array?
Ans: Array variable indicates the type of object that the array holds.
Ex: int arr[];

9) Java supports multidimensional arrays.
a)True
b)False
Ans: a.

10) An array of arrays can be created.
a)True
b)False
Ans: a.

11) What is a string?
Ans: A combination of characters is called as string.

12) Strings are instances of the class String.
a)True
b)False
Ans: a.

13) When a string literal is used in the program, Java automatically creates instances of the string class.
a)True
b)False
Ans: a.

14) Which operator is to create and concatenate string?
Ans: Addition operator(+).

15) Which of the following declare an array of string objects?
String[ ] s;
String [ ]s:
String[ s]:
String s[ ]:
Ans : a, b and d

16) What is the value of a[3] as the result of the following array declaration?
1
2
3
4
Ans : d

17) Which of the following are primitive types?
byte
String
integer
Float
Ans : a.

18) What is the range of the char type?
0 to 216
0 to 215
0 to 216-1
0 to 215-1
Ans. d

19) What are primitive data types?
Ans : byte, short, int, long
float, double
boolean
char

20) What are default values of different primitive types?
Ans : int - 0
short - 0
byte - 0
long - 0 l
float - 0.0 f
double - 0.0 d
boolean - false
char - null

21) Converting of primitive types to objects can be explicitly.
a)True
b)False
Ans: b.

22) How do we change the values of the elements of the array?
Ans : The array subscript expression can be used to change the values of the elements of the array.

23) What is final varaible?
Ans : If a variable is declared as final variable, then you can not change its value. It becomes constant.

24) What is static variable?
Ans : Static variables are shared by all instances of a class.

Thursday, 4 October 2012

Current Affairs


1. In which country the tallest communication tower named ‘skruty’ is suituated ?
Answer: Tokyo (Japan)

2. Who is the worlds shortest women who is still alive ?
Answer: Jyothi Amge

3. Who is the new leader of North Korea who has been recently elected ?
Answer: Kim Jong Un

4. How many years have been completed by African National Congress recently ?
Answer: 100 yrs .

5. Who is the first Indian American person who had been elected as governor for Lousiana in states of U.K.?
Answer: Bobby Jindal .

6. Which year is called as ‘International Year Of Cooperative’ according to UNO ?
Answer: 2012 year

7. Worlds oldest yoga teacher who had been entered in Guinnes Book of Records for yoga recently ?
Answer: Bernice Bates .

8. After how many years America had totally set back his military army from Iraq ?
Answer: 9yrs

9. Shoedar ‘ cruze missile was launched and tested by by which country ?
Answer: Iran

10. Who is the American Ambassdor to India in 2011?
Answer: Timothy J. Reomer.

11. For how many yrs the great leader of North Korea has headed the country ?
Answer: 17 yrs

12. Which is the Worlds first Hydrogen based three wheeler vehicle ?
Answer: High Alpha

13. Who is the person who had won the election in US Republican in Florida Primary results recently ?

Answer: Mitt Romney

14. According to the new census Jan 2012 , what is the % population of China ?
Answer: 51.27 %

15. Who’s name had been kept for the fly over bridge constructed in Islamabad recently?
Answer: Yousaf Raja Gillani .

16 Who is the President who had signed on millitary spending bills twice recently ?
Answer: Barack Obama

17. Which is the nation which joined UNO organisation recently ?
Answer: Pakistan

18. A credit Standard and Poor’s , due to which reasons it had reduced the rating of France, Italy and
other 9 countries recently ?
Answer: Debt crisis.

19. According to the fortune magazine‘s annual ranking for 100 best companies to work for 2012,which company stood first ?
Answer: Google.

20. Who inagurated the new mission control centre the SHAR ?
Answer: Prathiba Patil

Java Multiple choice Questions


1.The Java interpreter is used for the execution of the source code.
a) True                   b) False
Ans: a.

2) On successful compilation a file with the class extension is created.
a) True                    b) False
Ans: a.

3) The Java source code can be created in a Notepad editor.
a) True                     b) False
Ans: a.

4) The Java Program is enclosed in a class definition.
a) True                     b) False
Ans: a.

5) What declarations are required for every Java application?
Ans: A class and the main( ) method declarations.

6) What are the two parts in executing a Java program and their purposes?
Ans: Two parts in executing a Java program are:
Java Compiler and Java Interpreter: 
The Java Compiler is used for compilation and the Java Interpreter is used for execution of the application.

7) What are the three OOPs principles and define them?
Ans : Encapsulation, Inheritance and Polymorphism are the three OOPs  Principles.
Encapsulation: 
Is the Mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.
Inheritance:
Is the process by which one object acquires the properties of another object.
Polymorphism: 
Is a feature that allows one interface to be used for a general class of actions.

8) What is a compilation unit?
Ans : Java source code file.

9) What output is displayed as the result of executing the following statement?
System.out.println("// Looks like a comment.");
// Looks like a comment
The statement results in a compilation error
Looks like a comment
No output is displayed

Ans : a.

10) In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?
- It must have a package statement
- It must be named Test.java
- It must import java.lang
- It must declare a public class named Test

Ans : b

11) What are identifiers and what is naming convention?
Ans : Identifiers are used for class names, method names and variable names. An identifier may be any descriptive sequence of upper case & lower case letters,numbers or underscore or dollar sign and must not begin with numbers.

12) What is the return type of program’s main( ) method?
Ans : void

13) What is the argument type of program’s main( ) method?
Ans : string array.

14) Which characters are as first characters of an identifier?
Ans : A – Z, a – z, _ ,$

15) What are different comments?
Ans : 1) // -- single line comment
          2) /* --
              */ multiple line comment
          3) /** --
             */ documentation

16) What is the difference between constructor method and method?
Ans : Constructor will be automatically invoked when an object is created. Whereas method has to be call explicitly.

17) What is the use of bin and lib in JDK?
Ans : Bin contains all tools such as javac, applet viewer, awt tool etc., whereas Lib contains all packages and variables.

TCS Selection process and patterns


Selection process:
1) written test
2) Technical cum HR interview.
Written Test: Written test consists of 35 questions 80min, previously it is 60min but now time they increased 20min. It is a online test .
 Preparation: Up to my knowledge questions for written test is always from previous papers.so first of all solve below patterns mostly all these patterns are repeated in written test.and try previous papers given by various users in freshersworld and prepare quantitative aptitude by R.S Agarwal
 Pattern 1:
1. (1/2) of a number is 3 more than the (1/6) of the same number?
 a) 6 b)7 c)8 d)9
Solution:    Let the number be x,
                  ((1/2)*x)=3+(1/6)*x,
                   Then solve x
2. (1/3) of a number is 3 more than the (1/6) of the same number?
a) 6 b)16 c)18 d)21
 3. (1/3) of a number is 6 more than the (1/6) of the same number?
 a) 6 b)18 c)36 d)24
 4. (2/3) of a number is 4 more than the (1/6) of the same number?
a) 6 b)8 c)36 d)24
5. (1/3) of a number is 5 more than the (1/6) of the same number?
 a) 6 b)36 c)30 d)72
Pattern 2: 
1. There are two water tanks A and B, A is much smaller than B. While water fills at the rate of 1 liter every hour in A, it gets filled up like, 10, 20, 40,80, 160…..in tank B. (At the end of first hour, B has 10 liters, second hour it has 20 liters and so on). If tank B is 1/32 filled of the 21 hours, what is total duration of hours required to fill it completely?
a) 26 B)25 c)5 d)27
 Solution: for every hour water in tank in B is doubled,
Let the duration to fill the tank B is x hours.
x/32 part of water in tank of B is filled in 21 hours,
Next hour it is doubled so, 2*(x/32) part i.e (x/16) part is filled in 22 hours,
 Similarly (x/8)th part in 23 hours,
(x/4)th part is filled in 24 hours,
 (x/2)th part is filled in 25 hours,
(x)th part is filled in 26 hours So answer is 26 hours.

2. There are two pipes A and B. If A filled 10 liters in an hour, B can fill 20 liters in same time. Likewise B can fill 10, 20, 40, 80, 160…... If B filled in 1/16 of a tank in 3 hours, how much time will it take to fill the tank completely?
 a) 9 B)8 c)7 d)6

UNIX Interview Questions-8


71. For which kind of fault the page is checked first?
Ans: The page is first checked for the validity fault, as soon as it is found that the page is invalid (valid bit is clear), the validity fault handler returns immediately, and the process incur the validity page fault. Kernel handles the validity fault and the process will incur the protection fault if any one is present.

72. In what way the protection fault handler concludes?
Ans: After finishing the execution of the fault handler, it sets the modify and protection bits and clears the copy on write bit. It recalculates the process-priority and checks for signals.

73. How the Kernel handles both the page stealer and the fault handler?
Ans: The page stealer and the fault handler thrash because of the shortage of the memory. If the sum of the working sets of all processes is greater that the physical memory then the fault handler will usually sleep because it cannot allocate pages for a process. This results in the reduction of the system throughput because Kernel spends too much time in overhead, rearranging the memory in the frantic pace.

74. Explain different types of Unix systems.
Ans: The most widely used are: 
1. System V (AT&T)
 2. AIX (IBM) 
3. BSD (Berkeley) 
4. Solaris (Sun) 
5. Xenix ( A PC version of Unix)

75. Explain kernal and shell.
Ans: Kernel: It carries out basic operating system functions such as allocating memory, accessing files and handling communications. Shell:A shell provides the user interface to the kernal.
There are 3 major shells :
 1. C-shell
 2. Bourne shell
 3. Korn shell

76. What is ex and vi ?
Ans: ex is Unix line editor and vi is the standard Unix screen editor.

77. Which are typical system directories below the root directory?
Ans: (1) /bin: contains many programs which will be executed by users
 (2) /etc : files used by administrator 
(3) /dev: hardware devices
 (4) /lib: system libraries 
(5) /usr: application software
 (6) /home: home directories for different systems.

78. Construct pipes to execute the following jobs?
Ans:
1. Output of who should be displayed on the screen with value of total number of users who have logged in displayed at the bottom of the list.
2. Output of ls should be displayed on the screen and from this output the lines containing the word ‘poem’ should be counted and the count should be stored in a file.
3. Contents of file1 and file2 should be displayed on the screen and this output should be appended in a file.
From output of ls the lines containing ‘poem’ should be displayed on the screen along with the count.
4. Name of cities should be accepted from the keyboard . This list should be combined with the list present in a file. This combined list should be sorted and the sorted list should be stored in a file ‘newcity’.
5. All files present in a directory dir1 should be deleted any error while deleting should be stored in a file ‘errorlog’.

79.Explain the following commands?
$ ls > file1
$ banner hi-fi > message
$ cat par.3 par.4 par.5 >> report
$ cat file1>file1
$ date ; who
$ date ; who > logfile
$ (date ; who) > logfile

80. What is the significance of the “tee” command?
Ans: It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to the file specified by the user.

OS Interview Questions-7


1. What is Context Switch?
Ans : Switching the CPU to another process requires saving the state of the old process and loading the saved state for the new process. This task is known as a context switch.Context-switch time is pure overhead, because the system does no useful work while switching. Its speed varies from machine to machine, depending on the memory speed, the number of registers which must be copied, the existed of special instructions(such as a single instruction to load or store all registers).

2. Distributed Systems?
Ans : Distribute the computation among several physical processors.
Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines
Advantages of distributed systems:
->Resources Sharing
->Computation speed up – load sharing
->Reliability
->Communications

3.Difference between Primary storage and secondary storage?
Ans :
Main memory: – only large storage media that the CPU can access directly.
Secondary storage: – extension of main memory that provides large nonvolatile storage capacity.

4. What is CPU Scheduler?
Ans :
->Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them.
->CPU scheduling decisions may take place when a process:
1.Switches from running to waiting state.
2.Switches from running to ready state.
3.Switches from waiting to ready.
4.Terminates.
->Scheduling under 1 and 4 is nonpreemptive.
->All other scheduling is preemptive.

5. What do you mean by deadlock?
Ans : Deadlock is a situation where a group of processes are all blocked and none of them can become unblocked until one of the other becomes unblocked.The simplest deadlock is two processes each of which is waiting for a message from the other

6. What is Dispatcher?
Ans :
->Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves:
- Switching context
- Switching to user mode
- Jumping to the proper location in the user program to restart that program
- Dispatch latency – time it takes for the dispatcher to stop one process and start another running.

7. What is Throughput, Turnaround time, waiting time and Response time?
Ans :
Throughput – number of processes that complete their execution per time unit
Turnaround time – amount of time to execute a particular process
Waiting time – amount of time a process has been waiting in the ready queue
Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)

8. Explain the difference between micro-kernel and macro kernel?
Ans :Micro-Kernel: A micro-kernel is a minimal operating system that performs only the essential functions of an operating system. All other operating system functions are performed by system processes.
Monolithic: A monolithic operating system is one where all operating system code is in a single executable image and all operating system code runs in system mode.

9.What is multi tasking, multi programming, multi threading?
Ans :
Multi programming: Multiprogramming is the technique of running several programs at a time using timesharing.It allows a computer to do several things at the same time. Multiprogramming creates logical parallelism.
The concept of multiprogramming is that the operating system keeps several jobs in memory simultaneously. The operating system selects a job from the job pool and starts executing a job, when that job needs to wait for any i/o operations the CPU is switched to another job. So the main idea here is that the CPU is never idle.
Multi tasking: Multitasking is the logical extension of multiprogramming .The concept of multitasking is quite similar to multiprogramming but difference is that the switching between jobs occurs so frequently that the users can interact with each program while it is running. This concept is also known as time-sharing systems. A time-shared operating system uses CPU scheduling and multiprogramming to provide each user with a small portion of time-shared system.
Multi threading: An application typically is implemented as a separate process with several threads of control. In some situations a single application may be required to perform several similar tasks for example a web server accepts client requests for web pages, images, sound, and so forth. A busy web server may have several of clients concurrently accessing it. If the web server ran as a traditional single-threaded process, it would be able to service only one client at a time. The amount of time that a client might have to wait for its request to be serviced could be enormous.
So it is efficient to have one process that contains multiple threads to serve the same purpose. This approach would multithread the web-server process, the server would create a separate thread that would listen for client requests when a request was made rather than creating another process it would create another thread to service the request.
So to get the advantages like responsiveness, Resource sharing economy and utilization of multiprocessor architectures multithreading concept can be used

10. Give a non-computer example of preemptive and non-preemptive scheduling?
Ans : Consider any system where people use some kind of resources and compete for them. The non-computer examples for preemptive scheduling the traffic on the single lane road if there is emergency or there is an ambulance on the road the other vehicles give path to the vehicles that are in need. The example for preemptive scheduling is people standing in queue for tickets.