<< < 14 15 16 17 18 19 20 21 22 23 24 > >>   Sort: Rank

This class (IncrementImpl) will be used by various threads concurrently; can you see the inherent flaw(s)? How would you improve
This class (IncrementImpl) will be used by various threads concurrently; can you see the inherent flaw(s)? How would you improve it? public class IncrementImpl { private static int counter = 0; public synchronized void increment() { counter++; } public int getCounter() { return counter; } } The coun...
2012-08-28, 2111👍, 0💬

What is the relationship between synchronized and volatile keyword?
What is the relationship between synchronized and volatile keyword? The JVM is guaranteed to treat reads and writes of data of 32 bits or less as atomic.(Some JVM might treat reads and writes of data of 64 bits or less as atomic in future) For long or double variable, programmers should take care in...
2012-08-28, 2385👍, 0💬

What's the difference between constructors and other methods?
What's the difference between constructors and other methods? Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.
2012-08-27, 2130👍, 0💬

Why is multiple inheritance not possible in Java?
Why is multiple inheritance not possible in Java? It depends on how you understand "inheritance". Java can only "extends" one super class, but can "implements" many interfaces; that doesn't mean the multiple inheritance is not possible. You may use interfaces to make inheritance work for you. Or you...
2012-08-27, 2145👍, 0💬

Can one create a method which gets a String and modifies it?
Can one create a method which gets a String and modifies it? No. In Java, Strings are constant or immutable; their values cannot be changed after they are created, but they can be shared. Once you change a string, you actually create a new object. For example: String s = "abc"; //create a new String...
2012-08-24, 2059👍, 0💬

What is the difference between shallow copy and deep copy?
What is the difference between shallow copy and deep copy? Shallow copy shares the same reference with the original object like cloning, whereas the deep copy get a duplicate instance of the original object. If the shallow copy has been changed, the original object will be reflected and vice versa.
2012-08-24, 2090👍, 0💬

Can you declare a class as private?
Can you declare a class as private? Yes, we can declare a private class as an inner class. For example, class MyPrivate { private static class MyKey { String key = "12345"; } public static void main(String[] args) { System.out.println(new MyKey().key);//prints 12345 } }
2012-08-23, 2307👍, 0💬

Parsers? DOM vs SAX parser
Parsers? DOM vs SAX parser Parsers are fundamental xml components, a bridge between XML documents and applications that process that XML. The parser is responsible for handling xml syntax, checking the contents of the document against constraints established in a DTD or Schema. DOM 1. Tree of nodes ...
2012-08-23, 2144👍, 0💬

Why Java does not support pointers?
Why Java does not support pointers? Because pointers are unsafe. Java uses reference types to hide pointers and programmers feel easier to deal with reference types without pointers. This is why Java and C-sharp shine.
2012-08-22, 2192👍, 0💬

What is the difference between Swing and AWT components?
What is the difference between Swing and AWT components? AWT components are heavy-weight, whereas Swing components are lightweight. Heavy weight components 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 Uni...
2012-08-22, 2044👍, 0💬

What is the output of x &gt y? a:b = p*q when x=1,y=2,p=3,q=4?
What is the output of x &gt y? a:b = p*q when x=1,y=2,p=3,q=4? When this kind of question has been asked, find the problems you think is necessary to ask back before you give an answer. Ask if variables a and b have been declared or initialized. If the answer is yes. You can say that the syntax ...
2012-08-21, 2179👍, 0💬

Can you make an instance of an abstract class? For example - java.util.Calender is an abstract class with a method getInstance()
Can you make an instance of an abstract class? For example - java.util.Calender is an abstract class with a method getInstance() which returns an instance of the Calender class. No! You cannot make an instance of an abstract class. An abstract class has to be sub-classed. If you have an abstract cla...
2012-08-21, 1965👍, 0💬

Can you write a Java class that could be used both as an applet as well as an application?
Can you write a Java class that could be used both as an applet as well as an application? A. Yes. Add a main() method to the applet.
2012-08-20, 2089👍, 0💬

In System.out.println(),what is System,out and println,pls explain?
In System.out.println(),what is System,out and println,pls explain? System is a predefined final class,out is a PrintStream object acting as a field member and println is a built-in overloaded method in the out object.
2012-08-20, 2168👍, 0💬

Where and how can you use a private constuctor.
Where and how can you use a private constuctor. Private constructor can be used if you do not want any other class to instanstiate it by using new. The instantiation is done from a static public method, which is used when dealing with the factory method pattern.
2012-08-17, 2027👍, 0💬

How to add menushortcut to menu item?
How to add menushortcut to menu item? If you have a button instance called aboutButton, you may add menu short cut by calling aboutButton.setMnemonic('A'), so the user may be able to use Alt+A to click the button.
2012-08-17, 2065👍, 0💬

What is the benefit of subclass?
What is the benefit of subclass? Generally: The sub class inherits all the public methods and the implementation. The sub class inherits all the protected methods and their implementation. The sub class inherits all the default(non-access modifier) methods and their implementation. The sub class als...
2012-08-16, 2085👍, 0💬

What is scalability and performance?
What is scalability and performance? Performance is a measure of "how fast can you perform this task." and scalability describes how an application behaves as its workload and available computing resources increase.
2012-08-16, 2529👍, 0💬

What are use cases?
What are use cases? A use case describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance. It is part of the analysis of a program. The collection of use cases should, ideally, anticipate all the standard circumstances and many of the extra...
2012-08-15, 2141👍, 0💬

What is design by contract?
What is design by contract? The design by contract specifies the obligations of a method to any other methods that may use its services and also theirs to it. For example, the preconditions specify what the method required to be true when the method is called. Hence making sure that preconditions ar...
2012-08-15, 2257👍, 0💬

What is polymorphism?
What is polymorphism? Polymorphism means "having many forms". It allows methods (may be variables) to be written that needn't be concerned about the specifics of the objects they will be applied to. That is, the method can be specified at a higher level of abstraction and can be counted on to work e...
2012-08-14, 2085👍, 0💬

How the object oriented approach helps us keep complexity of software development under control?
How the object oriented approach helps us keep complexity of software development under control? We can discuss such issue from the following aspects: Objects allow procedures to be encapsulated with their data to reduce potential interference. Inheritance allows well-tested procedures to be reused ...
2012-08-14, 2343👍, 0💬

What is a Container in a GUI?
What is a Container in a GUI? A Container contains and arranges other components (including other containers) through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.
2012-08-13, 2076👍, 0💬

Is Java a super set of JavaScript?
Is Java a super set of JavaScript? No. They are completely different. Some syntax may be similar.
2012-08-13, 2227👍, 0💬

<< < 14 15 16 17 18 19 20 21 22 23 24 > >>   Sort: Rank