Java Interview Questions and Answers 6
The purpose of the System class is to provide access to system resources.
2.What is the purpose of the finally clause of a try-catch-finally statement?
The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.
3.What is the Locale class?
The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.
4.What is an abstract method?
An abstract method is a method whose implementation is deferred to a subclass. Or, a method that has no implementation.
5.What is the difference between interface and abstract class?
interface contains methods that must be abstract; abstract class may contain concrete methods. interface contains variables that must be static and final; abstract class may contain non-final and final variables. members an interface are public by default, abstract class may contain non-public members. interface is used to "implements"; whereas abstract class is used to "extends". interface can be used to achieve multiple inheritance; abstract class can be used as a single inheritance. interface can "extends" another interface, abstract class can "extends" another class and "implements" multiple interfaces. interface is absolutely abstract; abstract class can be invoked if a main() exists. interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces. If given a choice, use interface instead of abstract class.
6.What is a static method?
A static method is a method that belongs to the class rather than any object of the class and doesn't apply to an object or even require that any objects of the class have been instantiated.
7.What is a protected method?
A protected method is a method that can be accessed by any method in its package and inherited by any subclass of its class.
8.What is the difference between a static and a non-static inner class?
A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.
9.What is an object's lock and which object's have locks?
An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock. All objects and classes have locks. A class's lock is acquired on the class's Class object.
10.When can an object reference be cast to an interface reference?
An object reference can be cast to an interface reference when the object implements the referenced interface.
11.What is the difference between a Window and a Frame?
The Frame class extends Window to define a main application window that can have a menu bar.
12.What is the difference between a Window and a Frame?
Heavy weight components like Abstract Window Toolkit (AWT), depend on the local windowing toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button. In this relationship, the Motif button is called the peer to the java.awt.Button. If you create two Buttons, two peers and hence two Motif Buttons are also created. The Java platform communicates with the Motif Buttons using the Java Native Interface. For each and every component added to the application, there is an additional overhead tied to the local windowing system, which is why these components are called heavy weight.
13.Which package has light weight components?
javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.
14.What are peerless components?
The peerless components are called light weight components.
15.What is the difference between the Font and FontMetrics classes?
The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object
Java Interview Questions and Answers 5
The Canvas, Frame, Panel, and Applet classes support painting.
2.What is a native method?
A native method is a method that is implemented in a language other than Java.
3.How can you write a loop indefinitely?
for(;;)--for loop; while(true)--always true, etc.
4.Can an anonymous class be declared as implementing an interface and extending a class?
An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.
5.What is the purpose of finalization?
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.
6.When should the method invokeLater()be used?
This method is used to ensure that Swing components are updated through the event-dispatching thread.
7.How many methods in Object class?
This question is not asked to test your memory. It tests you how well you know Java. Ten in total.
clone()
equals() & hashcode()
getClass()
finalize()
wait() & notify()
toString()
8.How does Java handle integer overflows and underflows?
It uses low order bytes of the result that can fit into the size of the type allowed by the operation.
9.What is the numeric promotion?
Numeric promotion is used with both unary and binary bitwise operators. This means that byte, char, and short values are converted to int values before a bitwise operator is applied.
If a binary bitwise operator has one long operand, the other operand is converted to a long value.
The type of the result of a bitwise operation is the type to which the operands have been promoted. For example:
short a = 5;
byte b = 10;
long c = 15;
The type of the result of (a+b) is int, not short or byte. The type of the result of (a+c) or (b+c) is long.
10.Is the numeric promotion available in other platform?
Yes. Because Java is implemented using a platform-independent virtual machine, bitwise operations always yield the same result, even when run on machines that use radically different CPUs.
11.What is the difference between the Boolean & operator and the && operator?
If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.
Operator & has no chance to skip both sides evaluation and && operator does. If asked why, give details as above.
12.When is the ArithmeticException throwQuestion: What is the GregorianCalendar class?
The GregorianCalendar provides support for traditional Western calendars.
13.What is the SimpleTimeZone class?
The SimpleTimeZone class provides support for a Gregorian calendar.
14.How can a subclass call a method or a constructor defined in a superclass?
Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass's constructor.
15.What is the Properties class?
The properties class is a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used.
16.What is the purpose of the Runtime class?
The purpose of the Runtime class is to provide access to the Java runtime system.
Java Interview Questions and Answers 4
The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to communicate each other.
2.What are the high-level thread states?
The high-level thread states are ready, running, waiting, and dead.
3.What is the difference between yielding and sleeping?
When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.
4.What happens when a thread cannot acquire a lock on an object?
If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available.
5.What is the difference between Process and Thread?
A process can contain multiple threads. In most multithreading operating systems, a process gets its own memory address space; a thread doesn't. Threads typically share the heap belonging to their parent process. For instance, a JVM runs in a single process in the host O/S. Threads in the JVM share the heap belonging to that process; that's why several threads may access the same object. Typically, even though they share a common heap, threads have their own stack space. This is how one thread's invocation of a method is kept separate from another's. This is all a gross oversimplification, but it's accurate enough at a high level. Lots of details differ between operating systems. Process vs. Thread A program vs. similar to a sequential program an run on its own vs. Cannot run on its own Unit of allocation vs. Unit of execution Have its own memory space vs. Share with others Each process has one or more threads vs. Each thread belongs to one process Expensive, need to context switch vs. Cheap, can use process memory and may not need to context switch More secure. One process cannot corrupt another process vs. Less secure. A thread can write the memory used by another thread
6.Can an inner class declared inside of a method access local variables of this method?
It's possible if these variables are final.
7.What can go wrong if you replace &emp;&emp; with &emp; in the following code: String a=null; if (a!=null && a.length()>10) {...}
A single ampersand here would lead to a NullPointerException.
8.What is the Vector class?
The Vector class provides the capability to implement a growable array of objects
9.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.
10.If a method is declared as protected, where may the method be accessed?
A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.
11.What is an Iterator interface?
The Iterator interface is used to step through the elements of a Collection.
12.How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.
13.What's the main difference between a Vector and an ArrayList?
Java Vector class is internally synchronized and ArrayList is not.
14.What are wrapped classes?
Wrapped classes are classes that allow primitive types to be accessed as objects.
15.Does garbage collection guarantee that a program will not run out of memory?
No, it doesn't. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.
16What is the difference between preemptive scheduling and time slicing?
Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.
Java Interview Questions and Answers III
With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often causes dirty data and leads to significant errors.
2.What are synchronized methods and synchronized statements?
Synchronized methods are methods that are used to control access to a method or an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.
3.What are three ways in which a thread can enter the waiting state?
A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.
4.Can a lock be acquired on a class?
Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.
5.What's new with the stop(), suspend() and resume() methods in JDK 1.2?
The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.
6.What is the preferred size of a component?
The preferred size of a component is the minimum component size that will allow the component to display normally.
7.What's the difference between J2SDK 1.5 and J2SDK 5.0?
There's no difference, Sun Microsystems just re-branded this version.
8.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.
9.What is thread?
A thread is an independent path of execution in a system.
10.What is multi-threading?
Multi-threading means various threads that run in a system.
11.How does multi-threading take place on a computer with a single CPU?
The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
14.How to create a thread in a program?
You have two ways to do so. First, making your class "extends" Thread class. Second, making your class "implements" Runnable interface. Put jobs in a run() method and call start() method to start the thread.
15.Can Java object be locked down for exclusive use by a given thread?
Yes. You can lock an object by putting it in a "synchronized" block. The locked object is inaccessible to any thread other than the one that explicitly claimed it.
16.Can each Java object keep track of all the threads that want to exclusively access to it?
Yes. Use Thread.currentThread() method to track the accessing thread.
17.Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?
Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.
18.What invokes a thread's run() method?
After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.
Java Interview Questions and Answers II
Java is an object-oriented programming language developed initially by James Gosling and colleagues at Sun Microsystems. The language, initially called Oak (named after the oak trees outside Gosling's office), was intended to replace C++, although the feature set better resembles that of Objective C. Java should not be confused with JavaScript, which shares only the name and a similar C-like syntax. Sun Microsystems currently maintains and updates Java regularly.
2.What does a well-written OO program look like?
A well-written OO program exhibits recurring structures that promote abstraction, flexibility, modularity and elegance.
3.Can you have virtual functions in Java?
Yes, all functions in Java are virtual by default. This is actually a pseudo trick question because the word "virtual" is not part of the naming convention in Java (as it is in C++, C-sharp and VB.NET), so this would be a foreign concept for someone who has only coded in Java. Virtual functions or virtual methods are functions or methods that will be redefined in derived classes.
Jack developed a program by using a Map container to hold key/value pairs. He wanted to make a change to the map. He decided to make a clone of the map in order to save the original data on side. What do you think of it? ?
If Jack made a clone of the map, any changes to the clone or the original map would be seen on both maps, because the clone of Map is a shallow copy. So Jack made a wrong decision.
4.What is more advisable to create a thread, by implementing a Runnable interface or by extending Thread class?
Strategically speaking, threads created by implementing Runnable interface are more advisable. If you create a thread by extending a thread class, you cannot extend any other class. If you create a thread by implementing Runnable interface, you save a space for your class to extend another class now or in future.
5.What is NullPointerException and how to handle it?
When an object is not initialized, the default value is null. When the following things happen, the NullPointerException is thrown:
--Calling the instance method of a null object.
--Accessing or modifying the field of a null object.
--Taking the length of a null as if it were an array.
--Accessing or modifying the slots of null as if it were an array.
--Throwing null as if it were a Throwable value.
The NullPointerException is a runtime exception. The best practice is to catch such exception even if it is not required by language design.
6.An application needs to load a library before it starts to run, how to code?
One option is to use a static block to load a library before anything is called. For example,
class Test {
static {
System.loadLibrary("path-to-library-file");
}
....
}
When you call new Test(), the static block will be called first before any initialization happens. Note that the static block position may matter.
7.How could Java classes direct program messages to the system console, but error messages, say to a file?
The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the standard output could be re-directed:
Stream st = new Stream(new FileOutputStream("output.txt")); System.setErr(st); System.setOut(st);
8.What's the difference between an interface and an abstract class?
An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.
9.Name the containers which uses Border Layout as their default layout?
Containers which uses Border Layout as their default are: window, Frame and Dialog classes.
10.What do you understand by Synchronization?
Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access one resource at a time. In non synchronized multithreaded application, it is possible for one thread to modify a shared object while another thread is in the process of using or updating the object's value.
Synchronization prevents such type of data corruption.
E.g. Synchronizing a function:
public synchronized void Method1 () {
// Appropriate method-related code.
}
E.g. Synchronizing a block of code inside a function:
public myFunction (){
synchronized (this) {
// Synchronized code here.
}
}
Java Interview Questions and Answers I
The program compiles properly but at runtime it will give "Main method not public." message.
2) What is meant by pass by reference and pass by value in Java?
Pass by reference means, passing the address itself rather than passing the value. Pass by value means passing a copy of the value.
3) If you’re overriding the method equals() of an object, which other method you might also consider?
hashCode().
4) What is Byte Code? Or What gives java it’s “write once and run anywhere” nature?
All Java programs are compiled into class files that contain bytecodes. These byte codes can be run in any platform and hence java is said to be platform independent.
5) Expain the reason for each keyword of public static void main(String args[])?
public- main(..) is the first method called by java environment when a program is executed so it has to accessible from java environment. Hence the access specifier has to be public. static: Java environment should be able to call this method without creating an instance of the class , so this method must be declared as static. void: main does not return anything so the return type must be void The argument String indicates the argument type which is given at the command line and arg is an array for string given during command line.
6) What if the static modifier is removed from the signature of the main method? OrWhat if I do not provide the String array as the argument to the method?
Program compiles. But at runtime throws an error "NoSuchMethodError".
7) Why oracle Type 4 driver is named as oracle thin driver?
Oracle provides a Type 4 JDBC driver, referred to as the Oracle “thin” driver. This driver includes its own implementation of a TCP/IP version of Oracle’s Net8 written entirely in Java, so it is platform independent, can be downloaded to a browser at runtime, and does not require any Oracle software on the client side. This driver requires a TCP/IP listener on the server side, and the client connection string uses the TCP/IP port address, not the TNSNAMES entry for the database name.
8) What is the difference between final, finally and finalize?
What do you understand by the java final keyword? OrWhat is final, finalize() and finally? OrWhat is finalize() method? OrWhat is the difference between final, finally and finalize? OrWhat does it mean that a class or member is final?o final - declare constanto finally - handles exceptiono finalize - helps in garbage collectionVariables defined in an interface are implicitly final. A final class can't be extended i.e., final class may not be subclassed. This is done for security reasons with basic classes like String and Integer. It also allows the compiler to make some optimizations, and makes thread safety a little easier to achieve. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant). finalize() method is used just before an object is destroyed and garbage collected. finally, a key word used in exception handling and will be executed whether or not an exception is thrown. For example, closing of open connections is done in the finally method.
9) What is the Java API?
The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.
10) What is the GregorianCalendar class?
The GregorianCalendar provides support for traditional Western calendars.
11) What is the ResourceBundle class?
The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program's appearance to the particular locale in which it is being run.
12) Why there are no global variables in Java?
Global variables are globally accessible. Java does not support globally accessible variables due to following reasons: * The global variables breaks the referential transparency * Global variables creates collisions in namespace.
13) How to convert String to Number in java program?
The valueOf() function of Integer class is is used to convert string to Number.Here is the code example:String numString = "1000";int id=Integer.valueOf(numString).intValue();
14) What is the SimpleTimeZone class?
The SimpleTimeZone class provides support for a Gregorian calendar.
16) What is the difference between a while statement and a do statement?
A while statement (pre test) checks at the beginning of a loop to see whether the next loop iteration should occur.A do while statement (post test) checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the loop body at least once.
HR Interview Questions and Answers Paper II
1.Why are you leaving (or did you leave) this position ?
(If you have a job presently tell the hr)
If you’re not yet 100% committed to leaving your present post, don’t be afraid to say so. Since you have a job, you are in a stronger position than someone who does not. But don’t be coy either. State honestly what you’d be hoping to find in a new spot. Of course, as stated often before, you answer will all the stronger if you have already uncovered what this position is all about and you match your desires to it.
(If you do not presently have a job tell the hr.)
Never lie about having been fired. It’s unethical – and too easily checked. But do try to deflect the reason from you personally. If your firing was the result of a takeover, merger, division wide layoff, etc., so much the better.
But you should also do something totally unnatural that will demonstrate consummate professionalism. Even if it hurts , describe your own firing – candidly, succinctly and without a trace of bitterness – from the company’s point-of-view, indicating that you could understand why it happened and you might have made the same decision yourself.
Your stature will rise immensely and, most important of all, you will show you are healed from the wounds inflicted by the firing. You will enhance your image as first-class management material and stand head and shoulders above the legions of firing victims who, at the slightest provocation, zip open their shirts to expose their battle scars and decry the unfairness of it all.
For all prior positions:
Make sure you’ve prepared a brief reason for leaving. Best reasons: more money, opportunity, responsibility or growth.
2. The "Silent Treatment"
Like a primitive tribal mask, the Silent Treatment loses all it power to frighten you once you refuse to be intimidated. If your interviewer pulls it, keep quiet yourself for a while and then ask, with sincere politeness and not a trace of sarcasm, “Is there anything else I can fill in on that point?” That’s all there is to it.
Whatever you do, don’t let the Silent Treatment intimidate you into talking a blue streak, because you could easily talk yourself out of the position.
3. Why should I hire you?
By now you can see how critical it is to apply the overall strategy of uncovering the employer’s needs before you answer questions. If you know the employer’s greatest needs and desires, this question will give you a big leg up over other candidates because you will give him better reasons for hiring you than anyone else is likely to…reasons tied directly to his needs.
Whether your interviewer asks you this question explicitly or not, this is the most important question of your interview because he must answer this question favorably in is own mind before you will be hired. So help him out! Walk through each of the position’s requirements as you understand them, and follow each with a reason why you meet that requirement so well.
Example: “As I understand your needs, you are first and foremost looking for someone who can manage the sales and marketing of your book publishing division. As you’ve said you need someone with a strong background in trade book sales. This is where I’ve spent almost all of my career, so I’ve chalked up 18 years of experience exactly in this area. I believe that I know the right contacts, methods, principles, and successful management techniques as well as any person can in our industry.”
“You also need someone who can expand your book distribution channels. In my prior post, my innovative promotional ideas doubled, then tripled, the number of outlets selling our books. I’m confident I can do the same for you.”
“You need someone to give a new shot in the arm to your mail order sales, someone who knows how to sell in space and direct mail media. Here, too, I believe I have exactly the experience you need. In the last five years, I’ve increased our mail order book sales from $600,000 to $2,800,000, and now we’re the country’s second leading marketer of scientific and medical books by mail.” Etc., etc., etc.,
Every one of these selling “couplets” (his need matched by your qualifications) is a touchdown that runs up your score. IT is your best opportunity to outsell your competition.
4. Aren’t you overqualified for this position?
As with any objection, don’t view this as a sign of imminent defeat. It’s an invitation to teach the interviewer a new way to think about this situation, seeing advantages instead of drawbacks.
Example: “I recognize the job market for what it is – a marketplace. Like any marketplace, it’s subject to the laws of supply and demand. So ‘overqualified’ can be a relative term, depending on how tight the job market is. And right now, it’s very tight. I understand and accept that.”
“I also believe that there could be very positive benefits for both of us in this match.”
“Because of my unusually strong experience in ________________ , I could start to contribute right away, perhaps much faster than someone who’d have to be brought along more slowly.”
“There’s also the value of all the training and years of experience that other companies have invested tens of thousands of dollars to give me. You’d be getting all the value of that without having to pay an extra dime for it. With someone who has yet to acquire that experience, he’d have to gain it on your nickel.”
“I could also help you in many things they don’t teach at the Harvard Business School. For example…(how to hire, train, motivate, etc.) When it comes to knowing how to work well with people and getting the most out of them, there’s just no substitute for what you learn over many years of front-line experience. You company would gain all this, too.”
“From my side, there are strong benefits, as well. Right now, I am unemployed. I want to work, very much, and the position you have here is exactly what I love to do and am best at. I’ll be happy doing this work and that’s what matters most to me, a lot more that money or title.”
“Most important, I’m looking to make a long term commitment in my career now. I’ve had enough of job-hunting and want a permanent spot at this point in my career. I also know that if I perform this job with excellence, other opportunities cannot help but open up for me right here. In time, I’ll find many other ways to help this company and in so doing, help myself. I really am looking to make a long-term commitment.”
NOTE: The main concern behind the “overqualified” question is that you will leave your new employer as soon as something better comes your way. Anything you can say to demonstrate the sincerity of your commitment to the employer and reassure him that you’re looking to stay for the long-term will help you overcome this objection.
5. Where do you see yourself five years from now?
Reassure your interviewer that you’re looking to make a long-term commitment…that this position entails exactly what you’re looking to do and what you do extremely well. As for your future, you believe that if you perform each job at hand with excellence, future opportunities will take care of themselves.
Example: “I am definitely interested in making a long-term commitment to my next position. Judging by what you’ve told me about this position, it’s exactly what I’m looking for and what I am very well qualified to do. In terms of my future career path, I’m confident that if I do my work with excellence, opportunities will inevitable open up for me. It’s always been that way in my career, and I’m confident I’ll have similar opportunities here.”
6. Describe your ideal company, location and job.
The only right answer is to describe what this company is offering, being sure to make your answer believable with specific reasons, stated with sincerity, why each quality represented by this opportunity is attractive to you.
Remember that if you’re coming from a company that’s the leader in its field or from a glamorous or much admired company, industry, city or position, your interviewer and his company may well have an “Avis” complex. That is, they may feel a bit defensive about being “second best” to the place you’re coming from, worried that you may consider them bush league.
This anxiety could well be there even though you’ve done nothing to inspire it. You must go out of your way to assuage such anxiety, even if it’s not expressed, by putting their virtues high on the list of exactly what you’re looking for, providing credible reason for wanting these qualities.
If you do not express genuine enthusiasm for the firm, its culture, location, industry, etc., you may fail to answer this “Avis” complex objection and, as a result, leave the interviewer suspecting that a hot shot like you, coming from a Fortune 500 company in New York, just wouldn’t be happy at an unknown manufacturer based in Topeka, Kansas.
HR Interview Questions and Answers Paper I
TRAPS: Beware; about 80% of all interviews begin with this “innocent” question. Many candidates, unprepared for the question, skewer themselves by rambling, recapping their life story, delving into ancient work history or personal matters.BEST ANSWER: Start with the present and tell why you are well qualified for the position. Remember that the key to all successful interviewing is to match your qualifications to what the interviewer is looking for. In other words you must sell what the buyer is buying. This is the single most important strategy in job hunting.So, before you answer this or any question it's imperative that you try to uncover your interviewer's greatest need, want, problem or goal.To do so, make you take these two steps:
1. Do all the homework you can before the interview to uncover this person's wants and needs (not the generalized needs of the industry or company)
2. As early as you can in the interview, ask for a more complete description of what the position entails. You might say: “I have a number of accomplishments I'd like to tell you about, but I want to make the best use of our time together and talk directly to your needs. To help me do, that, could you tell me more about the most important priorities of this position? All I know is what I (heard from the recruiter, read in the classified ad, etc.)”Then, ALWAYS follow-up with a second and possibly, third question, to draw out his needs even more. Surprisingly, it's usually this second or third question that unearths what the interviewer is most looking for.You might ask simply, "And in addition to that?..." or, "Is there anything else you see as essential to success in this position?:This process will not feel easy or natural at first, because it is easier simply to answer questions, but only if you uncover the employer's wants and needs will your answers make the most sense. Practice asking these key questions before giving your answers, the process will feel more natural and you will be light years ahead of the other job candidates you're competing with. After uncovering what the employer is looking for, describe why the needs of this job bear striking parallels to tasks you've succeeded at before. Be sure to illustrate with specific examples of your responsibilities and especially your achievements, all of which are geared to present yourself as a perfect match for the needs he has just described.
2. What are your greatest strengths?
TRAPS: This question seems like a softball lob, but be prepared. You don't want to come across as egotistical or arrogant. Neither is this a time to be humble.BEST ANSWER: You know that your key strategy is to first uncover your interviewer's greatest wants and needs before you answer questions. And from Question 1, you know how to do this.Prior to any interview, you should have a list mentally prepared of your greatest strengths. You should also have, a specific example or two, which illustrates each strength, an example chosen from your most recent and most impressive achievements.You should, have this list of your greatest strengths and corresponding examples from your achievements so well committed to memory that you can recite them cold after being shaken awake at 2:30AM.Then, once you uncover your interviewer's greatest wants and needs, you can choose those achievements from your list that best match up.As a general guideline, the 10 most desirable traits that all employers love to see in their employees are:
1. A proven track record as an achiever...especially if your achievements match up with the employer's greatest wants and needs.
2. Intelligence...management "savvy".
3. Honesty...integrity...a decent human being.
4. Good fit with corporate culture...someone to feel comfortable with...a team player who meshes well with interviewer's team.
5. Likeability...positive attitude...sense of humor.
6. Good communication skills.
7. Dedication...willingness to walk the extra mile to achieve excellence.
8. Definiteness of purpose...clear goals.
9. Enthusiasm...high level of motivation.
10. Confident...healthy...a leader.
3. What are your greatest weaknesses?
TRAPS: Beware - this is an eliminator question, designed to shorten the candidate list. Any admission of a weakness or fault will earn you an “A” for honesty, but an “F” for the interview.PASSABLE ANSWER: Disguise a strength as a weakness.Example: “I sometimes push my people too hard. I like to work with a sense of urgency and everyone is not always on the same wavelength.”
Drawback: This strategy is better than admitting a flaw, but it's so widely used, it is transparent to any experienced interviewer.BEST ANSWER: (and another reason it's so important to get a thorough description of your interviewer's needs before you answer questions): Assure the interviewer that you can think of nothing that would stand in the way of your performing in this position with excellence. Then, quickly review you strongest qualifications.Example: “Nobody's perfect, but based on what you've told me about this position, I believe I' d make an outstanding match. I know that when I hire people, I look for two things most of all. Do they have the qualifications to do the job well, and the motivation to do it well? Everything in my background shows I have both the qualifications and a strong desire to achieve excellence in whatever I take on. So I can say in all honesty that I see nothing that would cause you even a small concern about my ability or my strong desire to perform this job with excellence.”
Alternate strategy (if you don't yet know enough about the position to talk about such a perfect fit): Instead of confessing a weakness, describe what you like most and like least, making sure that what you like most matches up with the most important qualification for success in the position, and what you like least is not essential.Example: Let's say you're applying for a teaching position. “If given a choice, I like to spend as much time as possible in front of my prospects selling, as opposed to shuffling paperwork back at the office. Of course, I long ago learned the importance of filing paperwork properly, and I do it conscientiously. But what I really love to do is sell (if your interviewer were a sales manager, this should be music to his ears.)
4. Tell me about something you did – or failed to do – that you now feel a little ashamed of.
TRAPS: There are some questions your interviewer has no business asking, and this is one. But while you may feel like answering, “none of your business,” naturally you can’t. Some interviewers ask this question on the chance you admit to something, but if not, at least they’ll see how you think on your feet.
Some unprepared candidates, flustered by this question, unburden themselves of guilt from their personal life or career, perhaps expressing regrets regarding a parent, spouse, child, etc. All such answers can be disastrous.
BEST ANSWER: As with faults and weaknesses, never confess a regret. But don’t seem as if you’re stonewalling either.Best strategy: Say you harbor no regrets, then add a principle or habit you practice regularly for healthy human relations.Example: Pause for reflection, as if the question never occurred to you. Then say, “You know, I really can’t think of anything.” (Pause again, then add): “I would add that as a general management principle, I’ve found that the best way to avoid regrets is to avoid causing them in the first place. I practice one habit that helps me a great deal in this regard. At the end of each day, I mentally review the day’s events and conversations to take a second look at the people and developments I’m involved with and do a doublecheck of what they’re likely to be feeling. Sometimes I’ll see things that do need more follow-up, whether a pat on the back, or maybe a five minute chat in someone’s office to make sure we’re clear on things…whatever.”
“I also like to make each person feel like a member of an elite team, like the Boston Celtics or LA Lakers in their prime. I’ve found that if you let each team member know you expect excellence in their performance…if you work hard to set an example yourself…and if you let people know you appreciate and respect their feelings, you wind up with a highly motivated group, a team that’s having fun at work because they’re striving for excellence rather than brooding over slights or regrets.”
J2EE Interview Questions and Answers Paper-III
Wiring UI components to back-end data sources such as backing bean properties.
2.What is build file ?
The XML file that contains one or more asant targets. A target is a set of tasks you want to be executed. When staritn asant, you can select which targets you want to have executed. When no target is given, the project's default target is executed.
3.What is business logic ?
The code that implements the functionality of an application. In the Enterprise JavaBeans architecture, this logic is implemented by the methods of an enterprise bean.
4.What is business method ?
A method of an enterprise bean that implements the business logic or rules of an application.
5.What is callback methods ?
Component methods called by the container to notify the component of important events in its life cycle.
6.What is caller ?
Same as caller principal.
7.What is caller principal ?
The principal that identifies the invoker of the enterprise bean method.
8.What is cascade delete ?
A deletion that triggers another deletion. A cascade delete can be specified for an entity bean that has container-managed persistence.
9.What is CDATA ?
A predefined XML tag for character data that means "don't interpret these characters," as opposed to parsed character data (PCDATA), in which the normal rules of XML syntax apply. CDATA sections are typically used to show examples of XML syntax.
10.What is certificate authority ?
A trusted organization that issues public key certificates and provides identification to the bearer.
11.What is client-certificate authentication ?
An authentication mechanism that uses HTTP SSL, in which the server and, optionally, the client authenticate each other with a public key certificate that conforms to a standard that is defined by X.509 Public Key Infrastructure.
12.What is comment ?
In an XML document, text that is ignored unless the parser is specifically told to recognize it.
13.What is commit ?
The point in a transaction when all updates to any resources involved in the transaction are made permanent.
14.What is component contract ?
The contract between a J2EE component and its container. The contract includes life-cycle management of the component, a context interface that the instance uses to obtain various information and servi its container, and a list of services that every container must provide for its components.
15.What is component-managed sign-on ?
A mechanism whereby security information needed for signing on to a resource is provided by an application component.
16.What is connector ?
A standard extension mechanism for containers that provides connectivity to enterprise information systems. A connector is specific to an enterprise information system and consists of a resource adapter and application development tools for enterprise information system connectivity. The resource adapter is plugged in to a container through its support for system-level contracts defined in the Connector architecture.
17.What is container-managed persistence ?
The mechanism whereby data transfer between an entity bean's variables and a resource manager is managed by the entity bean's container.
J2EE Interview Quesitons and Answers Papers-II
A first-tier J2EE client component that executes in its own Java virtual machine. Application clients have access to some J2EE platform APIs.
2.What is "application client container" ?
A container that supports application client components.
3.What is "application client module" ?
A software unit that consists of one or more classes and an application client deployment descriptor.
4.What is "application component provider" ?
A vendor that provides the Java classes that implement components' methods, JSP page definitions, and any required deployment descriptors.
5.What is "application configuration resource file" ?
An XML file used to configure resources for a Java Server Faces application, to define navigation rules for the application, and to register, Validator, listeners, renders, and components with the application.
6.What is "archiving" ?
The process of saving the state of an object and restoring it.
7.What is "asant" ?
A Java-based build tool that can be extended using Java classes. The configuration files are XML-based, calling out a target tree where various tasks get executed.
8.What is "attribute"?
A qualifier on an XML tag that provides additional information.
9.What is authentication ?
The process that verifies the identity of a user, device, or other entity in a computer system, usually as a prerequisite to allowing access to resources in a system. The Java servlet specification requires three types of authentication-basic, form-based, and mutual-and supports digest authentication.
10.What is authorization ?
The process by which access to a method or resource is determined. Authorization depends on the determination of whether the principal associated with a request through authentication is in a given security role. A security role is a logical grouping of users defined by the person who assembles the application. A deployer maps security roles to security identities. Security identities may be principals or groups in the operational environment.
11.What is authorization constraint ?
An authorization rule that determines who is permitted to access a Web resource collection.
12.What is B2B ?
B2B stands for Business-to-business.
13.What is backing bean ?
A JavaBeans component that corresponds to a JSP page that includes JavaServer Faces components. The backing bean defines properties for the components on the page and methods that perform processing for the component. This processing includes event handling, validation, and processing associated with navigation.
14.What is basic authentication ?
An authentication mechanism in which a Web server authenticates an entity via a user name and password obtained using the Web application's built-in authentication mechanism.
15.What is bean-managed persistence ?
The mechanism whereby data transfer between an entity bean's variables and a resource manager is managed by the entity bean.
16.What is bean-managed transaction ?
A transaction whose boundaries are defined by an enterprise bean.
17.What is binding (XML) ?
Generating the code needed to process a well-defined portion of XML data.
J2EE Interview Questions and Answers Paper-I
J2EE is an environment for developing and deploying enterprise applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitier, web-based applications.
2.What is the J2EE module?
A J2EE module consists of one or more J2EE components for the same container type and one component deployment descriptor of that type.
3.What are the components of J2EE application?
A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and communicates with other components. The J2EE specification defines the following J2EE components:
Application clients and applets are client components.
Java Servlet and JavaServer PagesTM (JSPTM) technology components are web components.
Enterprise JavaBeansTM (EJBTM) components (enterprise beans) are business components.
Resource adapter components provided by EIS and tool vendors.
4.What are the four types of J2EE modules?
1. Application client module
2. Web module
3. Enterprise JavaBeans module
4. Resource adapter module
5.What does application client module contain?
The application client module contains:
--class files,
--an application client deployment descriptor.
Application client modules are packaged as JAR files with a .jar extension.
6.What does web module contain?
The web module contains:
--JSP files,
--class files for servlets,
--GIF and HTML files, and
--a Web deployment descriptor.
Web modules are packaged as JAR files with a .war (Web ARchive) extension.
7.What are the differences between Ear, Jar and War files? Under what circumstances should we use each one?
There are no structural differences between the files; they are all archived using zip-jar compression. However, they are intended for different purposes.
--Jar files (files with a .jar extension) are intended to hold generic libraries of Java classes, resources, auxiliary files, etc.
--War files (files with a .war extension) are intended to contain complete Web applications. In this context, a Web application is defined as a single group of files, classes, resources, .jar files that can be packaged and accessed as one servlet context.
--Ear files (files with a .ear extension) are intended to contain complete enterprise applications. In this context, an enterprise application is defined as a collection of .jar files, resources, classes, and multiple Web applications.
Each type of file (.jar, .war, .ear) is processed uniquely by application servers, servlet containers, EJB containers, etc.
8.What is the difference between Session bean and Entity bean ?
The Session bean and Entity bean are two main parts of EJB container. Session Bean
--represents a workflow on behalf of a client
--one-to-one logical mapping to a client.
--created and destroyed by a client
--not permanent objects
--lives its EJB container(generally) does not survive system shut down
--two types: stateless and stateful beansEntity Bean
--represents persistent data and behavior of this data
--can be shared among multiple clients
--persists across multiple invocations
--findable permanent objects
--outlives its EJB container, survives system shutdown
--two types: container managed persistence(CMP) and bean managed persistence(BMP)
9.What is "applet" ?
A J2EE component that typically executes in a Web browser but can execute in a variety of other applications or devices that support the applet programming model.
10.What is "applet container" ?
A container that includes support for the applet programming model.
11.What is "application assembler" ?
A person who combines J2EE components and modules into deployable application units.
ASP.net Interview Questions and Answers Paper-II
1.What is ASP?
ASP stands for Active Server Pages. It is a server side technology which is used to display dynamic content on web pages. For example you could write code that would give your visitors different information, different images or even a totally different page depending on what browser version they are using.
2.How can you disable the browser to view the code?
Writing codes within the Tag
3.What is a "Virtual Directory"?
Virtual directories are aliases for directory paths on the server. It allows moving files on the disk between different folders, drives or even servers without changing the structure of web pages. It avoids typing an extremely long URL each time to access an ASP page.
4.Give the comment Tags for the following?
VBScript : REM & ‘(apostrophe)
JavaScript : // (single line comment)/* */ (Multi-line comments)
5.Which is the default Scripting Language of ASP (server-side)?
VBScript
6.Which is the default Data types in VBScript?
Variant is the default data type in VBScript, which can store a value of any type.
7.What is a variable?
Variable is a memory location through which the actual values are stored/retrieved. Its value can be changed.
8.What is the maximum size of an array?
Up to 60 dimensions.
9.What is Query string collection?
This collection stores any values that are provided the URL. This can be generated by three methods:By clicking on an anchor tag By sending a form to the server by the GET methodThrough user-typed HTTP addressIt allows you to extract data sent to the server using a GET request.
10.What are the attributes of the tags? What are their functions?
The two attributes are ACTION and METHODThe ACTION gives the name of the ASP file that should be opened next by which this file can access the information given in the form The METHOD determines which of the two ways (POST or GET) the browser can send the information to the server
11.What are the methods in Session Object?
The Session Object has only one method, which is Abandon. It destroys all the objects stored in a Session Object and releases the server resources they occupied.
12.What is ServerVariables collection?
The ServerVariables collection holds the entire HTTP headers and also additional items of information about the server.
13.What is the difference between Querystring collection and Form collection?
The main difference is that the Querystring collection gets appended to a URL.
14.What is a Form collection?
The Form collection holds the values of the form elements submitted with the POST method. This is the only way to generate a Form collection.
15.What are the ASP Scripting Objects?
The Dictionary object, the FileSystemObject object, TextStream object.
16.What happens to a HTML page?
The browser makes a HTTP request; the server gives a HTTP response to the browser and the browser converts into a HTML page.
ASP.net Interview Questions and Answers Paper-I
The browser makes a HTTP request; the server does the processing and gives a HTML response to the browser.
2.How can you change the primary scripting language for a page?
Specify
3.What is application Object?
Shares information among users of an application. Gives a notification when an application starts or ends.
4.What is the difference between client-side script and server-side script?
Scripts executed only by the browser without contacting server is called client-side script. It is browser dependent. The scripting code is visible to the user and hence not secure. Scripts executed by the web server and processed by the server is called server-side script.
5.What is the command to display characters to the HTML page?
Response.Write
6.Explain the POST & GET Method or Explain the difference between them?
POST METHOD:
The POST method generates a FORM collection, which is sent as a HTTP request body. All the values typed in the form will be stored in the FORM collection.
GET METHOD:
The GET method sends information by appending it to the URL (with a question mark) and stored as A Querystring collection. The Querystring collection is passed to the server as name/value pair.
The length of the URL should be less than 255 characters.
7.How many global.asa files can an Application have?
Only one global.asa file and it’s placed in the virtual directory’s root.
8.How many global.asa files can an Application have?
Only one global.asa file and it’s placed in the virtual directory’s root.
9.What are Scripting Objects?
Objects that can enhance the application are known as the Scripting Objects.
10.What is the Order of precedence for LOGICAL Operators ?
NOT, AND, OR, XOR, EQV, IMP
11.What is an Err Object?
Name it’s properties and methods.
12.What are LOCAL and GLOBAL variables?
Local variables lifetime ends when the Procedure ends. Global variables lifetime begins at the start of the script and ends at the end of the script and it can be used by any procedure within the script. Declaring a variable by using the keyword PRIVATE makes the variable global within the script, but if declared using PUBLIC, then all scripts can refer the variable.
13.Which is the default Scripting Language on the client side?
JavaScript
14.What is HTML (Hypertext Markup Language)?
It’s a method by which web pages can be built and generally used for formatting and linking text.
15.What is a Web Server?
It’s a Computer that provides Web services on the Internet or on a local Intranet. It is designed to locate, address and send out Simple pages to all other users who access these pages.
16.What is Session Object?
It stores information about a User’s session. Gives a notification when a user session begins or ends.
17.What is Server-Side includes?
It provides extra information by which it makes the site easier to manage. It can include text files using the #include statement, retrieve the size and last modification date of a file, defines how variables and error messages are displayed and inserts the values of HTTP variables in the page sent back to the browser.
Chapter 1
ls (list)
When you first login, your current working directory is your home directory. Your home directory has the same name as your user-name, for example, ee91ab, and it is where your personal files and subdirectories are saved.
To find out what is in your home directory, type
% ls (short for list)
The ls command lists the contents of your current working directory.
There may be no files visible in your home directory, in which case, the UNIX prompt will be returned. Alternatively, there may already be some files inserted by the System Administrator when your account was created.
ls does not, in fact, cause all the files in your home directory to be listed, but only those ones whose name does not begin with a dot (.) Files beginning with a dot (.) are known as hidden files and usually contain important program configuration information. They are hidden because you should not change them unless you are very familiar with UNIX!!!
To list all files in your home directory including those whose names begin with a dot, type
% ls -a
ls is an example of a command which can take options: -a is an example of an option. The options change the behaviour of the command. There are online manual pages that tell you which options a particular command can take, and how each option modifies the behaviour of the command. (See later in this tutorial)
mkdir (make directory)
We will now make a subdirectory in your home directory to hold the files you will be creating and using in the course of this tutorial. To make a subdirectory called unixstuff in your current working directory type
% mkdir unixstuff
To see the directory you have just created, type
% ls
cd (change directory)
The command cd directory means change the current working directory to 'directory'. The current working directory may be thought of as the directory you are in, i.e. your current position in the file-system tree.
To change to the directory you have just made, type
% cd unixstuff
Type ls
to see the contents (which should be empty)
Exercise 1a
Make another directory inside the unixstuff directory called backups
Still in the unixstuff directory, type
% ls -a
As you can see, in the unixstuff directory (and in all other directories), there are two special directories called (.) and (..)
In UNIX, (.) means the current directory, so typing
% cd .
NOTE: there is a space between cd and the dot
means stay where you are (the unixstuff directory).
This may not seem very useful at first, but using (.) as the name of the current directory will save a lot of typing, as we shall see later in the tutorial.
(..) means the parent of the current directory, so typing
% cd ..
will take you one directory up the hierarchy (back to your home directory). Try it now.
Note: typing cd with no argument always returns you to your home directory. This is very useful if you are lost in the file system.
pwd (print working directory)
Pathnames enable you to work out where you are in relation to the whole file-system. For example, to find out the absolute pathname of your home-directory, type cd
to get back to your home-directory and then type
% pwd
The full pathname will look something like this -
/a/fservb/fservb/fservb22/eebeng99/ee91ab
which means that ee91ab (your home directory) is in the directory eebeng99 (the group directory),which is located on the fservb file-server.
Note:
/a/fservb/fservb/fservb22/eebeng99/ee91ab
can be shortened to
/user/eebeng99/ee91ab
Exercise 1b
Use the commands ls, pwd and cd to explore the file system.
(Remember, if you get lost, type cd by itself to return to your home-directory)
Understanding pathnames
First type cd to get back to your home-directory, then type
% ls unixstuff
to list the conents of your unixstuff directory.
Now type
% ls backups
You will get a message like this -
backups: No such file or directory
The reason is, backups is not in your current working directory. To use a command on a file (or directory) not in the current working directory (the directory you are currently in), you must either cd to the correct directory, or specify its full pathname. To list the contents of your backups directory, you must type
% ls unixstuff/backups
~ (your home directory)
Home directories can also be referred to by the tilde ~ character. It can be used to specify paths starting at your home directory. So typing
% ls ~/unixstuff
will list the contents of your unixstuff directory, no matter where you currently are in the file system.
What do you think
% ls ~
would list?
What do you think
% ls ~/..
would list?
Introduction to The UNIX operating system
- Listing files and directories
- Making Directories
- Changing to a different Directory
- The directories . and ..
- Pathnames
- More about home directories and pathnames
- Copying Files
- Moving Files
- Removing Files and directories
- Displaying the contents of a file on the screen
- Searching the contents of a file
- Redirection
- Redirecting the Output
- Redirecting the Input
- Pipes
- Wildcards
- Filename Conventions
- Getting Help
- File system security (access rights)
- Changing access rights
- Processes and Jobs
- Listing suspended and background processes
- Killing a process
- Other Useful UNIX commands
- Compiling UNIX software packages
- Download source code
- Extracting source code
- Configuring and creating the Makefile
- Building the package
- Running the software
- Stripping unnecessary code
- UNIX variables
- Environment variables
- Shell variables
- Using and setting variables