-
What is the difference between the prefix and postfix forms of the ++ operator
The prefix form performs the increment operation and returns the value of the incrementoperation. Thepostfix form returns the current value all of the expression and then performs theincrement operation onthat value.
-
What is a Java package and how is it used
A Java package is a naming context for classes and interfaces. A package is used tocreate a separate namespace for groups of classes and interfaces. Packages are also used to organize relatedclasses and interfacesinto a single API unit and to control accessibility to these classes and interfaces.
-
How does a try statement determine which catch clause should be used tohandle an exception
When an exception is thrown within the body of a try statement, the catch clauses of thetry statement areexamined in the order in which they appear. The first catch clause that is capable ofhandling the exceptionis executed. The remaining catch clauses are ignored.
-
What are synchronized methods and synchronized statements
Synchronized methods are methods that are used to control access to an object. A threadonly executes asynchronized method after it has acquired the lock for the method's object or class.Synchronizedstatements are similar to synchronized methods. A synchronized statement can only beexecuted after athread has acquired the lock for the object or class referenced in the synchronizedstatement.
-
What are the two basic ways in which classes that can be run as threads may bedefined
A thread class may be declared as a subclass of Thread, or it may implement theRunnable interface.
-
What are the problems faced by Java programmers who don't use layoutmanagers
Without layout managers, Java programmers are faced with determining how their GUIwill be displayedacross multiple windowing systems and finding a common sizing and positioning thatwill work within theconstraints imposed by each windowing system.
-
What is the difference between an if statement and a switch statement
The if statement is used to select among two alternatives. It uses a boolean expression todecide whichalternative should be executed. The switch statement is used to select among multiplealternatives. It usesan int expression to determine which alternative should be executed.
-
What are the similarities and differences between Java and C/C++?
FeaturesJavaC/C++PointerNoYesOperator OverloadNoYesPreprocessorsNoYesStructures, UnionsNoYesEnumsNoYesFunctionsNo (only methods within classes)YesGoto statementNoYesAutomatic CoercionsNo (types should be converted explicitly)YesGlobal VariablesNo (variable is a part of a class)YesTemplatesNoYesPrivate, Protected, PublicYesYesInheritanceNoYesDefault parametersNoYesGarbage CollectionYesNoMulti-thread...
-
What is the purpose of the toolkit in the Abstract Window Toolkit (AWT)? How does AWT work ?
The AWT toolkit is an interface between the abstract window layer and a specific windowing implementation.
-
What is layout manager ? How does it work ?
A layout manager is an object that positions and resizes the components in a Container according to some algorithm; for example, the FlowLayout layout manager lays out components from left to right until it runs out of room and then continues laying out components below that row.
-
Q: What you know about Corba implementation in Java ?
Java 1.2 promises full CORBA IDL support.
-
Q: What do you know about networking support in Java ?
Java supports "low-level" and "high-level" classes. "Low-level" classes provide support for socket programming: Socket, DatagramSocket, and ServerSocket classes. "High-level" classes provide "Web programming": URL, URLEncoder, and URLConnection classes. Networking programming classes ease the programming of network applications, but do not substitute your knowledge of networking. Java networking like...
-
Q: How to make application thread-safe ?
You should use the word synchronized to mark the critical section of code. You may also use other methods of thread synchronization (see wait(), notify(), notifyAll() etc.
-
What is the difference between StringBuffer and String class?
A string buffer implements a mutable sequence of characters. A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls. The String class represents character strings. All string literals in Java programs, such as "abc" are constant and implemented...
-
Describe, in general, how java's garbage collector works?
The Java runtime environment deletes objects when it determines that they are no longer being used. This process is known as garbage collection. The Java runtime environment supports a garbage collector that periodically frees the memory used by objects that are no longer needed. The Java garbage collector is a mark-sweep garbage collector that scans Java's dynamic memory areas for objects, marking...
-
What's the difference between == and equals method?
The equals method can be considered to perform a deep comparison of the value of an object, whereas the == operator performs a shallow comparison. The quals() method compares the characters inside a string object. == operator compares two object references to check whether they refer to the same instances or not.
-
How can you force all derived classes to implement a method present in the base class?
Creating and implementing an interface would be the best way for this situation. Just create an interface with empty methods which forces a programmer to implement all the methods present under it. Another way of achieving this task is to declare a class as abstract with all its methods abstract.
-
Java says "write once, run anywhere". What are some ways this isn't quite true?
Any time you use system calls specific to one operating system and do not create alternative calls for another operating system, your program will not function correctly. Solaris systems and Intel systems order the bits of an integer differently. (You may have heard of little endian vs. big endian) If your code uses bit shifting, or other binary operators, they will not work on systems that have opposide...
-
Describe java's security model.
Java's security model is one of the most interesting and unique aspects of the language. For the most part it's broken into two pieces: the user adjustable security manager that checks various API operations like file access, and the byte code verifier that asserts the validity of compiled byte code. public abstract class SecurityManager java.lang.SecurityManager is an abstract class which different...
-
What is the difference between a Vector and an Array. Discuss the advantages and disadvantages of both?
The vector container class generalizes the concept of an ordinary C array. Like an array, a vector is an indexed data structure, with index values that range from 0 to one less than the number of elements contained in the structure. Also like an array, values are most commonly assigned to and extracted from the vector using the subscript operator. However, the vector differs from an array in the following...
Java Interview Questions
Ans