1. 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
________________________________________
2. What kind of thread is the Garbage collector thread?
- It is a daemon thread.
________________________________________
3. 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.
________________________________________
4. How will you invoke any external process in Java?
- Runtime.getRuntime().exec(….)
________________________________________
5. 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.
________________________________________
6. 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, …)
________________________________________
7. What is the basic difference between string and stringbuffer object?
- String is an immutable object. StringBuffer is a mutable object.
________________________________________
8. 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.
________________________________________
9. 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.
________________________________________
10. What is the base class for Error and Exception?
- Throwable
________________________________________
11. What is the byte range?
-128 to 127
________________________________________
12. What is the implementation of destroy method in java.. is it native or java code?
- This method is not implemented.
________________________________________
13. What is a package?
- To group set of classes into a single unit is known as packaging. Packages provides wide namespace ability.
________________________________________
14. 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.
________________________________________
15. What is a DatabaseMetaData?
- Comprehensive information about the database as a whole.
________________________________________
16. What is Locale?
- A Locale object represents a specific geographical, political, or cultural region
________________________________________
17. How will you load a specific locale?
- Using ResourceBundle.getBundle(…);
________________________________________
18. 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.
________________________________________
19. Is JVM a compiler or an interpreter?
- Interpreter
________________________________________
20. When you think about optimization, what is the best way to findout the time/memory consuming process?
- Using profiler
________________________________________
21. 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.
________________________________________
22. How will you get the platform dependent values like line separator, path separator, etc., ?
- Using Sytem.getProperty(…) (line.separator, path.separator, …)
________________________________________
23. 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.
________________________________________
24. 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.
________________________________________
25. What is the significance of ListIterator?
- You can iterate back and forth.
________________________________________
26. What is the major difference between LinkedList and ArrayList?
- LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.
________________________________________
27. What is nested class?
- If all the methods of a inner class is static then it is a nested class.
________________________________________
28. 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.
________________________________________
29. What is composition?
- Holding the reference of the other class within some other class is known as composition.
________________________________________
30. 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.
________________________________________
31. What are the methods in Object?
- clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString
________________________________________
32. 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.
________________________________________
33. 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 … }
________________________________________
34. What is DriverManager?
- The basic service to manage set of JDBC drivers.
________________________________________
35. 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() ).
Friday, January 22, 2010
Saturday, November 28, 2009
source code
import java.awt.BorderLayout;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
public class SwingScrollBarExample extends JPanel {
JLabel label;
public SwingScrollBarExample() {
super(true);
label = new JLabel();
setLayout(new BorderLayout());
JScrollBar hbar = new JScrollBar(JScrollBar.HORIZONTAL, 30, 20, 0, 300);
JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
hbar.setUnitIncrement(2);
hbar.setBlockIncrement(1);
hbar.addAdjustmentListener(new MyAdjustmentListener());
vbar.addAdjustmentListener(new MyAdjustmentListener());
add(hbar, BorderLayout.SOUTH);
add(vbar, BorderLayout.EAST);
add(label, BorderLayout.CENTER);
}
class MyAdjustmentListener implements AdjustmentListener {
public void adjustmentValueChanged(AdjustmentEvent e) {
label.setText(" New Value is " + e.getValue() + " ");
repaint();
}
}
public static void main(String s[]) {
JFrame frame = new JFrame("Scroll Bar Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new SwingScrollBarExample());
frame.setSize(200, 200);
frame.setVisible(true);
}
}
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
public class SwingScrollBarExample extends JPanel {
JLabel label;
public SwingScrollBarExample() {
super(true);
label = new JLabel();
setLayout(new BorderLayout());
JScrollBar hbar = new JScrollBar(JScrollBar.HORIZONTAL, 30, 20, 0, 300);
JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
hbar.setUnitIncrement(2);
hbar.setBlockIncrement(1);
hbar.addAdjustmentListener(new MyAdjustmentListener());
vbar.addAdjustmentListener(new MyAdjustmentListener());
add(hbar, BorderLayout.SOUTH);
add(vbar, BorderLayout.EAST);
add(label, BorderLayout.CENTER);
}
class MyAdjustmentListener implements AdjustmentListener {
public void adjustmentValueChanged(AdjustmentEvent e) {
label.setText(" New Value is " + e.getValue() + " ");
repaint();
}
}
public static void main(String s[]) {
JFrame frame = new JFrame("Scroll Bar Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new SwingScrollBarExample());
frame.setSize(200, 200);
frame.setVisible(true);
}
}
Sun is making the shift because Java has far greater brand awareness than the company's name, said CEO Jonathan Schwartz in his blog on Thursday. The current symbol, which stands for Stanford University Network Workstation, reflects the company's origins but not its present, he said.
"The number of people who know Java swamps the number of people who know Sun," Schwartz wrote. "JAVA is a technology whose value is near infinite to the Internet, and a brand that's inseparably a part of Sun (and our profitability)."
Sun estimates that 1 billion consumers recognize the steaming coffee cup symbol of Java, it said in a press release.
Java is a programming language and platform for running applications written in Java and some other languages. The software is installed on over 2 billion mobile phones as well as desktop PCs and servers.
In addition to having a better recognized brand, Java spans Sun's multiple businesses. The company is often referred to as a "server vendor," but Schwartz, who used to head up Sun's software business, argued that Java touches all of what Sun does.
"Java means limitless opportunity--for our software, systems, storage, service and microelectronics businesses. And for the open-source communities we shepherd," he wrote.
Sun has sought to capitalize on the Java brand for many years through consumer-oriented marketing efforts. But despite inventing Java in 1995, financial analysts have often criticized the company in the past few years because other companies have commercialized Java technology more successfully.
In an effort to monetize Java better, Sun has sought to reach out to software developers in corporations and start-ups. It has open-sourced Java under the General Public License and said that it will open-source its entire software product line. It has already open-sourced its Solaris operating system, which IBM said it will begin to support on its server hardware.
One Sun partner from Germany left an unhappy comment on Schwartz's blog, saying that many people don't have a good association with Java. "In the minds of many people, Java == slow," he wrote.
The shift may not go down well with Java licensees either.
The platform and language are widely used, incorporated into products from hundreds of vendors. But Sun controls the branding of Java and restricts licensees from using the Java name in their products.
Partners, including rival IBM, have complained that that Java Community Process and events like JavaOne revolve around Sun rather than the Java "community" as a whole
"The number of people who know Java swamps the number of people who know Sun," Schwartz wrote. "JAVA is a technology whose value is near infinite to the Internet, and a brand that's inseparably a part of Sun (and our profitability)."
Sun estimates that 1 billion consumers recognize the steaming coffee cup symbol of Java, it said in a press release.
Java is a programming language and platform for running applications written in Java and some other languages. The software is installed on over 2 billion mobile phones as well as desktop PCs and servers.
In addition to having a better recognized brand, Java spans Sun's multiple businesses. The company is often referred to as a "server vendor," but Schwartz, who used to head up Sun's software business, argued that Java touches all of what Sun does.
"Java means limitless opportunity--for our software, systems, storage, service and microelectronics businesses. And for the open-source communities we shepherd," he wrote.
Sun has sought to capitalize on the Java brand for many years through consumer-oriented marketing efforts. But despite inventing Java in 1995, financial analysts have often criticized the company in the past few years because other companies have commercialized Java technology more successfully.
In an effort to monetize Java better, Sun has sought to reach out to software developers in corporations and start-ups. It has open-sourced Java under the General Public License and said that it will open-source its entire software product line. It has already open-sourced its Solaris operating system, which IBM said it will begin to support on its server hardware.
One Sun partner from Germany left an unhappy comment on Schwartz's blog, saying that many people don't have a good association with Java. "In the minds of many people, Java == slow," he wrote.
The shift may not go down well with Java licensees either.
The platform and language are widely used, incorporated into products from hundreds of vendors. But Sun controls the branding of Java and restricts licensees from using the Java name in their products.
Partners, including rival IBM, have complained that that Java Community Process and events like JavaOne revolve around Sun rather than the Java "community" as a whole
The JavaCard team have been cranking away. Development on the 3.0 version is finally (almost) finished, and it's pretty amazing. Java Card 3 is available in two Editions.
Classic Edition
This is the same as Java Card 2 with some enhancements/bug fixes. It is almost 10 years young and is the most popular platform for the SIM and ID markets.
Connected Edition
This is the next generation Java Card technology:
JDK6 Compatible VM: Except for floats, it support class file version 50.
Full Java Language support: Java Card 2 has restrictions on the language itself. But JC3 has no limits. You can use all language features like annotations, enhanced for-loops etc... (except floating point)
Rich API: This is mixture of CLDC, GCF, Servlet, JavaCard2 API, Sockets, Threads, Transactions ...
Three application models and two library models, which makes it possible to have virtually any kind of secure application on JC3:
Servlets, extended-Applets, Classic-Applets
Extension-Library and Classic-Library
Servlet Container with Servlet 2.5 support.
HTTP and HTTPS interface: No need for special client programming. Use any web client to reach JC3.
Still tiny(!!):24K RAM, 128K EEPROM, 512K ROM with a 32 bit processor
It is not just "Card" any more: With the newly added USB interface this technology can go beyond Smart Cards into devices like secure USB tokens, Secure Personal Databases, Embedded Servers, WebDAV compliant thumb drives and more.
Last but not least, there is a Netbeans Plugin for easy development. Nightly builds of NetBeans point to the latest JavaCard plugin
HIS EDUCATION AND CAREER
James Arthur Gosling the Father of Java In 1977, James Gosling received a B.Sc in Computer Science from the University of Calgary. In 1983, he earned a Ph.D in Computer Science from Carnegie Mellon University, and his doctoral thesis was titled "The Algebraic Manipulation of Constraints". While working towards his doctorate, he wrote a version of emacs (gosmacs), and before joining Sun Microsystems he built a multi-processor version of Unix[1] while at Carnegie Mellon University, as well as several compilers and mail systems.
Since 1984, Gosling has been with Sun Microsystems, and is generally known best as the father of the Java programming language.
Born:May 19,1955 (age:55)
Residence:US
Nationality:Canada
Occupation:Computer Scientist
Employer:Sun Microsystem
Known for:Java Programming Language
CONTRIBUTION:
He is generally credited as the inventor of the Java programming language in 1994. He created the original design of Java and implemented its original compiler and virtual machine. For this achievement he was elected to the United States National Academy of Engineering. He has also made major contributions to several other software systems, such as NeWS and Gosling Emacs. He also cowrote the "bundle" program, a utility thoroughly detailed in Brian Kernighan and Rob Pike's book The Unix Programming Environment.
HONOURS
In 2007, he was made an Officer of the Order of Canada.[2] The Order is Canada's highest civilian honour. Officers are the second highest grade.
Subscribe to:
Posts (Atom)