Labels

THOUGHTS

**The youth needs to develop an attitude : I can do it! We can do it !! India will do it!!! ""மரங்களை நடுவோம் பசுமை இல்ல விளைவை தடுப்போம்"" !!! PLEASE DO IT**
Showing posts with label PLACEMENT PAPERS. Show all posts
Showing posts with label PLACEMENT PAPERS. Show all posts

Tuesday, December 6, 2011

VERIZON PLACEMENT PAPER 2.

2011 Verizon Placement Paper:-

1-10 questions of the type

Rose is _______ beautiful flower.
Options: a, an, the, none

11-16 Reading comprehension... on computer protection and security

17-20 Reading comprehension on Databases (Actually you don't need to read the passage you will be able to answer without reading it--- its so trivial)

Analytical: ( 30 questions 30 minutes)
21. Sheela is 16th from first. 29th from last in a test. 6 boys did not come. 3 failed what is the strength of the class 22-26 problems on sets.. eg 15 speak Tamil 25 speak Tamil and Hindi out of 53 people how many speak Tamil alone. etc( Do not remember exact figures)

27-32 Problems on sets eg 54 boys play cricket.61play football,66 play tennis. 24 play all three, 32 play football and cricket, 15 play foot ball and tennis. How many players played only cricket, football, tennis same kind of problem on white ,green and yellow kites

33-37 Typical annals question( u find in RS Agarwals)
6 movies need to be screened in a movie festival. The slots are 9.30,10.30,1 3.30 5.30, 7

A can screen in afternoon or morning B cannot screen before C nobody else can screen when D is screening..( similar conditions.. Watch out we all ran out of time trying to attempt this question)

38-40 Question on cube. A cube is painted with three colours namely Red, yellow ,green its [anted in such a way that colors are on the adjacent sides are not same. The cube is cut into 27 small cubes. How many cubes with one color, two color, three color etc

41-45 One question and Two statements would be given Mark A if statement 1 alone is enough to get the answer. B if statement 2 alone is enough, C if statement 1 and 2 are necessary. D if answer cannot be arrived at
eg 1.P-X>0
2., pX>0
is p positive.

46-50 Question on cube.. 16 cubes are kept on top of which 4 cubes r kept at the centre , on top of that 2 cubes are kept and on top of that one cube is kept. It is painted from top to bottom. How many cubes with 1,2,3,4, 0,sides painted.

Mental Ability (15 questions 25 minutes)

51-53 
Questions on pattern matching. Like mark A if first and third are identical, B if second and third are identical, C if first and second are identical D if they are different.

54-59 Questions of the form if +is - and - is * . * is / and / is + then find 12/3*5-2+5

60-62 A set of conditions for admissions of a school student is given like he should be in top 20 in the entrance test or should have sports excellence etc.. and questions of different cases are given and we need to find if the candidate can be admitted or not.

63-65 Similar questions for recruitment of cook. He should be 25 yrs of age with 3 yrs experience if he has lesser exp. he should meet the head cook . if he is below 25 yrs he should meet the manager and questions on various cases.

Technical (C and DS) :


66. Of the following select a code to print a singly link list in a reverse order.

67. select a code to print elements of a dequeue

68. a=3,b=3,c=3
a-=b-- - --c;
printf (a, b, c);

69. Find a declaration of ADT of a polynomial.

70. Select code that shows DFS of a graph

71
. Select the statement that appropriately fills the DFS algorithm

VERIZON PLACEMENT PAPER1

1. Select the statement that appropriately fills the DFS algorithm

2.  File *fp1,*fp2;
fp1=fopen ("a","w");
fp2=fopen ("a","w");
and operations using these two file pointers . and 4 options based on that

3. int *px;
do{
*px=f(1);
} while( i<10 && *px<900);
f(int a)
{
int x= a*50;
return &x;
}
And four options about value of *px also has options on error conditions

4. Some question on strings.4 codes given and we need to select an appropriate code.

your ans for each ques below would be  

A, if all 3 items given in the ques are exactly alike.

B, if only the first and second items are exactly alike.

C, if only the first and third items are exactly alike.

D, if none of the aboue.

 

5. 5344544445               5344544445                   5344543445

a)A  b)B  c)C d)D

 

6. 8472.9200602            8472.9200602                8472.9200602

a)A b)B c)C d)D

 
7. 6461.4421129             6461.4421129                 6461.4421129

a)A b)B c)C d)D

 

8. 2001.7886162             2001.7786162                 2001.7885162

a)A b)B c)C d)D

 

9.
 KVKVKVKVVV       KVKVKKVVVV            KVKKVVVVVV

a)A b)B c)C d)D

 

10. Arizona Desert              Arizona Desert                 Arizzona Desert

a)A b)B c)C d)D

 

11. If * stands for -, /stands for +, +stands for *, then which of the following is TRUE?

A) 32/14*6+40-8=44.8

B) 14*8/6+40-8=16.8

c) 32*6/14+32-8=9.9

D) 32/6*14+32-8=18.9

 

12. If * stands for /, /stands for -, +stands for * and –stands for +, then 17/5*4+19-8?

A)1.25

B) 24.5

C) 12.8

D) 22.4

 

13. If + stands for ‘division’, * stands for ‘multiplication’ and / stands for ‘subtraction’, then which of the following equations is CORRECT?

A) 36*6+7/2-6=20

B) 36/6+3*5-3=45

c) 36+6-3*5/3=24

D) 36-6+3*5/3=74

 

14. If * stands for /, / stands for -, + stands for *, - stands for +, then which of the following equations is TRUE?

A) 28/10*6+80-12=20

B) 10*12/6+80-12=49.3

c) 28*6/10+28-12=3.1

D) 12*28/6+80-12=448

 

15. If * stands for +, / stands for *, + stands for -, - stands for /, then which of the following equations is TRUE?

A) 8*12/8+40-12=32.7

B) 20*8/8+20-12=8

c) 12*20/8+40-12=-16

D) 20/8*8+40-12=164.7

 

16.  If * stands for -, / stands for +, + stands for /, - stands for *, then which of the following equations is TRUE?

A) 20/16*4+90-12=35.58*12/8+40-12=32.7

B) 16*12/4+90-12=3.5

c) 20*4/16+20-12=-8

D) 12*20/4+90-12=4

Thursday, October 27, 2011

Networking Basic Questions


Networking Part 1.

1 . What is an Object server?

With an object server, the Client/Server application is written as a set of communicating objects. Client object communicate with server objects using an Object Request Broker (ORB). The client invokes a method on a remote object. The ORB locates an instance of that object server class, invokes the requested method and returns the results to the client object. Server objects must provide support for concurrency and sharing. The ORB brings it all together.
2 . What is a Transaction server?

With a transaction server, the client invokes remote procedures that reside on the server with an SQL database engine. These remote procedures on the server execute a group of SQL statements. The network exchange consists of a single request/reply message. The SQL statements either all succeed or fail as a unit.
3 . What is a Database Server?

With a database server, the client passes SQL requests as messages to the database server. The results of each SQL command are returned over the network. The server uses its own processing power to find the request data instead of passing all the records back to the client and then getting it find its own data. The result is a much more efficient use of distributed processing power. It is also known as SQL engine.
4 . What are the most typical functional units of the Client/Server applications?
User interface
Business Logic and
Shared data.
5 . What are all the Extended services provided by the OS?


Ubiquitous communications
Network OS extension
Binary large objects (BLOBs)
Global directories and Network yellow pages
Authentication and Authorization services
System management
Network time
Database and transaction services
Internet services
Object- oriented services
6 . What are Triggers and Rules?

Triggers are special user defined actions usually in the form of stored procedures, that are automatically invoked by the server based on data related events. It can perform complex actions and can use the full power of procedural languages.
A rule is a special type of trigger that is used to perform simple checks on data.
7 . What is meant by Transparency?

Transparency really means hiding the network and its servers from the users and even the application programmers.
8 . What are TP-Lite and TP-Heavy Monitors?

TP-Lite is simply the integration of TP Monitor functions in the database engines. TP-Heavy are TP Monitors which supports the Client/Server architecture and allow PC to initiate some very complex multiserver transaction from the desktop.
9 . What are the two types of OLTP?

TP lite, based on stored procedures. TP heavy, based on the TP monitors.
10 . What is a Web server?

This new model of Client/Server consists of thin, protable, "universal" clients that talk to superfat servers. In the simplet form, a web server returns documents when clients ask for them by name. The clients and server communicate using an RPC-like protocol called HTTP.
11 . What are Super servers?

These are fully-loaded machines which includes multiprocessors, high-speed disk arrays for intervive I/O and fault tolerant features.
12 . What is a TP Monitor?

There is no commonly accepted definition for a TP monitor. According to Jeri Edwards' a TP Monitor is "an OS for transaction processing".
13 . TP Monitor does mainly two things extremely well. They are Process management and Transaction management.?

They were originally introduced to run classes of applications that could service hundreds and sometimes thousands of clients. TP Monitors provide an OS - on top of existing OS - that connects in real time these thousands of humans with a pool of shared server processes.
14 . What is meant by Asymmetrical protocols?

There is a many-to-one relationship between clients and server. Clients always initiate the dialog by requesting a service. Servers are passively awaiting for requests from clients.
15 . What are the types of Transparencies?

The types of transparencies the NOS middleware is expected to provide are:-
Location transparency
Namespace transparency
Logon transparency
Replication transparency
Local/Remote access transparency
Distributed time transparency
Failure transparency and
Administration transparency.


Click here to Register in Naukri.com & TimesJobs.com
 Prepare For Job    
Home    .Net    J2EE    PHP    Testing    Freshers    HR Q/A    Networking    Others    Freshers Jobs    Experienced Jobs    Post Ur Jobs
   
 Networking Part 2.

1 . What does the Mount protocol do ?

The Mount protocol returns a file handle and the name of the file system in which a requested file resides. The message is sent to the client from the server after reception of a client's request.
2 . What are Digrams and Trigrams?

The most common two letter combinations are called as digrams. e.g. th, in, er, re and an. The most common three letter combinations are called as trigrams. e.g. the, ing, and, and ion.
3 . What is the HELLO protocol used for?

The HELLO protocol uses time instead of distance to determine optimal routing. It is an alternative to the Routing Information Protocol.
4 . What is the minimum and maximum length of the header in the TCP segment and IP datagram?

The header should have a minimum length of 20 bytes and can have a maximum length of 60 bytes.
5 . What do you meant by "triple X" in Networks?

The function of PAD (Packet Assembler Disassembler) is described in a document known as X.3. The standard protocol has been defined between the terminal and the PAD, called X.28; another standard protocol exists between the PAD and the network, called X.29. Together, these three recommendations are often called "triple X".
6 . What is attenuation?

The degeneration of a signal over distance on a network cable is called attenuation.
7 . What is Protocol Data Unit?

The data unit in the LLC level is called the protocol data unit (PDU). The PDU contains of four fields a destination service access point (DSAP), a source service access point (SSAP), a control field and an information field. DSAP, SSAP are addresses used by the LLC to identify the protocol stacks on the receiving and sending machines that are generating and using the data. The control field specifies whether the PDU frame is a information frame (I - frame) or a supervisory frame (S - frame) or a unnumbered frame (U - frame).
8 . What are the data units at different layers of the TCP / IP protocol suite?

The data unit created at the application layer is called a message, at the transport layer the data unit created is called either a segment or an user datagram, at the network layer the data unit created is called the datagram, at the data link layer the datagram is encapsulated in to a frame and finally transmitted as signals along the transmission media.
9 . What is difference between ARP and RARP?

The address resolution protocol (ARP) is used to associate the 32 bit IP address with the 48 bit physical address, used by a host or a router to find the physical address of another host on its network by sending a ARP query packet that includes the IP address of the receiver.
The reverse address resolution protocol (RARP) allows a host to discover its Internet address when it knows only its physical address.
10 . What is MAC address?

The address for a device as it is identified at the Media Access Control (MAC) layer in the network architecture. MAC address is usually stored in ROM on the network adapter card and is unique.

Linux Basic Interview Questions

                                                                   Linux

1 . How do you list files in a directory?

ls  - list directory contents

ls -l (-l  use a long listing format)
2 . How do you list all files in a directory, including the hidden files?

ls -a  (-a, do not hide entries starting with .)
3 . How do you find out all processes that are currently running?

ps -f (-f does full-format listing.)
4 . How do you find out the processes that are currently running or a particular user?

ps -au Myname   (-u by effective user ID (supports names)) (a - all users)
5 . How do you kill a process?

kill -9  8 (process_id 8) or kill -9  %7  (job number 7)
      kill -9 -1  (Kill all processes you can kill.)
      killall - kill processes by name most (useful - killall java)
6 . What would you use to view contents of the file?

less filename
      cat filename
      pg filename
      pr filename
      more filename
      most useful is command: tail file_name - you can see the end of the log file.
7 . What would you use to edit contents of the file?

vi  screen editor or jedit, nedit or ex  line editor
8 . What would you use to view contents of a large error log file?

tail  -10 file_name   ( last 10 rows)
9 . How do you log in to a remote Unix box?

Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login program))
10 . How do you get help on a UNIX terminal?

man command_name
      info command_name (more information)
11 . How do you list contents of a directory including all of its subdirectories, providing full details and sorted by modification time?

ls -lac
         -a all entries
         -c by time
12 . How do you create a symbolic link to a file (give some reasons of doing so)?

ln /../file1 Link_name
Links create pointers to the actual files, without duplicating the contents of
the files. That is, a link is a way of providing another name to the same file.
There are two types of links to a file:Hard link, Symbolic (or soft) link;
13 . What is a filesystem?

Sum of all directories called file system.
       A file system is the primary means of file storage in UNIX.
       File systems are made of inodes and superblocks.
14 . How do you get its usage (a filesystem)?

By storing  and manipulate  files.
15 . How do you check the sizes of all users� home directories (one command)?

du -s
      df

The du command summarizes disk usage by directory. It recurses through all subdirectories and shows disk usage by each subdirectory with a final total at the end.

   Q. in current directory
   A. ls -ps (p- directory; s - size)
16 . How do you check for processes started by user 'pat'?

ps -fu pat   (-f -full_format u -user_name )
17 . How do you start a job on background?

bg  %4  (job 4)
18 . What utility would you use to replace a string '2001' for '2002' in a text file?

Grep,  Kde( works on Linux and Unix)
19 . What utility would you use to cut off the first column in a text file?

awk, kde
20 . How to copy file into directory?

cp  /tmp/file_name . (dot mean in the current directory)
21 . How to remove directory with files?

rm -rf directory_name
22 . What is the difference between internal and external commands?

Internal commands are stored in the; same level as the operating system while external
commands are stored on the hard disk among the other utility programs.
23 . List the three main parts of an operating system command:

The three main parts are the command, options and arguments.
24 . What is the difference between an argument and an option (or switch)?

An argument is what the command should act on: it could be a filename,
directory or name. An option is specified when you want to request additional
information over and above the basic information each command supplies.
25 . What is the purpose of online help?

Online help provides information on each operating system command, the
syntax, the options, the arguments with descriptive information.
26 . Name two forms of security.

Two forms of security are Passwords and File Security with permissions specified.
27 . What command do you type to find help about the command who?

$ man who
28 . What is the difference between home directory and working directory?

Home directory is the directory you begin at when you log into the
system. Working directory can be anywhere on the system and it is where you are currently
working.
29 . Which directory is closer to the top of the file system tree, parent directory or current directory?

The parent directory is above the current directory, so it is closer to
the root or top of the
file system.
30 . Given the following pathname: $ /business/acctg/payable/supplier/april a) If you were in the directory called acctg, what would be the relative pathname name for the file called april? b) What would be the absolute pathname for april?

a) $ payable/supplier/april

b) $ /business/acctg/payable/supplier/april
31 . Suppose your directory had the following files: help. 1 help.2 help.3 help.4 help.O1 help.O2 aid.O1 aid.O2 aid.O3 back. 1 back.2 back.3 a) What is the command to list all files ending in 2? b) What is the command to list all files starting in aid? c) What is the command to list all "help" files with one character extension?
a) ls *2
b) ls aid.*
c) ls help.?


32 . What are two subtle differences in using the more and the pg commands?

With the more command you display another screenful by pressing
 the spacebar, with pg you press the return key.
      The more command returns you automatically to the UNIX
shell when completed, while pg waits until you press return.
33 . When is it better to use the more command rather than cat command?

It is sometimes better to use the more command when you are viewing
 a file that will display over one screen.
34 . What are two functions the move mv command can carry out?

The mv command moves files and can also be used to rename a file or directory.
35 . Name two methods you could use to rename a file.
Two methods that could be used:
a. use the mv command
b. copy the file and give it a new name and then remove the original file if no longer needed.
36 . The soccer league consists of boy and girl teams. The boy file names begin with B, the girl teams begin with G. All of these files are in one directory called "soccer", which is your current directory: Bteam.abc Bteam.OOl Bteam.OO2 Bteam.OO4 Gteam.win Gteam.OOl Gteam.OO2 Gteam.OO3 Write the commands to do the following: a) rename the file Bteam.abc to Bteam.OO3. b) erase the file Gteam. win after you have viewed the contents of the file c) make a directory for the boy team files called "boys", and one for the girl team files called" girls" d) move all the boy teams into the "boys" directory e) move all the girl teams into the "girls" directory f) make a new file called Gteam.OO4 that is identical to Gteam.OOl g) make a new file called Gteam.OO5 that is identical to Bteam.OO2
a) mv Bteam.abc Bteam.OO3.
b) cat Gteam.win -or- more Gteam.win
rm Gteam. win
c) mkdir boys
mkdir girls
d) mv Bteam* boys
e) mv Gteam* girls
f) cd girls
cp Gteam.OO1 Gteam.OO4
g) There are several ways to do this. Remember that we are currently in the directory
/soccer/girls.
cp ../boys/Bteam.OO2 Gteam.OO5
or
cd ../boys
cp Bteam.OO2 ../girls/Gteam.OO5
37 . What metacharacter is used to do the following: 1.1 Move up one level higher in the directory tree structure 1.2 Specify all the files ending in .txt 1.3 Specify one character 1.4 Redirect input from a file 1.5 Redirect the output and append it to a file
1. 1.1 double-dot or ..
1.2 asterisk or *
1.3 question or ?
1.4 double greater than sign: >>
1.5 the less than sign or <
38 . List all the files beginning with A

To list all the files beginning with A command: ls A*
39 . Which of the quoting or escape characters allows the dollar sign ($) to retain its special meaning?

The double quote (") allows the dollar sign ($) to retain its special meaning.
Both the backslash (\) and single quote (') would remove the special meaning of the dollar sign.
40 . What is a faster way to do the same command? mv fileO.txt newdir mv filel.txt newdir mv file2.txt newdir mv file3.txt newdir

A shortcut method would be:   mv file?.txt newdir
41 . List two ways to create a new file:
a. Copy a file to make a new file.
b. Use the output operator e.g. ls -l > newfile.txt
42 . What is the difference between > and >> operators?
The operator > either overwrites the existing file (WITHOUT WARNING) or creates a new file.
The operator >> either adds the new contents to the end of an existing file or creates a new file.
43 . Write the command to do the following: 1. Redirect the output from the directory listing to a printer. 2. Add the file efg.txt to the end of the file abc.txt. 3. The file testdata feeds information into the file called program 4. Observe the contents of the file called xyz.txt using MORE. 5. Observe a directory listing that is four screens long.
1. ls > lpr
2. cat efg.txt >> abc.txt
3. program < testdata
4. more < xyz.txt
5. ls > dirsave | more
44 . How do you estimate file space usage

Use du command (Summarize disk usage of each FILE, recursively for
directories.) Good to use arguments du -hs
(-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) 
(-s, --summarize display only a total for each argument)
45 . How can you see all mounted drives?

mount -l
46 . How can you find a path to the file in the system?

locate file_name (locate - list files in databases that match a pattern)
47 . What Linux HotKeys do you know?

Ctrl-Alt-F1 Exit to command prompt
        Ctrl-Alt-F7 or F8    Takes you back to KDE desktop from command prompt
        Crtl-Alt-Backspace Restart XWindows
        Ctrl-Alt-D Show desktop
48 . What can you tell about the tar Command?

The tar program is an immensely useful archiving utility. It can combine
an entire directory tree into one large file suitable for transferring or
compression.
49 . What types of files you know?
Files come in eight flavors:
Normal files
Directories
Hard links
Symbolic links
Sockets
Named pipes
Character devices
Block devices
50 . How to copy files from on PC to another on the same network

Use the following command:scp yur_file you_login@your_IP
example: copy .conf file from your PC  to king computer-
 scp /etc/X11/xorg.conf king@10.0.3.156:
51 . Please describe information below: -rw-rw-r-- 1 dotpc dotpc 102 Jul 18 2003 file.buf drwxr-xr-x 9 dotpc dotpc 4096 Oct 21 09:34 bin lrwxrwxrwx 1 dotpc dotpc 20 Mar 21 15:00 client -> client-2.9.5 drwxrwxr-x 11 dotpc dotpc 4096 Sep 2 2005 client-2.8.9 drwxrwxr-x 7 dotpc dotpc 4096 Dec 14 12:13 data drwxr-xr-x 12 dotpc dotpc 4096 Oct 21 09:41 docs drwxr-xr-x 5 dotpc dotpc 4096 Dec 7 14:22 etc drwxr-xr-x 11 dotpc dotpc 4096 Mar 21 15:54 client-2.9.5 -rw-r--r-- 1 dotpc dotpc 644836 Mar 22 09:53 client-2.9.5.tar.gz

This is a result of command $ls -l
we have two files, 6 directories and one link to client-2.9.5 directory.
There is number of files in every directory, size and data of last change.
52 . If you would like to run two commands in sequence what operators you can use?

; or && the difference is:
if you separate commands with ; second command will be run automatically.
if you separate commands with && second command will be run only in the case
 the first was run successfully.
53 . How you will uncompress the file?

Use tar command (The GNU version of the tar archiving utility):
tar -zxvf file_name.tar.gz
54 . How do you execute a program or script, my_script in your current directoty?

./my_script
55 . How to find current time configuration in the file my_new.cfg

grep time my_new.cfg
Grep  searches the named input files (or standard input if
no files are named, or the file name - is given) for lines
containing a match to the given pattern.
56 . What does grep() stand for?

General Regular Expression Parser.
57 . What does the top command display?

Top provides an ongoing look at processor activity in real
       time.   It  displays  a  listing of the most CPU-intensive
       tasks on the system, and can provide an interactive inter­
       face for manipulating processes. (q is to quit)
58 . How can you find configuration on linux?

by using /sin/ifconfig
If no arguments are given, ifconfig displays the  status  of  the  cur-
rently  active interfaces.  If a single interface argument is given, it displays the status of the given interface only; if a single  -a  argu-
ment  is  given,  it  displays the status of all interfaces, even those
that are down.  Otherwise, it configures an interface.
59 . How to find difference in two configuration files on the same server?

Use diff command that is compare files line by line
diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf
60 . What is the best way to see the end of a logfile.log file?

Use tail command - output the last part of files
tail -n file_name ( the last N lines, instead of the last 10 as default)
61 . Please write a loop for removing all files in the current directory that contains a word 'log'

for i in *log*; do rm $i; done
62 . How to switch to a previously used directory?

cd -
63 . How many VI editor modes do you know?

Three modes -
Command mode: letters or sequence of letters interactively command vi.
Insert mode: Text is inserted.
Command line mode: enter this mode by typing ":"  and entry command line  at the foot of the screen.
64 . How can you terminate VI session?
    Use command: ZZ that is save changes and quit.
    Use command line: ":wq" that is write changes and quit.
    Use command line: ":q!" to ignore changes and quit.
65 . How can you copy lines into the buffer in command mode?
      yy - copy a single line defined by current cursor position
      3yy - copy 3 lines. Current line and two lines below it.
   

Core Java Basic Interview Questions

                                                                    Core Java

1 . Language Fundamentals

How many number of non-public class definitions can a source file have
A source file can contain unlimited number of non-public class definitions
What types of values does boolean variables take
It only takes values true and false

Which primitive datatypes are signed?
All except char and Boolean

Is char type signed or unsigned?

char type is integral but unsigned. It range is 0 to 2^7-1 ?

What forms an integral literal can be??
decimal, octal and hexadecimal, hence example it can be 28, 034 and 0x1c respectively

What is the default value of Boolean???
False

Why is the main method static??
So that it can be invoked without creating an instance of that class

What is the difference between class variable, member variable and automatic(local) variable??
class variable is a static variable and does not belong to instance of class but rather shared across all the instances
member variable belongs to a particular instance of class and can be called from any method of the class
automatic or local variable is created on entry to a method and has only method scope

When are static and non static variables of the class initialized??
The static variables are initialized when the class is loadedNon static variables are initialized just before the constructor is called

When are automatic variable initialized??
Automatic variable have to be initialized explicitly

How is an argument passed in java, by copy or by reference??
If the variable is primitive datatype then it is passed by copy.
If the variable is an object then it is passed by reference

What is garbage collection??
The runtime system keeps track of the memory that is allocated and is able to determine whether that memory is still useable. This work is usually done in background by a low-priority thread that is referred to as garbage collector. When the gc finds memory that is no longer accessible from any live thread it takes steps to release it back to the heap for reuse

Does System.gc and Runtime.gc() guarantee garbage collection??
No

2 . Operators and assignment

What are different types of operators in java??
Uniary ++, --, +, -, |, ~, ()
Arithmetic *, /, %,+, -
Shift <<, >>, >>>
Comparison =, instanceof, = =,!=Bitwise &, ^, |Short Circuit &&, ||Ternary ?:Assignment =

How does bitwise (~) operator work??
It converts all the 1 bits in a binary value to 0s and all the 0 bits to 1s, e.g 11110000 coverts to 00001111

What is a modulo operator %??
This operator gives the value which is related to the remainder of a divisione.g x=7%4 gives remainder 3 as an answer

Can shift operators be applied to float types.??
No, shift operators can be applied only to integer or long types

What happens to the bits that fall off after shifting??
They are discarded

What values of the bits are shifted in after the shift??
In case of signed left shift >> the new bits are set to zero

But in case of signed right shift it takes the value of most significant bit before the shift, that is if the most significant bit before shift is 0 it will introduce 0, else if it is 1, it will introduce 1.

3 . Modifiers

What are access modifiers??
These public, protected and private, these can be applied to class, variables, constructors and methods. But if you don't specify an access modifier then it is considered as Friendly

Can protected or friendly features be accessed from different packages??
No when features are friendly or protected they can be accessed from all the classes in that package but not from classes in another package

How can you access protected features from another package?
You can access protected features from other classes by subclassing the that class in another package, but this cannot be done for friendly features

What are the rules for overriding??
Private method can be overridden by private, friendly, protected or public methods
Friendly method can be overridden by friendly, protected or public methods
Protected method can be overridden by protected or public methods
Public method can be overridden by public method

Explain modifier final??
Final can be applied to classes, methods and variables and the features cannot be changed. Final class cannot be subclassed, methods cannot be overridden

Can you change the reference of the final object??
No the reference cannot be change, but the data in that object can be changed

Can abstract modifier be applied to a variable??
No it is applied only to class and methods

Can abstract class be instantiated??
No abstract class cannot be instantiated i.e you cannot create a new object of this class

When does the compiler insist that the class must be abstract??
If one or more methods of the class are abstract.
If class inherits one or more abstract methods from the parent abstract class and no implementation is provided for that method
If class implements an interface and provides no implementation for those methods

How is abstract class different from final class??
Abstract class must be subclassed and final class cannot be subclassed

Where can static modifiers be used??
They can be applied to variables, methods and even a block of code, static methods and variables are not associated with any instance of class

When are the static variables loaded into the memory??
During the class load time


4 . Modifiers

When are the non static variables loaded into the memory
They are loaded just before the constructor is called

How can you reference static variables??
Via reference to any instance of the class
Computer comp = new Computer ();
comp.harddisk where hardisk is a static variable
comp.compute() where compute is a method

Via the class name
Computer.harddisk
Computer.compute()

Can static method use non static features of there class??
No they are not allowed to use non static features of the class, they can only call static methods and can use static data

What is static initializer code??
A class can have a block of initializer code that is simply surrounded by curly braces and labeled as static e.g.
public class Demo{
static int =10;
static{
System.out.println("Hello world');
}
}

And this code is executed exactly once at the time of class load

Where is native modifier used??
It can refer only to methods and it indicates that the body of the method is to be found else where and it is usually written in non java language

What are transient variables??
A transient variable is not stored as part of objects persistent state and they cannot be final or static

What is synchronized modifier used for??
It is used to control access of critical code in multithreaded programs

What are volatile variables??
It indicates that these variables can be modified asynchronously


5 . Conversion Casting and Promotion

What are wrapped classes??
Wrapped classes are classes that allow primitive types to be accessed as objects.

What are the four general cases for Conversion and Casting??
Conversion of primitives
Casting of primitives
Conversion of object references
Casting of object references

When can conversion happen??
It can happen during
Assignment
Method call
Arithmetic promotion

What are the rules for primitive assignment and method call conversion??
A boolean can not be converted to any other type
A non Boolean can be converted to another non boolean type, if the conversion is widening conversion
A non Boolean cannot be converted to another non boolean type, if the conversion is narrowing conversion
See figure below for simplicity
assignment

What are the rules for primitive arithmetic promotion conversion??
For Unary operators :
If operant is byte, short or a char it is converted to an int
If it is any other type it is not converted
For binary operands :
If one of the operands is double, the other operand is converted to double
Else If one of the operands is float, the other operand is converted to float
Else If one of the operands is long, the other operand is converted to long
Else both the operands are converted to int

What are the rules for casting primitive types??
You can cast any non Boolean type to any other non boolean type
You cannot cast a boolean to any other type; you cannot cast any other type to a boolean

What are the rules for object reference assignment and method call conversion??
An interface type can only be converted to an interface type or to object. If the new type is an interface, it must be a superinterface of the old type
A class type can be converted to a class type or to an interface type. If converting to a class type the new type should be superclass of the old type. If converting to an interface type new type the old class must implement the interface
An array maybe converted to class object, to the interface cloneable, or to an array. Only an array of object references types may be converted to an array, and the old element type must be convertible to the new element

What are the rules for Object reference casting??
Casting from Old types to Newtypes
Compile time rules

    * When both Oldtypes and Newtypes are classes, one should be subclass of the other
    * When both Oldtype ad Newtype are arrays, both arrays must contain reference types (not primitive), and it must be legal to cast an element of Oldtype to an element of Newtype
    * You can always cast between an interface and a non-final object

Runtime rules

    * If Newtype is a class. The class of the expression being converted must be Newtype or must inherit from Newtype
    * If NewType is an interface, the class of the expression being converted must implement Newtype

6 . Flow Control and exception

What is the difference between while and do while loop??
Do while loop walways executes the body of the loop at least once, since the test is performed at the end of the body

When do you use continue and when do you use break statements??
When continue statement is applied it prematurely completes the iteration of a loop.
When break statement is applied it causes the entire loop to be abandoned.

What is the base class from which all exceptions are subclasses??
All exceptions are subclasses of a class called java.lang.Throwable

How do you intercept and thereby control exceptions??
We can do this by using try/catch/finally blocks
You place the normal processing code in try block
You put the code to deal with exceptions that might arise in try block in catch block
Code that must be executed no matter what happens must be place in finally block

When do we say an exception is handled??
When an exception is thrown in a try block and is caught by a matching catch block, the exception is considered to have been handled

When do we say an exception is not handled??
There is no catch block that names either the class of exception that has been thrown or a class of exception that is a parent class of the one that has been thrown, then the exception is considered to be unhandled, in such condition the execution leaves the method directly as if no try has been executed

7 . Flow Control and exception

In what sequence does the finally block gets executed??
If you put finally after a try block without a matching catch block then it will be executed after the try block
If it is placed after the catch block and there is no exception then also it will be executed after the try block
If there is an exception and it is handled by the catch block then it will be executed after the catch block

What can prevent the execution of the code in finally block??

    * The death of thread
    * Use of system.exit()
    * Turning off the power to CPU
    * An exception arising in the finally block itself

What are the rules for catching multiple exceptions??
A more specific catch block must precede a more general one in the source, else it gives compilation error
Only one catch block, that is first applicable one, will be executed

What does throws statement declaration in a method indicate??
This indicates that the method throws some exception and the caller method should take care of handling it

What are checked exception??
Checked exceptions are exceptions that arise in a correct program, typically due to user mistakes like entering wrong data or I/O problems

What are runtime exceptions??
Runtime exceptions are due to programming bugs like out of bond arrays or null pointer exceptions.

What is difference between Exception and errors??
Errors are usually compile time and exceptions can be runtime or checked

How will you handle the checked exceptions??
You can provide a try/catch block to handle it. OR
Make sure method declaration includes a throws clause that informs the calling method an exception might be thrown from this particular method

When you extend a class and override a method, can this new method throw exceptions other than those that were declared by the original method
No it cannot throw, except for the subclasses of those exceptions

Is it legal for the extending class which overrides a method which throws an exception, not o throw in the overridden class
Yes it is perfectly legal

Explain the user defined Exceptions?
User defined Exceptions are the separate Exception classes defined by the user for specific purposed. An user defined can created by simply sub-classing it to the Exception class. This allows custom exceptions to be generated (using throw) and caught in the same way as normal exceptions.
Example:
class myCustomException extends Exception {
// The class simply has to exist to be an exception
}

8 . Objects and Classes

What's the difference between constructors and other methods??
Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

What is the difference between Overloading and Overriding??
Overloading : Reusing the same method name with different arguments and perhaps a different return type is called as overloading
Overriding : Using the same method name with identical arguments and return type is know as overriding

What do you understand by late binding or virtual method Invocation. (Example of runtime polymorphism)
When a compiler for a non object oriented language comes across a method invocation, it determines exactly what target code should be called and build machine language to represent that call. In an object oriented language, this is not possible since the proper code to invoke is determined based upon the class if the object being used to make the call, not the type of the variable. Instead code is generated that will allow the decision to be made at run time. This delayed decision making is called as late binding

Can overriding methods have different return types??
No they cannot have different return types

If the method to be overridden has access type protected, can subclass have the access type as private
No, it must have access type as protected or public, since an overriding method must not be less accessible than the method it overrides

Can constructors be overloaded??
Yes constructors can be overloaded

What happens when a constructor of the subclass is called??
A constructor delays running its body until the parent parts of the class have been initialized. This commonly happens because of an implicit call to super() added by the compiler. You can provide your own call to super(arguments..) to control the way the parent parts are initialized. If you do this, it must be the first statement of the constructor.

If you use super() or this() in a constructor where should it appear in the constructor??
It should always be the first statement in the constructor

9 . Objects and Classes

What is an inner class??
An inner class is same as any other class, but is declared inside some other class

How will you reference the inner class??
To reference it you will have to use OuterClass$InnerClass

Can objects that are instances of inner class access the members of the outer class??
Yes they can access the members of the outer class

What modifiers may be used with an inner class that is a member of an outer class???
A (non-local) inner class may be declared as public, protected, private, static, final, or abstract

Can inner classes be static??
Yes inner classes can be static, but they cannot access the non static data of the outer classes, though they can access the static data

Can an inner class be defined inside a method??
Yes it can be defined inside a method and it can access data of the enclosing methods or a formal parameter if it is final

What is an anonymous class??
Some classes defined inside a method do not need a name, such classes are called anonymous classes

What are the rules of anonymous class??
The class is instantiated and declared in the same place
The declaration and instantiation takes the form
new Xxxx () {// body}
Where Xxxx is an interface name.
An anonymous class cannot have a constructor. Since you do not specify a name for the class, you cannot use that name to specify a constructor
10 . Threads

Where does java thread support reside??
It resides in three places
The java.lang.Thread class (Most of the support resides here)
The java.lang.Object class
The java language and virtual machine

What is the difference between Thread and a Process??
Threads run inside process and they share data.
One process can have multiple threads, if the process is killed all the threads inside it are killed, they dont share data

What happens when you call the start() method of the thread??
This registers the thread with a piece of system code called thread scheduler
The schedulers determines which thread is actually running

Does calling start () method of the thread causes it to run??
No it merely makes it eligible to run. The thread still has to wait for the CPU time along with the other threads, then at some time in future, the scheduler will permit the thread to run

When the thread gets to execute, what does it execute??
The thread executes a method call run(). It can execute run() method of either of the two choices given below :
The thread can execute it own run() method.
The thread can execute the run() method of some other objects
For the first case you need to subclass the Thread class and give your subclass a run() method
For the second method you need to have a class implement the interface runnable. Define your run method. Pass this object as an argument to the Thread constructor

How many methods are declared in the interface runnable??
The runnable method declares only one method :
public void run();

Which way would you prefer to implement threading , by extending Thread class or implementing Runnable interface??
The preferred way will be to use Interface Runnable, because by subclassing the Thread class you have single inheritance i.e you wont be able to extend any other class


11 . Threads

What happens when the run() method returns
When the run() method returns, the thread has finished its task and is considered dead. You can't restart a dead thread. You can call the methods of dead thread

What are the different states of the thread
They are as follows:
Running: The state that all thread aspire to be
Various waiting states : Waiting, Sleeping, Suspended and Bloacked
Ready : Waiting only for the CPU
Dead : All done

What is Thread priority
Every thread has a priority, the higher priorit thread gets preference over the lower priority thread by the thread scheduler

What is the range of priority integer
It is from 1 to 10. 10 beings the highest priority and 1 being the lowest

What is the default priority of the thread
The default priority is 5

What happens when you call Thread.yield()
It caused the currently executing thread to move to the ready state if the scheduler is willing to run any other thread in place of the yielding thread.
Yield is a static method of class Thread

What is the advantage of yielding
It allows a time consuming thread to permit other threads to execute

12 . Threads

What happens when you call Thread.sleep()
It passes time without doing anything and without using the CPU. A call to sleep method requests the currently executing thread to cease executing for a specified amount of time.

Does the thread method start executing as soon as the sleep time is over
No, after the specified time is over the thread enters into ready state and will only execute when the scheduler allows it to do so.

What do you mean by thread blocking
If a method needs to wait an indeterminable amount of time until some I/O occurrence takes place, then a thread executing that method should graciously step out of the Running state. All java I/O methods behave this way. A thread that has graciously stepped out in this way is said to be blocked

What threading related methods are there in object class
wait(), notify() and notifyAll() are all part of Object class and they have to be called from synchronized code only

What is preemptive scheduling
In preemptive scheduling there are only two ways for the thread to leave the running state without ecplicitly calling wait() or suspended()
It can cease t be ready to execute ()by calling a blocking I/O method)
It can get moved out by CPU by a higher priorit thread that becomes ready to execute

What is non-preemptive or Time sliced or round robin scheduling
With time slicing the thread is allowd to execute for a limited amount of time. It is then moved to ready state, where it must contend with all the other ready threads.

What are the two ways of synchronizing the code
Synchronizing an entire method by putting the synchronized modifier in the methods declaration. To execute the method, a thread must acquire the lock of the object that owns the method

Synchronize a subset of a method by surrounding the desired lines of code with curly brackets and inserting the synchronized expression before the opening curly. This allows you to synchronize the block on the lock of any object at all, not necessarily the object that owns the code

What happens when the wait() method is called
The calling thread gives up CPU
The calling thread gives up the lock
The calling thread goes into the monitor's waiting pool

What happens when the notify() method is called
One thread gets moved out of monitors waiting pool and into the ready state
The thread that was notified ust reacquire the monitors locl before it can proceed

Using notify () method how you can specify which thread should be notified
You cannot specify which thread is to be notified, hence it is always better to call notifyAll() method

13 . java.lang & java.util Packages

What is the ultimate ancestor of all java classes
Object class is the ancestor of all the java classes

What are important methods of Object class
wait(), notify(), notifyAll(), equals(), toString().

What is the difference between "= =" and "equals()"
"= =" does shallow comparison, It retuns true if the two object points to the same address in the memory, i.e if the same the same reference
"equals()" does deep comparison, it checks if the values of the data in the object are same

What would you use to compare two String variables - the operator == or the method equals()?
I'd use the method equals() to compare the values of the Strings and the == to check if two variables point at the same instance of a String object

Give example of a final class
Math class is final class and hence cannot be extended

What is the difference between String and StringBuffer
String is an immutable class, i.e you cannot change the values of that class
Example :
String str = "java"; // address in memory say 12345
And now if you assign a new value to the variable str then
str = "core java"; then the value of the variable at address 12345 will not change but a new memory is allocated for this variable say 54321
So in the memory address 12345 will have value "java"
And the memory address 54321 will have value "core java" and the variable str will now be pointing to address 54321 in memory

StringBuffer can be modified dynamically
Example:
StringBuffer strt ="java" // address in memory is say 12345
And now if you assign a new value to the variable str then
Str = "core java"; then value in the address of memory will get replaced, a new memory address is not allocated in this case.


 java.lang & java.util Packages

15. What will be the result if you compare StringBuffer with String if both have same values
It will return false as you cannot compare String with StringBuffer

 What is Collection API

The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces.
Example of classes: HashSet, HashMap, ArrayList, LinkedList, TreeSet and TreeMap.
Example of interfaces: Collection, Set, List and Map.

What are different types of collections

A collection has no special order and does not reject duplicates
A list is ordered and does not reject duplicates
A set has no special order but rejects duplicates
A map supports searching on a key field, values of which must be unique

18.Tell  something about Arrays

Arrays are fast to access, but are inefficient if the number of elements grow and if you have to insert or delete an element

Difference between ArrayList and Vector

Vector methods are synchronized while ArrayList methods are not

Iterator a Class or Interface? What is its use?

Iterator is an interface which is used to step through the elements of a Collection

Difference between Hashtable and HashMap

Hashtable does not store null value, while HashMap does
Hashtable is synchronized, while HashMap is not