Java Swings
1) Can a class be it’s own event handler? Explain how to implement this.
Answer: Sure. an example could be a class that extends Jbutton and implements ActionListener. In the actionPerformed method, put the code to perform when the button is pressed.
2) Why does JComponent have add() and remove() methods but Component does not?
Answer: because JComponent is a subclass of Container, and can contain other components and jcomponents.
3) How would you create a button with rounded edges?
Answer: there’s 2 ways. The first thing is to know that a JButton’s edges are drawn by a Border. so you can override the Button’s paintComponent(Graphics) method and draw a circle or rounded rectangle (whatever), and turn off the border. Or you can create a custom border that draws a circle or rounded rectangle around any component and set the button’s border to it.
4) If I wanted to use a SolarisUI for just a JTabbedPane, and the Metal UI for everything else, how would I do that?
Answer: in the UIDefaults table, override the entry for tabbed pane and put in the SolarisUI delegate. (I don’t know it offhand, but I think it’s "com.sun.ui.motiflookandfeel.MotifTabbedPaneUI" - anything simiar is a good answer.)
5) What is the difference between the ‘Font’ and ‘FontMetrics’ class?
Answer: The Font Class is used to render ‘glyphs’ - the characters you see on the screen. FontMetrics encapsulates information about a specific font on a specific Graphics object. (width of the characters, ascent, descent)
6) What class is at the top of the AWT event hierarchy?
Answer: java.awt.AWTEvent. if they say java.awt.Event, they haven’t dealt with swing or AWT in a while.
7) Explain how to render an HTML page using only Swing.
Answer: Use a JEditorPane or JTextPane and set it with an HTMLEditorKit, then load the text into the pane.
8) How would you detect a keypress in a JComboBox?
Answer: This is a trick. most people would say ‘add a KeyListener to the JComboBox’ - but the right answer is ‘add a KeyListener to the JComboBox’s editor component.’
9) Why should the implementation of any Swing callback (like a listener) execute quickly?
A: Because callbacks are invoked by the event dispatch thread which will be blocked processing other events for as long as your method takes to execute.
10) In what context should the value of Swing components be updated directly?
A: Swing components should be updated directly only in the context of callback methods invoked from the event dispatch thread. Any other context is not thread safe?
11) Why would you use SwingUtilities.invokeAndWait or SwingUtilities.invokeLater?
A: I want to update a Swing component but I’m not in a callback. If I want the update to happen immediately (perhaps for a progress bar component) then I’d use invokeAndWait. If I don’t care when the update occurs, I’d use invokeLater.
12) If your UI seems to freeze periodically, what might be a likely reason?
A: A callback implementation like ActionListener.actionPerformed or MouseListener.mouseClicked is taking a long time to execute thereby blocking the event dispatch thread from processing other UI events.
13) Which Swing methods are thread-safe?
A: The only thread-safe methods are repaint(), revalidate(), and invalidate()
14) Why won’t the JVM terminate when I close all the application windows?
A: The AWT event dispatcher thread is not a daemon thread. You must explicitly call System.exit to terminate the JVM.
Also see Latest, Recently asked Popular Java Swings, JDBC, Javascript, Java Applets, Java Developers Questions, more Java and Other languages Topics Interview Questions 2008 with solutions here for placement technical, HR Interviews for IT, ITES, BPO, KPO, Internet - Web 2.0 Companies. Keep viewing PreviousPapers.blogspot.com for more latest and previous papers.
Keep watching
Saturday, March 29, 2008
Java Swings Technical Interview Questions
Posted by
mani
at
10:56 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
Java Technical HR Interview Questions with Solutions for 2008
Java Technical Interview Questions asked in reputed IT, ITES, Web 2.0 technology, software developers interview questions with solutions. We couldnt list here all the Individual Java Questions, so You can surely find more specific java questions asked in Multinational Companies Placement papers tech rounds. Good Luck..
JDBC and JSP Interview Questions - 25
Java IT Companies Interview Questions - 24
Java Interview Questions 2008 - 23
Mostly Asked Real Java Technical Interview Questions - 22
Java Networking Algorithmic Interview Questions - 21
Java Important Technical Interview Questions - 20
Java Swings Interview Questions with Complete Answers
Java Graphics User Interface Designer - Interview Questions 18
Java Database JDBC, Bridge, Interview Questions 17
Java AWT Tutorials / Technical Interview Questions Solutions 2008 - 16
Java Applets Technical Interview Test Questions 15
Java on Oracle Technical Interview 2008
Java free explanations, basic and advanced questions 13
Java Lanugage Interview Questions 12
Java free Interview Questions With Solutions 11
Java Servlets Basic Technical Interview Questions 10
Java Tutorials - Free Technical Questions 9
Java Developers Technical Interview - 8
Core Java Questions IT Companies Interview - 7
B.tech Freshers Technical Interview Java Software Questions 6
JSP Tech Interview Questions 5
Java Networking Technical Questions 4
Java Enterprise Advanced Interview Questions - 3
Java Latest Advanced Technical Questions - 2
Java Latest Interview Questions and Answers 1
Posted by
mani
at
10:49 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
JDBC and JSP Interview Questions - 25
JDBC and JSP interview questions
What is the query used to display all tables names in SQL Server (Query analyzer)?
select * from information_schema.tablesHow many types of JDBC Drivers are present and what are they?- There are 4 types of JDBC Drivers
JDBC-ODBC Bridge Driver
Native API Partly Java Driver
Network protocol Driver
JDBC Net pure Java Driver
Can we implement an interface in a JSP?- No
What is the difference between ServletContext and PageContext?- ServletContext: Gives the information about the container. PageContext: Gives the information about the Request
What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?- request.getRequestDispatcher(path): In order to create it we need to give the relative path of the resource, context.getRequestDispatcher(path): In order to create it we need to give the absolute path of the resource.
How to pass information from JSP to included JSP?- Using <%jsp:param> tag.
What is the difference between directive include and jsp include?- <%@ include>: Used to include static resources during translation time. JSP include: Used to include dynamic content or static content during runtime.
What is the difference between RequestDispatcher and sendRedirect?- RequestDispatcher: server-side redirect with request and response objects. sendRedirect : Client-side redirect with new request and response objects.
How does JSP handle runtime exceptions?- Using errorPage attribute of page directive and also we need to specify isErrorPage=true if the current page is intended to URL redirecting of a JSP.
How do you delete a Cookie within a JSP?
Cookie mycook = new Cookie(\"name\",\"value\");
response.addCookie(mycook);
Cookie killmycook = new Cookie(\"mycook\",\"value\");
killmycook.setMaxAge(0);
killmycook.setPath(\"/\");
killmycook.addCookie(killmycook);How do I mix JSP and SSI #include?- If you’re just including raw HTML, use the #include directive as usual inside your .jsp file.
But it’s a little trickier if you want the server to evaluate any JSP code that’s inside the included file. If your data.inc file contains jsp code you will have to use
<%@ vinclude="data.inc" %>
The is used for including non-JSP files.
I made my class Cloneable but I still get Can’t access protected method clone. Why?- Some of the Java books imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but that’s not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesn’t do anything special and just calls super.clone().
Why is XML such an important development?- It removes two constraints which were holding back Web developments: dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for; the complexity of full SGML, whose syntax allows many powerful but hard-to-program options. XML allows the flexible development of user-defined document types. It provides a robust, non-proprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for.
What is the fastest type of JDBC driver?- JDBC driver performance will depend on a number of issues:
the quality of the driver code,
the size of the driver code,
the database server and its load,
network topology,
the number of times your request is translated to a different API.
In general, all things being equal, you can assume that the more your request and response change hands, the slower it will be. This means that Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).
How do I find whether a parameter exists in the request object?
boolean hasFoo = !(request.getParameter(\"foo\") == null
request.getParameter(\"foo\").equals(\"\"));or
boolean hasParameter =
request.getParameterMap().contains(theParameter); //(which works in Servlet 2.3+)How can I send user authentication information while makingURLConnection?- You’ll want to use HttpURLConnection.setRequestProperty and set all the appropriate headers to HTTP authorization.
See more latest Java, javascript, java beans, java struts, swings, animation, graphics, GUI recent important questions mostly asked in common interview questions pre placement and GD topics. See Technical interview java questions commonly asked placement questions for top IT MNCs in India, USA, UK, Norway, China, etc. Solutions Coming Soon..
Posted by
mani
at
10:43 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
Java IT Companies Interview Questions - 24
Java Interview Questions
1.How are Observer and Observable used?
Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.
2.What is synchronization and why is it important?
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 leads to
significant errors.
3.How does Java handle integer overflows and underflows?
It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.
4.Does garbage collection guarantee that a program will not run out of memory?
Garbage collection does not guarantee that a program will not run out of
memory. 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
5.What 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.
6.When a thread is created and started, what is its initial state?
A thread is in the ready state after it has been created and started.
7.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.
8.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.
9.What is the difference between a while statement and a do statement?
A while statement checks at the beginning of a loop to see whether the next
loop iteration should occur. A do statement 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 body of a loop at least once.
10.What is the difference between static and non-static variables?
A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.
11.How are this() and super() used with constructors?
this() is used to invoke a constructor of the same class. super() is used to
invoke a superclass constructor.
12.What are synchronized methods and synchronized statements?
Synchronized methods are methods that are used to control access to 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.
Posted by
mani
at
10:37 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
Java Interview Questions 2008 - 23
Java Latest, Mostly Asked, Popular Interview Questions for 2008
1.Does Java provide any construct to find out the size of an object?
No there is not sizeof operator in Java. So there is not direct way to determine the size of an object directly in Java.
2.Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?
Read the system time just before the method is invoked and immediately after method returns. Take the time difference, which will give you the time taken by a method for execution.
To put it in code...
long start = System.currentTimeMillis ();
method ();
long end = System.currentTimeMillis ();
System.out.println ("Time taken for execution is " + (end - start));
Remember that if the time taken for execution is too small, it might show that it is taking zero milliseconds for execution. Try it on a method which is big enough, in the sense the one which is doing considerable amout of processing.
3.What are wrapper classes?
Java provides specialized classes corresponding to each of the primitive data types. These are called wrapper classes. They are e.g. Integer, Character, Double etc.
4.Why do we need wrapper classes?
It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object.
5.What are checked exceptions?
Checked exception are those which the Java compiler forces you to catch. e.g. IOException are checked Exceptions.
6.What are runtime exceptions?
Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked by the compiler at compile time.
7.What is the difference between error and an exception?
An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime. While exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist. Or a NullPointerException will take place if you try using a null reference. In most of the cases it is possible to recover from an exception (probably by giving user a feedback for entering proper values etc.).
8.How to create custom exceptions?
Your class should extend class Exception, or some more specific type thereof.
9.If I want an object of my class to be thrown as an exception object, what should I do?
The class should extend from Exception class. Or you can extend your class from some more precise exception type also.
10.If my class already extends from some other class what should I do if I want an instance of my class to be thrown as an exception object?
One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.
11.What happens to an unhandled exception?
One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.
12.How does an exception permeate through the code?
An unhandled exception moves up the method stack in search of a matching When an exception is thrown from a code which is wrapped in a try block followed by one or more catch blocks, a search is made for matching catch block. If a matching type is found then that block will be invoked. If a matching type is not found then the exception moves up the method stack and reaches the caller method. Same procedure is repeated if the caller method is included in a try catch block. This process continues until a catch block handling the appropriate type of exception is found. If it does not find such a block then finally the program terminates.
13.What are the different ways to handle exceptions?
There are two ways to handle exceptions,
1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and
2. List the desired exceptions in the throws clause of the method and let the caller of the method hadle those exceptions.
14.What is the basic difference between the 2 approaches to exception handling...1> try catch block and 2> specifying the candidate exceptions in the throws clause?
When should you use which approach?
In the first approach as a programmer of the method, you urself are dealing with the exception. This is fine if you are in a best position to decide should be done in case of an exception. Whereas if it is not the responsibility of the method to deal with it's own exceptions, then do not use this approach. In this case use the second approach. In the second approach we are forcing the caller of the method to catch the exceptions, that the method is likely to throw. This is often the approach library creators use. They list the exception in the throws clause and we must catch them. You will find the same approach throughout the java libraries we use.
15.Is it necessary that each try block must be followed by a catch block?
It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block OR a finally block. And whatever exceptions are likely to be thrown should be declared in the throws clause of the method.
16.If I write return at the end of the try block, will the finally block still execute?
Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will execute and then the control return.
17.If I write System.exit (0); at the end of the try block, will the finally block still execute?
No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.
Posted by
mani
at
10:31 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
Mostly Asked Real Java Technical Interview Questions - 22
1.Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile?
Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying,can not resolve symbol
symbol : class ABCD
location: package io
import java.io.ABCD;
2.Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?
No you will have to import the subpackages explicitly. Importing com.MyTest.* will import classes in the package MyTest only. It will not import any class in any of it's subpackage.
3.What is the difference between declaring a variable and defining a variable?
In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization.
e.g String s; is just a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions.
4.What is the default value of an object reference declared as an instance variable?
null unless we define it explicitly.
5.Can a top level class be private or protected?
No. A top level class can not be private or protected. It can have either "public" or no modifier. If it does not have a modifier it is supposed to have a default access.If a top level class is declared as private the compiler will complain that the "modifier private is not allowed here". This means that a top level class can not be private. Same is the case with protected.
6.What type of parameter passing does Java support?
In Java the arguments are always passed by value .
7.Primitive data types are passed by reference or pass by value?
Primitive data types are passed by value.
8.Objects are passed by value or by reference?
Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object .
9.What is serialization?
Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.
10.How do I serialize an object to a file?
The class whose instances are to be serialized should implement an interface Serializable. Then you pass the instance to the ObjectOutputStream which is connected to a fileoutputstream. This will save the object to a file.
11.Which methods of Serializable interface should I implement?
The serializable interface is an empty interface, it does not contain any methods. So we do not implement any methods.
12.How can I customize the seralization process? i.e. how can one have a control over the serialization process?
Yes it is possible to have control over serialization process. The class should implement Externalizable interface. This interface contains two methods namely readExternal and writeExternal. You should implement these methods and write the logic for customizing the serialization process.
13.What is the common usage of serialization?
Whenever an object is to be sent over the network, objects need to be serialized. Moreover if the state of an object is to be saved, objects need to be serilazed.
14.What is Externalizable interface?
Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism. Thus if your class implements this interface, you can customize the serialization process by implementing these methods.
15.What happens to the object references included in the object?
The serialization mechanism generates an object graph for serialization. Thus it determines whether the included object references are serializable or not. This is a recursive process. Thus when an object is serialized, all the included objects are also serialized alongwith the original obect.
16.What one should take care of while serializing the object?
One should make sure that all the included objects are also serializable. If any of the objects is not serializable then it throws a NotSerializableException.
17.What happens to the static fields of a class during serialization? Are these fields serialized as a part of each serialized object?
Yes the static fields do get serialized. If the static field is an object then it must have implemented Serializable interface. The static fields are serialized as a part of every object. But the commonness of the static fields across all the instances is maintained even after serialization.
Real time Java sun Language Technical Interview Questions asked in reputed IT and other Companies for Developers, Database Administrators, Web Developers, Internet Application Developers Job Tech Interview for 2008. Questions for School project viva, College Admission Technical Interview, etc. Keep Watching PreivousPapers.blogspot.com for lots more technical Questions
Posted by
mani
at
10:21 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
Java Networking Algorithmic Interview Questions - 21
Java Computer Language Networking and Algorithmic Technical Interview Questions What is the protocol used by server and client ?
Can I modify an object in CORBA ?
What is the functionality stubs and skeletons ?
What is the mapping mechanism used by Java to identify IDL language ?
Diff between Application and Applet ?
What is serializable Interface ?
What is the difference between CGI and Servlet ?
What is the use of Interface ?
Why Java is not fully objective oriented ?
Why does not support multiple Inheritance ?
What it the root class for all Java classes ?
What is polymorphism ?
Suppose If we have variable ‘ I ‘ in run method, If I can create one or more thread each thread will occupy a separate copy or same variable will be shared ?
In servlets, we are having a web page that is invoking servlets username and password ? which is checked in the database ? Suppose the second page also If we want to verify the same information whether it will connect to the database or it will be used previous information?
What are virtual functions ?
Write down how will you create a binary Tree ?
What are the traverses in Binary Tree ?
Write a program for recursive Traverse ?
What are session variable in Servlets ?
What is client server computing ?
What is Constructor and Virtual function? Can we call Virtual function in a constructor ?
Why we use OOPS concepts? What is its advantage ?
What is the middleware ? What is the functionality of Webserver ?
Why Java is not 100 % pure OOPS ? ( EcomServer )
When we will use an Interface and Abstract class ?
What is an RMI?
How will you pass parameters in RMI ? Why u serialize?
What is the exact difference in between Unicast and Multicast object ? Where we will use ?
What is the main functionality of the Remote Reference Layer ?
How do you download stubs from a Remote place ?
What is the difference in between C++ and Java ? can u explain in detail ?
I want to store more than 10 objects in a remote server ? Which methodology will follow ?
What is the main functionality of the Prepared Statement ?
What is meant by static query and dynamic query ?
What are the Normalization Rules ? Define the Normalization ?
What is meant by Servlet? What are the parameters of the service method ?
What is meant by Session ? Tell me something about HTTPSession Class ?
How do you invoke a Servlet? What is the difference in between doPost and doGet methods ?
What is the difference in between the HTTPServlet and Generic Servlet ? Explain their methods ? Tell me their parameter names also ?
Have you used threads in Servlet ?
Write a program on RMI and JDBC using StoredProcedure ?
How do you sing an Applet ?
In a Container there are 5 components. I want to display the all the components names, how will you do that one ?
Why there are some null interface in java ? What does it mean ? Give me some null interfaces in JAVA ?
Tell me the latest versions in JAVA related areas ?
What is meant by class loader ? How many types are there? When will we use them ?
How do you load an Image in a Servlet ?
What is meant by flickering ?
What is meant by distributed Application ? Why we are using that in our applications ?
What is the functionality of the stub ?
Have you used any version control ?
What is the latest version of JDBC ? What are the new features are added in that ?
Explain 2 tier and 3 -tier Architecture ?
What is the role of the webserver ?
How have you done validation of the fields in your project ?
What is the main difficulties that you are faced in your project ?
What is meant by cookies ? Explain ?
Free download online Sun Java Language Technical Interview Questions and Tutorials. Free reference place for java placement questions for 2008
Posted by
mani
at
10:10 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
Java Important Technical Interview Questions - 20
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 the purpose of assert keyword used in JDK1.4.x? - In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing.
How will you get the platform dependent values like line separator, path separator, etc., ? - Using Sytem.getProperty(…) (line.separator, path.separator, …)
What is skeleton and stub? what is the purpose of those? - Stub is a client side representation of the server, which takes care of communicating with the remote server. Skeleton is the server side representation. But that is no more in use… it is deprecated long before in JDK.
What is the final keyword denotes? - final keyword denotes that it is the final implementation for that method or variable or class. You can’t override that method/variable/class any more.
What is the significance of ListIterator? - You can iterate back and forth.
What is the major difference between LinkedList and ArrayList? - LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.
What is nested class? - If all the methods of a inner class is static then it is a nested class.
What is inner class? - If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.
What is composition? - Holding the reference of the other class within some other class is known as composition.
What is aggregation? - It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation.
What are the methods in Object? - clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString
Can you instantiate the Math class? - You can’t instantiate the math class. All the methods in this class are static. And the constructor is not public.
What is singleton? - It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton { private static final Singleton s = new Singleton(); private Singleton() { } public static Singleton getInstance() { return s; } // all non static methods … }
What is DriverManager? - The basic service to manage set of JDBC drivers.
What is Class.forName() does and how it is useful? - It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( “class-instance”.newInstance() ).
Posted by
mani
at
9:06 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
Java Graphics User Interface Designer - Interview Questions 18
Java GUI designer interview questions
What advantage do Java’s layout managers provide over traditional windowing systems? - Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java’s layout managers aren’t tied to absolute sizing and positioning, they are able to accomodate platform-specific differences among windowing systems.
What is the difference between the paint() and repaint() methods? - The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.
How can the Checkbox class be used to create a radio button? - By associating Checkbox objects with a CheckboxGroup
What is the difference between a Choice and a List? - A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.
What interface is extended by AWT event listeners? - All AWT event listeners extend the java.util.EventListener interface.
What is a layout manager? - A layout manager is an object that is used to organize components in a container
Which Component subclass is used for drawing and painting? - Canvas
What are the problems faced by Java programmers who dont use layout managers? - Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system
What is the difference between a Scrollbar and a ScrollPane? (Swing) - A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.
See Latest Java Language Graphic User Interface Interview Questions For Animation Companies - Mauj, Maya, Land Marvel, Compact Disc India, Illion, Illuminated, Imagi, Houston, Pixar 3d Studio, Animantz, PNC Pritish Nandy Communications, Animation 5, i2eye animation studio, Dreamworks Animation Interview Questions, Thomson, Arena Multimedia Multiple Choice Questions with answers key, Aptech Academy Java Placement Interview Questions, Prana 3d studios detailed graphics GUI Questions with detailed solutions. Keep Watching Previouspapers.blogspot.com for more free stuff..
Java Database JDBC, Bridge, Interview Questions 17
Java database interview questions
How do you call a Stored Procedure from JDBC? - The first step is to create a CallableStatement object. As with Statement and PreparedStatement objects, this is done with an open Connection object. A CallableStatement object contains a call to a stored procedure.
CallableStatement cs =
con.prepareCall("{call SHOW_SUPPLIERS}");
ResultSet rs = cs.executeQuery();Is the JDBC-ODBC Bridge multi-threaded? - No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won’t get the advantages of multi-threading.
Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection? - No. You can open only one Statement object per connection when you are using the JDBC-ODBC Bridge.
What is cold backup, hot backup, warm backup recovery? - Cold backup (All these files must be backed up at the same time, before the databaseis restarted). Hot backup (official name is ‘online backup’) is a backup taken of each tablespace while the database is running and is being accessed by the users.
When we will Denormalize data? - Data denormalization is reverse procedure, carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to replicate data for certain data.
What is the advantage of using PreparedStatement? - If we are using PreparedStatement the execution time will be less. The PreparedStatement object contains not just an SQL statement, but the SQL statement that has been precompiled. This means that when the PreparedStatement is executed,the RDBMS can just run the PreparedStatement’s Sql statement without having to compile it first.
What is a “dirty read”? - Quite often in database processing, we come across the situation wherein one transaction can change a value, and a second transaction can read this value before the original change has been committed or rolled back. This is known as a dirty read scenario because there is always the possibility that the first transaction may rollback the change, resulting in the second transaction having read an invalid value. While you can easily command a database to disallow dirty reads, this usually degrades the performance of your application due to the increased locking overhead. Disallowing dirty reads also leads to decreased system concurrency.
What is Metadata and why should I use it? - Metadata (’data about data’) is information about one of two things: Database information (java.sql.DatabaseMetaData), or Information about a specific ResultSet (java.sql.ResultSetMetaData). Use DatabaseMetaData to find information about your database, such as its capabilities and structure. Use ResultSetMetaData to find information about the results of an SQL query, such as size and types of columns
Different types of Transaction Isolation Levels? - The isolation level describes the degree to which the data being updated is visible to other transactions. This is important when two transactions are trying to read the same row of a table. Imagine two transactions: A and B. Here three types of inconsistencies can occur:
Dirty-read: A has changed a row, but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong if A rolls back his changes and updates his own changes to the database.
Non-repeatable read: B performs a read, but A modifies or deletes that data later. If B reads the same row again, he will get different data.
Phantoms: A does a query on a set of rows to perform an operation. B modifies the table such that a query of A would have given a different result. The table may be inconsistent.
TRANSACTION_READ_UNCOMMITTED : DIRTY READS, NON-REPEATABLE READ AND PHANTOMS CAN OCCUR.
TRANSACTION_READ_COMMITTED : DIRTY READS ARE PREVENTED, NON-REPEATABLE READ AND PHANTOMS CAN OCCUR.
TRANSACTION_REPEATABLE_READ : DIRTY READS , NON-REPEATABLE READ ARE PREVENTED AND PHANTOMS CAN OCCUR.
TRANSACTION_SERIALIZABLE : DIRTY READS, NON-REPEATABLE READ AND PHANTOMS ARE PREVENTED.What is 2 phase commit? - A 2-phase commit is an algorithm used to ensure the integrity of a committing transaction. In Phase 1, the transaction coordinator contacts potential participants in the transaction. The participants all agree to make the results of the transaction permanent but do not do so immediately. The participants log information to disk to ensure they can complete In phase 2 f all the participants agree to commit, the coordinator logs that agreement and the outcome is decided. The recording of this agreement in the log ends in Phase 2, the coordinator informs each participant of the decision, and they permanently update their resources.
How do you handle your own transaction ? - Connection Object has a method called setAutocommit(Boolean istrue)
- Default is true. Set the Parameter to false , and begin your transactionWhat is the normal procedure followed by a java client to access the db.? - The database connection is created in 3 steps:
Find a proper database URL
Load the database driver
Ask the Java DriverManager class to open a connection to your database
In java code, the steps are realized in code as follows:
Create a properly formatted JDBR URL for your database. (See FAQ on JDBC URL for more information). A JDBC URL has the form
jdbc:someSubProtocol://myDatabaseServer/theDatabaseNameClass.forName(”my.database.driver”);
Connection conn = DriverManager.getConnection(”a.JDBC.URL”, “databaseLogin”,”databasePassword”);
What is a data source? - A DataSource class brings another level of abstraction than directly using a connection object. Data source can be referenced by JNDI. Data Source may point to RDBMS, file System , any DBMS etc.
What are collection pools? What are the advantages? - A connection pool is a cache of database connections that is maintained in memory, so that the connections may be reused
How do you get Column names only for a table (SQL Server)? Write the Query. -
select name from syscolumns
where id=(select id from sysobjects where name='user_hdr')
order by colid --user_hdr is the table name
Posted by
mani
at
7:44 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008
Java AWT Tutorials / Technical Interview Question Solutions 2008
Java AWT interview questions
What is meant by Controls and what are different types of controls? - Controls are componenets that allow a user to interact with your application. The AWT supports the following types of controls:
Labels
Push buttons
Check boxes
Choice lists
Lists
Scroll bars
Text components
Which method of the component class is used to set the position and the size of a component? - setBounds(). The following code snippet explains this:
txtName.setBounds(x,y,width,height);places upper left corner of the text field txtName at point (x,y) with the width and height of the text field set as width and height.
Which TextComponent method is used to set a TextComponent to the read-only state? - setEditable()
How can the Checkbox class be used to create a radio button? - By associating Checkbox objects with a CheckboxGroup.
What methods are used to get and set the text label displayed by a Button object? - getLabel( ) and setLabel( )
What is the difference between a Choice and a List? - Choice: A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. List: A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.
What is the difference between a Scollbar and a Scrollpane? - A Scrollbar is a Component, but not a Container. A Scrollpane is a Container and handles its own events and performs its own scrolling.
Which are true about the Container class?
The validate( ) method is used to cause a Container to be laid out and redisplayed.
The add( ) method is used to add a Component to a Container.
The getBorder( ) method returns information about a Container’s insets.
getComponent( ) method is used to access a Component that is contained in a Container.
Answers: a, b and d
Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame’s font is set to 12-point TimesRoman, the Panel’s font is set to 10-point TimesRoman, and the Button’s font is not set, what font will be used to display the Button’s label?
12-point TimesRoman
11-point TimesRoman
10-point TimesRoman
9-point TimesRoman
Answer: c.
What are the subclasses of the Container class? - The Container class has three major subclasses. They are:
Window
Panel
ScrollPane
Which object is needed to group Checkboxes to make them exclusive? - CheckboxGroup.
What are the types of Checkboxes and what is the difference between them? - Java supports two types of Checkboxes:
Exclusive
Non-exclusive.
In case of exclusive Checkboxes, only one among a group of items can be selected at a time. I f an item from the group is selected, the checkbox currently checked is deselected and the new selection is highlighted. The exclusive Checkboxes are also called as Radio buttons. The non-exclusive checkboxes are not grouped together and each one can be selected independent of the other.
What is a Layout Manager and what are the different Layout Managers available in java.awt and what is the default Layout manager for the panel and the panel subclasses? - A layout Manager is an object that is used to organize components in a container. The different layouts available in java.awt are:
FlowLayout: The elements of a FlowLayout are organized in a top to bottom, left to right fashion.
BorderLayout: The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container.
CardLayout: The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.
GridLayout: The elements of a GridLayout are of equal size and are laid out using the square of a grid.
GridBagLayout:
The elements of a GridBagLayout are organized according to a grid.However, the elements are of different sizes and may occupy more
than one row or column of the grid. In addition, the rows and columns may have different sizes.
The default Layout Manager of Panel and Panel sub classes is FlowLayout.
Can I add the same component to more than one container? - No. Adding a component to a container automatically removes it from any previous parent (container).
How can we create a borderless window? - Create an instance of the Window class, give it a size, and show it on the screen.
Frame aFrame = new Frame();
Window aWindow = new Window(aFrame);
aWindow.setLayout(new FlowLayout());
aWindow.add(new Button(\"Press Me\"));
aWindow.getBounds(50,50,200,200);
aWindow.show();Can I create a non-resizable windows? If so, how? - Yes. By using setResizable() method in class Frame.
Which containers use a BorderLayout as their default layout? Which containers use a FlowLayout as their default layout? - The Window, Frame and Dialog classes use a BorderLayout as their default layout. The Panel and the Applet classes use the FlowLayout as their default layout.
How do you change the current layout manager for a container?
Use the setLayout method
Once created you cannot change the current layout manager of a component
Use the setLayoutManager method
Use the updateLayout method
Answer: a.
What is the difference between a MenuItem and a CheckboxMenuItem?- The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked
Free download online recent and current year solved placement question papers 2008 of leading companies in India and Abroad. See More Latest and previous expert, common, basic, important, advanced questions asked in college admission, entrance tests and technical interviews for 2007, 2008 january, february, march, april, may, june, july, august, september, october, november, december for leading IT Companies in India, USA, UK, Norway, China. Reputed MNCs testing job interview questions for Wipro, Infosys, TCS, Satyam Computers, HCL, IBM, Cisco, Microsoft, Keane, Flextronics, Accenture, Cognizant, T Systems, SAP, Oracle, Texas Instruments, Quark, Patni Computer Systems, Mastek, BT, Dell, BPO, ITES companies, Software Companies. Freshers and on campus interview held in delhi, mumbai, bangalore, chennai, madurai, noida, gurgaon, chandigarh, mohali, pune, hyderabad, kolkata, thane, ahmedabad, etc. Recent, latest reasoning, multiple choice questions, verbal, non verbal, mathematics questions with solutions / solved / answer keys, booklet. GD topics for leading campus placement interview, placement drive, HR Interview Questions and answers, how to behave, Tips, preparation, most recently asked / important software testing interview, free tutorials for java, oracle, c, c++, networking, web designing, windows 2000, vista, etc. questions. Keep Watching Previouspapers.blogspot.com for more stuff!
Posted by
mani
at
7:43 AM
0
comments
Labels: Java Language Recent Technical Interview Questions, Java Latest Interview Questions 2008