Tuesday, 31 May 2011

How to mount an ISO image file as a filesystem in AIX


In AIX you "dd" the ISO file into a raw LV, then mount the LV as a filesystem.
Here are the steps for copying the ISO named "image.iso" into "/cd1iso", a JFS filesystem:
1. Create a filesystem with size slightly bigger than the size of the ISO image. Do NOT mount the filesystem:
# /usr/sbin/crfs -v jfs -g rootvg -a size=800M -m/cd1iso -Ano -pro -tno -a frag=4096 -a nbpi=4096 -a ag=8


2. Get the logical volume name associated with the new filesystem:
# lsfs | grep cd1iso (assume it is /dev/lv00)


3. dd the ISO image into rlv00 (raw lv00):
# dd if=image.iso of=/dev/rlv00 bs=10M


4. Alter /cd1iso stanza in /etc/filesystems => vfs=cdrfs and options=ro 


    /cd1iso:
            dev            = /dev/cd1_lv
            vfs             = cdrfs
            log             = /dev/loglv00
            mount           = false
            options         = ro
            account         = false


5. Mount the file system :
# mount /cd1iso


6. When finished, remove the filesystem:
# rmfs /cd1iso

Linux Kernek Panic Reboot


By default after a kernel panic Linux just waits there for a system administrator to hit the restart or powercycle button.  This is because of the value set on "kernel.panic" parameter.


[root@linux23 ~]# cat /proc/sys/kernel/panic
0
[root@linux23 ~]# sysctl -a | grep kernel.panic
kernel.panic = 0
[root@linux23 ~]#


To disable this and make the Linux OS reboot after a kernel panic, we have to set an integer N greater than zero to the paramter "kernel.panic", where "N" is the number of seconds to wait before a automatic reboot.  For example , if you set N = 10 , then the system waits for 10 seconds before automatic reboot. To make this permanent, edit /etc/sysctl.conf and set it.


[root@linux23 ~]# echo "10" > /proc/sys/kernel/panic
0
[root@linux23 ~]# grep kernel.panic /etc/sysctl.conf
kernel.panic = 10
[root@linux23 ~]#

Monday, 23 May 2011

HOW WILL WORK HASHMAP IN JAVA


"Have you used HashMap before" or "What is HashMap? Why do we use it “ 


Almost everybody answers this with yes and then interviewee keep talking about common facts about hashMap like hashMap accpt null while hashtable doesn't, HashMap is not synchronized, hashMap is fast and so on along with basics like its stores key and value pairs etc.
This shows that person has used hashMap and quite familier with the funtionalities HashMap offers but interview takes a sharp turn from here and next set of follow up questions gets more detailed about fundamentals involved in hashmap. Interview here you and come back with questions like


"Do you Know how hashMap works in Java” or 
"How does get () method of HashMap works in Java" 


And then you get answers like I don't bother its standard Java API, you better look code on java; I can find it out in Google at any time etc.
But some interviewee definitely answer this and will say "HashMap works on principle of hashing, we have put () and get () method for storing and retrieving data from hashMap. When we pass an object to put () method to store it on hashMap, hashMap implementation calls
hashcode() method hashMap key object and by applying that hashcode on its own hashing funtion it identifies a bucket location for storing value object , important part here is HashMap stores both key+value in bucket which is essential to understand the retrieving logic. if people fails to recognize this and say it only stores Value in the bucket they will fail to explain the retrieving logic of any object stored in HashMap . This answer is very much acceptable and does make sense that interviewee has fair bit of knowledge how hashing works and how HashMap works in Java.
But this is just start of story and going forward when depth increases a little bit and when you put interviewee on scenarios every java developers faced day by day basis. So next question would be more likely about collision detection and collision resolution in Java HashMap e.g 


"What will happen if two different objects have same hashcode?”


Now from here confusion starts some time interviewer will say that since Hashcode is equal objects are equal and HashMap will throw exception or not store it again etc. then you might want to remind them aobut equals and hashCode() contract that two unequal object in Java very much can have equal hashcode. Some will give up at this point and some will move ahead and say "Since hashcode () is same, bucket location would be same and collision occurs in hashMap, Since HashMap use a linked list to store in bucket, value object will be stored in next node of linked list." great this answer make sense to me though there could be some other collision resolution methods available this is simplest and HashMap does follow this.
But story does not end here and final questions interviewer ask like 


"How will you retreive if two different objects have same hashcode?” 


 Hmmmmmmmmmmmmm
Interviewee will say we will call get() method and then HashMap uses keys hashcode to find out bucket location and retreives object but then you need to remind him that there are two objects are stored in same bucket , so they will say about traversal in linked list until we find the value object , then you ask how do you identify vlaue object because you don't value object to compare ,So until they know that HashMap stores both Key and Value in linked list node they won't be able to resolve this issue and will try and fail.


But those bunch of people who remember this key information will say that after finding bucket location , we will call keys.equals() method to identify correct node in linked list and return associated value object for that key in Java HashMap. Perfect this is the correct answer.


In many cases interviewee fails at this stage because they get confused between hashcode () and equals () and keys and values object in hashMap which is pretty obvious because they are dealing with the hashcode () in all previous questions and equals () come in picture only in case of retrieving value object from HashMap.
Some good developer point out here that using immutable, final object with proper equals () and hashcode () implementation would act as perfect Java HashMap keys and improve performance of Java hashMap by reducing collision. Immutablity also allows caching there hashcode of different keys which makes overall retreival process very fast and suggest that String and various wrapper classes e.g Integer provided by Java Collection API are very good HashMap keys.


Now if you clear all this java hashmap interview question you will be surprised by this very interesting question "What happens On HashMap in Java if the size of the Hashmap exceeds a given threshold defined by load factor ?".
 Until you know how hashmap works exactly you won't be able to answer this question. 
if the size of the map exceeds a given threshold defined by load-factor e.g. if load factor is .75 it will act to re-size the map once it filled 75%. Java Hashmap does that by creating another new bucket array of size twice of previous size of hashmap, and then start putting every old element into that new bucket array and this process is called rehashing because it also applies hash function to find new bucket location. 


If you manage to answer this question on hashmap in java you will be greeted by "do you see any problem with resizing of hashmap in Java" , you might not be able to pick the context and then he will try to give you hint about multiple thread accessing the java hashmap and potentially looking for race condition on HashMap in Java. 


So the answer is Yes there is potential race condition exists while resizing hashmap in Java, if two thread at the same time found that now Java Hashmap needs resizing and they both try to resizing. on the process of resizing of hashmap in Java , the element in bucket which is stored in linked list get reversed in order during there migration to new bucket because java hashmap doesn't append the new element at tail instead it append new element at head to avoid tail traversing. if race condition happens then you will end up with an infinite loop. though this point you can potentially argue that what the hell makes you think to use HashMap in multi-threaded environment to interviewer :) 


I like this question because of its depth and number of concept it touches indirectly, if you look at questions asked during interview this HashMap questions has verified 
Concept of hashing 
Collision resolution in HashMap
Use of equals () and hashCode () method and there importance?
Benefit of immutable object?
race condition on hashmap in Java
Resizing of Java HashMap


Just to summararize here are the answers which does makes sense for above questions


How HashMAp works in Java


HashMap works on principle of hashing, we have put () and get () method for storing and retrieving object form hashMap.When we pass an both key and value to put() method to store on HashMap, it uses key object hashcode() method to calculate hashcode and they by applying hashing on that hashcode it identifies bucket location for storing value object.
While retrieving it uses key object equals method to find out correct key value pair and return value object associated with that key. HashMap uses linked list in case of collision and object will be stored in next node of linked list.


Also hashMap stores both key+value tuple in every node of linked list.


What will happen if two different HashMap key objects have same hashcode?


They will be stored in same bucket but no next node of linked list. And keys equals () method will be used to identify correct key value pair in HashMap.


In terms of usage HashMap is very versatile and I have mostly used hashMap as cache in electronic trading application I have worked . Since finance domain used Java heavily and due to performance reason we need caching a lot HashMap comes as very handy there.

how to get command in unix



  1. Runnig the last executed command in unix:

!find 
This will repeat the last find command executed. It saves lot of time if you re searching for something and you need to execute same command again and again. In fact "!" can be used with any command to invoke previous run of that command.
   2.   Finding files which has been modified less than one day in Unix:
find . -mtime -1


This is my favorite while looking out some issue just to check which files have been modified recently which could be likely cause of  issue, believe me it helps a lot and many a times gives you enough hint of any problem due to intended or unintended file change.


3. List all the files and directories in the box which holds the 777 permission in Unix?
find . -perm 777 –print


I use this command to find out all the executable files , you can also modify it to find all the read only files or files having write permission etc by changing permissions e.g. to find all read only files in current directory : find . –perm 555
Here "." or period denotes current directory. You can replace it with any directory you want.


4. How to do case insensitive search using find command in Unix? Use option “-i" with name, by default find searches are case sensitive.
find . –iname "error" –print 




5. How to delete temporary files using find command in Unix?
find . -name *.tmp -print | xargs rm –f


Use of xargs along with find gives you immense power to do whatever you want with each search result. See another example below


6. How to find all text file which contains word Exception using find command in Unix ?
find . –name *.txt –print | xargs grep “Exception” 


find . –name *.java –print | xargs grep “MemoryCache”, this will search all java files starting from current directory for word "MemoryCache".




7. Finding files only in current directory not searching on sub directories:
While using find command I realized that some time I only need to find files and directories that are new , only in the current directory so I modified the find command as follows.


find . -maxdepth 1 -type f -newer first_file


Another way of doing it is below:


find . -type f -cmin 15 -prune


Means type file, last modified 15 minutes ago, only look at the current directory. (No sub-directories)




8. Find all files in current directory and subdirectory, greater than some size using find command in Unix:
find . -size +1000c -exec ls -l {} \; 


Always use a c after the number, and specify the size in bytes, otherwise you will get confuse because find -size list files based on size of disk block. to find files using a range of file sizes, a minus or plus sign can be specified before the number. The minus sign means "less than," and the plus sign means "greater than." Suppose if you want to find all the files within a range you can use find command as below


find . -size +10000c -size -50000c -print


This example lists all files that are greater than 10,000 bytes, but less than 50,000 bytes: 


9. Find files which are some days old and greater than some size in Unix. Very common scenario where you want to delete some large old files to free some space in your machine. You can use combination of "-mtime" and "-size" to achieve this.


find . -mtime +10 -size +50000c -exec ls -l {} \; 


This command will find which are more than 10 days old and size greater than 50K.


10. You can use "awk" in combination of find to print a formatted output e.g. next command will find all of the symbolic links in your home directory, and print the files your symbolic links points to:


find . -type l -print | xargs ls -ld | awk '{print $10}'


"." says starts from current directory and include all sub directory
"-type l" says list all links


Hope you find this useful , please share how you are using find commands and we can benefit from each others experience and work more efficiently in unix.

Sunday, 1 May 2011

IT PUBLICATIONS


  1. http://www.32bitsonline.com/  A LARGE AMOUNT OF LINUX INFORMATION AVAILABLE HERE
  2. http://xrds.acm.org/  ORIENTAL FRAME WORK DEVELOPING ,EXTENSIBLE IMAGE INPUT AND OUT PUT LIBRARIES AVAILABLE HERE.
  3. http://www.advisor.com/  ADVICE ABOUT E-BUSINESS AND ENTERPRISE DEVELOPMENT STRATEGIES,TECHNOLOGIES.
  4. http://www.bbc.co.uk/news/science_and_environment/  TECHNOLOGY NEWS FROM BBC
  5. http://www.crn.com/   PROVIDERS FOR INFORMATION AND TECHNOLOGY SERVICES

IT BOOKS SITES


  1. http://www.bookpool.com/   ITS TECHNICAL BOOK STORE
  2. http://www.halfpricecomputerbooks.com/  LOW PRICE COMPUTER BOOKS
  3. http://www.technologybooks.com/      NETWORKING RELATED BOOKS AVAILABLE HERE
  4. http://www.wkmn.com         INTERNET WORKING  TOPIC BOOKS AVAILABLE HERE
  5. http://www.standardsdirect.org/  GOOD SITE FOR DOWNLOADING MAJOR INTERNATIONAL STANDARDS

Tuesday, 26 April 2011

unix interview questions



1. How are devices represented in UNIX?


All devices are represented by files called special files that are located in/dev directory. Thus, device files and other files are named and accessed in the same way. A 'regular file' is just an ordinary data file in the disk. A 'block special file' represents a device with characteristics similar to a disk (data transfer in terms of blocks). A 'character special file' represents a device with characteristics similar to a keyboard (data transfer is by stream of bits in sequential order).


2. What is 'inode'?


All UNIX files have its description stored in a structure called 'inode'. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode. In addition to descriptions about the file, the inode contains pointers to the data blocks of the file. If the file is large, inode has indirect pointer to a block of pointers to additional data blocks (this further aggregates for larger files). A block is typically 8k.
Inode consists of the following fields:


File owner identifier
File type
File access permissions
File access times
Number of links
File size
Location of the file data


3. Brief about the directory representation in UNIX?


A Unix directory is a file containing a correspondence between filenames and inodes. A directory is a special file that the kernel maintains. Only kernel modifies directories, but processes can read directories. The contents of a directory are a list of filename and inode number pairs. When new directories are created, kernel makes two entries named '.' (refers to the directory itself) and '..' (refers to parent directory).
System call for creating directory is mkdir (pathname, mode).


4.  What are the Unix system calls for I/O?
- Open: to open a file. Syntax: open (pathname, flag, and mode).
- Create: To create a file. Syntax: create (pathname, mode).
- Close: To close a file. Syntax: close (filedes).
- Read: To read data from a file that is opened. Syntax: read (filedes, buffer, bytes)
- Write: To write data to a file that is opened. Syntax: write (filedes, buffer, bytes)
- Lseek: To position the file pointer at given location in the file.
Syntax: lseek (filedes, offset, from).
- Dup: To make a duplicate copy of an existing file descriptor. Syntax: dup (filedes).
- Fcntl: To make the changes to the properties of an open file.
Syntax: fcntl (filedes, cmd, arg).


5.  What is a FIFO? 
FIFO are otherwise called as 'named pipes'. FIFO (first-in-first-out) is a special file which is said to be data transient. Once data is read from named pipe, it cannot be read again. Also, data can be read only in the order written. It is used in interprocess communication where a process writes to one end of the pipe (producer) and the other reads from the other end (consumer).


6.  What are links and symbolic links in UNIX file system? 
A link is a second name (not a file) for a file. Links can be used to assign more than one name to a file, but cannot be used to assign a directory more than one name or link filenames on different computers.
Symbolic link 'is' a file that only contains the name of another file.Operation on the symbolic link is directed to the file pointed by the it.Both the limitations of links are eliminated in symbolic links.
Commands for linking files are:
Link ln filename1 filename2
Symbolic link ln -s filename1 filename2


7.  How do you create special files like named pipes and device files? 
The system call mknod creates special files in the following sequence.
1. kernel assigns new inode,
2. sets the file type to indicate that the file is a pipe, directory or special file,
3. If it is a device file, it makes the other entries like major, minor device numbers.
For example:
If the device is a disk, major device number refers to the disk controller and minor device number is the disk.


8. What is the difference between internal and external commands?


Internal commands are commands that are already loaded in the system. They can be executed any time and are independent. On the other hand, external commands are loaded when the user requests for them. Internal commands don’t require a separate process to execute them. External commands will have an individual process. Internal commands are a part of the shell while external commands require a Path. If the files for the command are not present in the path, the external command won’t execute.



9. What is difference between ps -ef and ps -auxwww?


This is indeed a good Unix Interview Command Question and I have faced this issue while ago where one culprit process was not visible by execute ps –ef command and we are wondering which process is holding the file.
ps -ef will omit process with very long command line while ps -auxwww will list those process as well.


10. How do you find how many cpu are in your system and there details?


By looking into file /etc/cpuinfo for example you can use below command:
cat /proc/cpuinfo


11. What is difference between HardLink and SoftLink in UNIX?


I have discussed this Unix Command Interview questions  in my blog post difference between Soft link and Hard link in Unix


12. What is Zombie process in UNIX? How do you find Zombie process in UNIX?


 When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the child's exit status. To be able to get this information, the parent calls 'wait()'; In the interval between the child terminating and the parent calling 'wait()', the child is said to be a 'zombie' (If you do 'ps', the child will have a 'Z' in its status field to indicate this.)
Zombie : The process is dead but have not been removed from the process table.




13. There is a file some where in your system which contains word "UnixCommandInterviewQuestions” How will find that file in Unix?


 By using find command in UNIX for details see here 10 example of using find command in Unix


14. In a file word UNIX is appearing many times? How will you count number?
  grep -c "Unix" filename


15. How do you set environment variable which will be accessible form sub shell?


 By using export   for example export count=1 will be available on all sub shell.



Monday, 25 April 2011

java interview questions

What is garbage collection? What is the process that is responsible for doing that in java?  
Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process
What kind of thread is the Garbage collector thread? 
 It is a daemon thread.
What is a daemon thread? 
These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by killing them abruptly.
How will you invoke any external process in Java? 
Runtime.getRuntime().exec(….)
What is the finalize method do? 
Before the invalid objects get garbage collected, the JVM give the user a chance to clean up some resources before it got garbage collected.
What is mutable object and immutable object? 
If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer, …) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float, …)
What is the basic difference between string and stringbuffer object? 
String is an immutable object. StringBuffer is a mutable object.
What is the purpose of Void class? 
The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.
What is reflection? 
Reflection allows programmatic access to information about the fields, methods and constructors of loaded classes, and the use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions.
What is the base class for Error and Exception? 
 Throwable
What is the byte range? 
128 to 127
What is the implementation of destroy method in java.. is it native or java code? 
 This method is not implemented.
What is a package? 
 To group set of classes into a single unit is known as packaging. Packages provides wide namespace ability.
What are the approaches that you will follow for making a program very efficient? 
By avoiding too much of static methods avoiding the excessive and unnecessary use of synchronized methods Selection of related classes based on the application (meaning synchronized classes for multiuser and non-synchronized classes for single user) Usage of appropriate design patterns Using cache methodologies for remote invocations Avoiding creation of variables within a loop and lot more.
What is a DatabaseMetaData? 
 Comprehensive information about the database as a whole.
What is Locale? 
A Locale object represents a specific geographical, political, or cultural region
How will you load a specific locale? 
 Using ResourceBundle.getBundle(…);
What is JIT and its use? 
Really, just a very fast compiler… In this incarnation, pretty much a one-pass compiler — no offline computations. So you can’t look at the whole method, rank the expressions according to which ones are re-used the most, and then generate code. In theory terms, it’s an on-line problem.
Is JVM a compiler or an interpreter? 
 Interpreter
When you think about optimization, what is the best way to findout the time/memory consuming process? 
 Using profiler


 What is immutable object? Can you write immutable object?

You need to make class final and all its member final so that once objects gets crated no one can modify its state. You can achieve same functionality by making member as non final but private and not modifying them except in constructor.


 Does all property of immutable object needs to be final?
Not necessary as stated above you can achieve same functionality by making member as non final but private and not modifying them except in constructor.


What is the difference between creating String as new () and literal?
When we create string with new () it’s created in heap and not added into string pool while String created using literal are created in String pool itself which exists in Perm area of heap.


How does substring () inside String works?
Another good question, I think answer is not sufficient but here it is “Substring creates new object out of string by taking a portion of original string”.


 How do you handle error condition while writing stored procedure or accessing stored procedure from java?
Open for all, my friend didn't know the answer so he didn't mind telling me.


What is difference between Executor.submit() and Executer.execute() method ? 
(Former returns an object of Future which can be used to find result from worker thread)


What is the difference between factory and abstract factory pattern?
Open for all, he explains about factory pattern and how factory pattern saves maintenance time by encapsulating logic of object creation but didn't know exact answer


What is Singleton? is it better to make whole method synchronized or only critical section synchronized ?
see my article 10 Interview questions on Singleton Pattern in Java




Can you write code for iterating over hashmap in Java 4and Java 5 ?
Tricky one but he managed to write using while and for loop.


When do you override hashcode and equals() ?
Whenever necessary especially if you want to do equality check or want to use your object as key in HashMap.


Is it better to synchronize critical section of getInstance() method or whole getInstance() method ?
Answer is critical section because if we lock whole method than every time some one call this method will have to wait even though we are not creating any object)


 What is the difference when String is gets created using literal or new() operator ?
When we create string with new() its created in heap and not added into string pool while String created using literal are created in String pool itself which exists in Perm area of heap.


Does not overriding hashcode() method has any performance implication ?
This is a good question and open to all , as per my knowledge a poor hashcode function will result in frequent collision in HashMap which eventually increase time for adding an object into Hash Map.

C++ INTERVIEW QUESTIONS


What is the diffrence between c# and c+?

c is procedure oriented language&c++is object oriented language.
 

Read the following program carefully and write the output of the program. Explain each line of code according to given numbering. #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> 1……………… int main (void) { pid_t pid; 2………………………… pid = fork(); 3…………………………. if (pid > 0) { int i; 4………………………… for (i = 0; i < 5; i++) { 5………………… …………… printf(" I AM VU : %d\n", i); 6………………… …………… sleep(1); } exit(0); } 7………………… ……… else if (pid == 0) { int j; for (j = 0; j < 5; j++) { 8……………………………… printf(" I have no child: %d\n", j); sleep(1); } _exit(0); } else { 9………………………………fprintf(stderr, "can't fork, error %d\n", errno); 10……………… … ………… exit (EXIT_FAILURE); } ?

1 int main (void) Starts the main function 
2 pid = fork ( ); The fork ( ) method will call and store 
the integer value in the pid variable. In case of Child “0” 
value returned while the parent will store the “process id” 
of the child. In case when fork fails it will be 
initialized by -1 
3 if (pid > 0) This condition will be only true when fork 
failed. 
4 for (i = 0; i < 5; i++) Limmitations of for loop are 
declared and the loop starts 
5 printf(" I AM VU : %d\n", i); 
Prints I AM VU and the value of I message on screen 
6 sleep(1); Process sleeps 
7 else if (pid == 0) Now this blok of code executes in 
parent process since fork returns the ID to the parent 
process from child. which is not 0. 
8 printf(" I have no child: %d\n", j); 
“I have no child” is printed on the screen 
9 fprintf(stderr, "can't fork, error %d\n", errno); 
If the given conditions are not true then this error 
message is send 
10 exit (EXIT_FAILURE); system call will terminate the 
process abnormally as it fails.

1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 generate this output using for loop?

#include<conio.h>
#include<stdio.h>
void main()
{
int i,j,k,l;
for(i=1;i<=4;i++)
{
 for(k=i;k<=4;k++)
 {
  printf(" ");
 }
 for(j=1;j<=i;j++)
 {
  printf(" %d",j);
 }
printf("\n");
}
for(i=3;i>0;i--)
 {
 for(l=i;l<=3;l++)
  {
  printf(" ");
  }
 for(j=1;j<=i;j++)
  {
  printf(" %d",j);
  }
 printf("\n");
 }
getch();

What’s the advantage of using System.Text.StringBuilder over System.String? 
StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.
Can you store multiple data types in System.Array?
 No.
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
 The first one performs a deep copy of the array, the second one is shallow.
How can you sort the elements of the array in descending order? 
By calling Sort() and then Reverse() methods.
What’s the .NET datatype that allows the retrieval of data by a unique key?
 HashTable.
What’s class SortedList underneath? 
A sorted HashTable.
Will finally block get executed if the exception had not occurred? 
Yes.
What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?
 A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
Can multiple catch blocks be executed? 
No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
Why is it a bad idea to throw your own exceptions? 
Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.
What’s a delegate? 
A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
What’s a multicast delegate? 
It’s a delegate that points to and eventually fires off several methods.
How’s the DLL Hell problem solved in .NET? 
Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly

What are the ways to deploy an assembly? 
An MSI installer, a CAB archive, and XCOPY command.
 
 

civils interview questions and answers



Tell me something interesting about yourself?

Don’t be embarrassed or mention that you collect beer mats. Take this opportunity to make some positive statements. In particular your relevant strengths, qualities, achievements and recent experience could all be described. Equally, if you possess a particular distinction it should be mentioned here. An example could be a sporting achievement of significance, a local honor for helpfulness or bravery or anything else that will help the interviewer single you out in their mind: as long as it is positive and commendable of course. 


You may be asked about something you have mentioned in your application. In which case you will be expected to be reasonably knowledgeable and interested in the topic. Be prepared! 


Why compression strenth of concrete is tested with a cube of size 150x150x150 mm ?


Because as per IS standard the compressive strength is 
taken as per these specimen.


What is the diffrence between FE 415 & FE 500 TMT BARS?


Yield stress of the steel for Fe 415 is 415 n/mm2 and for Fe
500 is 500n/mm2.


What is stub column ?


A stub column is column which does no have any base  which provided only for stiffness purpose of the member.


How many quantity of water use in 1cu.m. concrete?


Depending upon grade of concrete and water cement ratio. it will be about 180litres/cum.



What would your present employer say about your suitability for the Civil Service?


Bearing in mind that the Board has plenty of references from your previous employers you need to be careful here. Be confident, but also be honest. Just pick on a few issues to start with and see if the discussion goes any deeper. There may be a reason for the Board to be checking something out that a previous employer of yours has said about you. This could be either positive or negative. 


Alternatively it could just be a conventional and routine question. It is best to be prepared and perhaps check with your referees before attending the Selection Board. 



How to find motors H.P. whout any rating?(only give you a motor and multimeter)


If there is provision to apply load on it ,the HP can be ascertained from the circle diagram of the motor.



 Explain what you will bring to the fast stream should you be successful?


A straightforward question asking you to outline your strengths and qualities. At least that is the way you should look at it. You should ideally consider the key requirements made of fast stream applicants from the information the selection board provided you with and reflect this back to the board. 


You should certainly consider mentioning some or all of the following:


Desire/ambition to succeed
Interests in taking a lead role
Willingness to work flexibly and as required
A profound interest in researching and preparing policy documents
An interest in and aptitude for team work
Ability to take decisions
Ability to priorities activities etc,












Saturday, 23 April 2011

digital logic design interview questions



1) Explain about setup time and hold time, what will happen if there is setup time and hold tine violation, how to overcome this?


Set up time is the amount of time before the clock edge that the input signal needs to be stable to guarantee it is accepted properly on the clock edge.
Hold time is the amount of time after the clock edge that same input signal has to be held before changing it to make sure it is sensed properly at the clock edge.
Whenever there are setup and hold time violations in any flip-flop, it enters a state where its output is unpredictable: this state is known as metastable state (quasi stable state); at the end of metastable state, the flip-flop settles down to either '1' or '0'. This whole process is known as metastability.


2) What is skew, what are problems associated with it and how to minimize it?


In circuit design, clock skew is a phenomenon in synchronous circuits in which the clock signal (sent from the clock circuit) arrives at different components at different times.
This is typically due to two causes. The first is a material flaw, which causes a signal to travel faster or slower than expected. The second is distance: if the signal has to travel the entire length of a circuit, it will likely (depending on the circuit's size) arrive at different parts of the circuit at different times. Clock skew can cause harm in two ways. Suppose that a logic path travels through combinational logic from a source flip-flop to a destination flip-flop. If the destination flip-flop receives the clock tick later than the source flip-flop, and if the logic path delay is short enough, then the data signal might arrive at the destination flip-flop before the clock tick, destroying there the previous data that should have been clocked through. This is called a hold violation because the previous data is not held long enough at the destination flip-flop to be properly clocked through. If the destination flip-flop receives the clock tick earlier than the source flip-flop, then the data signal has that much less time to reach the destination flip-flop before the next clock tick. If it fails to do so, a setup violation occurs, so-called because the new data was not set up and stable before the next clock tick arrived. A hold violation is more serious than a setup violation because it cannot be fixed by increasing the clock period.
Clock skew, if done right, can also benefit a circuit. It can be intentionally introduced to decrease the clock period at which the circuit will operate correctly, and/or to increase the setup or hold safety margins. The optimal set of clock delays is determined by a linear program, in which a setup and a hold constraint appears for each logic path. In this linear program, zero clock skew is merely a feasible point.
Clock skew can be minimized by proper routing of clock signal (clock distribution tree) or putting variable delay buffer so that all clock inputs arrive at the same time


3. How do you convert a XOR gate into a buffer and a inverter (Use only one XOR gate for each)


4.Implement an 2-input AND gate using a 2x1 mux.

5.what is a multiplexer? 
A Multiplexer  is a combinational  circut which selects one of many input signals and directs to the only              out put.



microprocessor interview questions, answers



What is a Microprocessor?
Microprocessor is a program-controlled device, which fetches the instructions from memory, decodes and executes the instructions. Most Micro Processor are single- chip devices.
What are the flags in 8086?
In 8086 Carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag, Trace flag, Interrupt flag, Direction flag, and Sign flag.
Why crystal is a preferred clock source?
Because of high stability, large Q (Quality Factor) & the frequency that doesn?t drift with aging. Crystal is used as a clock source most of the times.
In 8085 which is called as High order / Low order Register?
Flag is called as Low order register & Accumulator is called as High order Register.
What is Tri-state logic?
Three Logic Levels are used and they are High, Low, High impedance state. The high and low are normal logic levels & high impedance state is electrical open circuit conditions. Tri-state logic has a third line called enable line.
What happens when HLT instruction is executed in processor?
The Micro Processor enters into Halt-State and the buses are tri-stated.
Which Stack is used in 8085?
LIFO (Last In First Out) stack is used in 8085.In this type of Stack the last stored information can be retrieved first
What is Program counter?
Program counter holds the address of either the first byte of the next instruction to be fetched for execution or the address of the next byte of a multi byte instruction, which has not been completely fetched. In both the cases it gets incremented automatically one by one as the instruction bytes get fetched. Also Program register keeps the address of the next instruction.
What are the various registers in 8085?
Accumulator register, Temporary register, Instruction register, Stack Pointer, Program Counter are the various registers in 8085
What is 1st / 2nd / 3rd / 4th generation processor?
The processor made of PMOS / NMOS / HMOS / HCMOS technology is called 1st / 2nd / 3rd / 4th generation processor, and it is made up of 4 / 8 / 16 / 32 bits.
Name the processor lines of two major manufacturers?
High-end: Intel - Pentium (II, III, 4), AMD - Athlon. Low-end: Intel - Celeron, AMD - Duron. 64-bit: Intel - Itanium 2, AMD - Opteron.
What?s the speed and device maximum specs for Firewire?
IEEE 1394 (Firewire) supports the maximum of 63 connected devices with speeds up to 400 Mbps. Where?s MBR located on the disk? Main Boot Record is located in sector 0, track 0, head 0, cylinder 0 of the primary active partition.
Where does CPU Enhanced mode originate from?
Intel?s 80386 was the first 32-bit processor, and since the company had to backward-support the 8086. All the modern Intel-based processors run in the Enhanced mode, capable of switching between Real mode (just like the real 8086) and Protected mode, which is the current mode of operation.
How many bit combinations are there in a byte?
Byte contains 8 combinations of bits.
Have you studied buses? What types?
There are three types of buses.
Address bus: This is used to carry the Address to the memory to fetch either Instruction or Data.
Data bus : This is used to carry the Data from the memory.
Control bus : This is used to carry the Control signals like RD/WR, Select etc.
What is the Maximum clock frequency in 8086?
5 Mhz is the Maximum clock frequency in 8086.
What is meant by Maskable interrupts?
An interrupt that can be turned off by the programmer is known as Maskable interrupt.
What is Non-Maskable interrupts?
An interrupt which can be never be turned off (ie. disabled) is known as Non-Maskable interrupt
What are the different functional units in 8086?
Bus Interface Unit and Execution unit, are the two different functional units in 8086.
What are the various segment registers in 8086?
Code, Data, Stack, Extra Segment registers in 8086.
What does EU do?
Execution Unit receives program instruction codes and data from BIU, executes these instructions and store the result in general registers.
Which Stack is used in 8086? k is used in 8086?
FIFO (First In First Out) stack is used in 8086.In this type of Stack the first stored information is retrieved first.
What are the flags in 8086?
In 8086 Carry flag, Parity flag, Auxiliary carry flag, Zero flag, Overflow flag, Trace flag, Interrupt flag, Direction flag, and Sign flag.
What is SIM and RIM instructions?
SIM is Set Interrupt Mask. Used to mask the hardware interrupts.
RIM is Read Interrupt Mask. Used to check whether the interrupt is Masked or not.
What is the difference between 8086 and 8088?
The BIU in 8088 is 8-bit data bus & 16- bit in 8086.Instruction queue is 4 byte long in 8088and 6 byte in 8086.
Give example for Non-Maskable interrupts?
Trap is known as Non-Maskable interrupts, which is used in emergency condition.
Give examples for Micro controller?
Z80, Intel MSC51 &96, Motorola are the best examples of Microcontroller.
What are the various interrupts in 8086?
Maskable interrupts, Non-Maskable interrupts.
What is meant by Maskable interrupts?
An interrupt that can be turned off by the programmer is known as Maskable interrupt.
What is Non-Maskable interrupts?
 An interrupt which can be never be turned off (ie.disabled) is known as Non-Maskable interrupt.