-
When does the compiler supply a default constructor for a class
The compiler supplies a default constructor for a class if no other constructors areprovided.
-
What are the Object and Class classes used for
The Object class is the highest-level class in the Java class hierarchy. The Class class isused to representthe classes and interfaces that are loaded by a Java program.
-
Compare SWING components to standard AWT.
Swing is an extension of, and not a replacement for the AWT. There is some overlap between AWT and Swing (for example a Swing JButton component might be viewed as an improved functional replacement for an AWT Button component.) One of the advantages of Swing components is that because the components are not rendered on the screen by the operating system, the look and feel of a component does not change...
-
What is Java Beans ?
According to JavaSoft, "A Java Bean is a reusable software component that can be manipulated visually in a builder tool."
-
In Java, You can create a String object as: String str = "abc"; & String str = new String("abc");Why cant a button object be created as : Button bt = "abc" Why is it compulsory to create a button object as: Button bt = new Button("abc"); Why is this not compulsory in String's case?
The main reason you cannot create a button by Button bt1= "abc"; is because "abc" is a literal string (something slightly different than a String object, bytheway)and bt1 is a Button object. That simple. The only object in Java that can be assigned a literal String is java.lang.String. Important to note that you are NOT calling a java.lang.String constuctor when you type String s = "abc";For example String...
-
How can you achieve Multiple Inheritance in Java?
Java's interface mechanism can be used to implement multiple inheritance, with one important difference from c++ way of doing MI: the inherited interfaces must be abstract. This obviates the need to choose between different implementations, as with interfaces there are no implementations.
-
What is the difference between an Applet and an Application?
1. Applets can be embedded in HTML pages and downloaded over the Internet whereas Applications have no special support in HTML for embedding or downloading.2. Applets can only be executed inside a java compatible container, such as a browser or appletviewer whereas Applications are executed at command line by java.exe or jview.exe.3. Applets execute under strict security limitations that disallow certain...
-
What does the keyword "synchronize" mean in java. When do you use it? What are the disadvantages of synchronization?
Synchronize is used when u want to make ur methods thread safe. The disadvantage of synchronise is it will end up in slowing down the program. Also if not handled properly it will end up in dead lock.1. Only use (and minimize it's use)synchronization when writing multithreaded code as there is a speed (up to five to six time slower, depending on the execution time of the synchronized/nonsynchronized...
-
Access specifiers: "public", "protected", "private", nothing?
Public – any other class from any package can instantiate and execute the classes and methodsProtected – only subclasses and classes inside of the package can access the classes and methodsPrivate – the original class is the only class allowed to execute the methods
-
What does the "final" keyword mean in front of a variable? A method? A class?
FINAL for a variable : value is constantFINAL for a method : cannot be overriddenFINAL for a class : cannot be derived
-
-
Why do you create interfaces, and when MUST you use one?
You would create interfaces when you have two or more functionalities talking to each other. Doing it this way help you in creating a protocol between the parties involved.
-
What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.
-
What is the serialization?
The serialization is a kind of mechanism that makes a class or a bean persistence by having its properties or fields and state information saved and restored to and from storage.
-
-
-
-
Difference between Statement and PreparedStatement?
Answer posted by pravash on 2005-06-08 02:16:34: The PreparedStatement is a slightly more powerful version of a Statement, and should always be at least as quick and easy to handle as a Statement. The PreparedStatement may be parametrizednull Most relational databases handles a JDBC / SQL query in four steps: 1.Parse the incoming SQL query 2. Compile the SQL query 3....
-
-
Java Interview Questions
Ans