Inheritance is used for an IS-A relationship.
Aggregation is used for a HAS-A relationship.
EG:
Cars, Scooters are vehicles. (Inheritance)
Car has a steering, wheel etc. (Aggregation)
In...
Type: Posts; User: SahilKabra; Keyword(s):
Inheritance is used for an IS-A relationship.
Aggregation is used for a HAS-A relationship.
EG:
Cars, Scooters are vehicles. (Inheritance)
Car has a steering, wheel etc. (Aggregation)
In...
Hi,
Yes. You can use throw alone without using try catch.
EG:
public void foo() throws Exception {
throw new Exception();
}
Throw is used to throw an exception.
Throws is used in a...
public static void main (String [] args) throws Exception {
String number = "30";
System.out.println(Integer.parseInt(number));
}
Please paste this in a java class file.
...
Use
Integer.parseInt("3");
It throws an exception if the string contains an invalid number.
Regards,
Sahil.
Hi,
To increase the heap memory, use the following command when you execute your application:
java -Xms32m -Xmx256m MyClassName
In the above command,
-Xms32m means that the minimum memory...
Hi Venkat,
To add data to a table dynamically, you will have to extend javax.swing.table.AbstractTableModel. In this class there is a method called getValueAt(rowIndex, colIndex). This method is a...
Hi Heidi,
This is my analysis:
Take the string HEIDI.
The first time the function will be called with
f("HEIDI")
Now the x.empty() will return false. So the control will call the function...
Hi Ankit,
It would have been better had you given the stack trace.
But the problem you are facing usually occurs because of the following:-
You may not have your classpath configured correctly....
Hi Gaurav0252,
What you can do is to store all these Strings in an Array.
Loop through the array comparing every element with every other element. You could also declare an integer array where you...
Hi Patkar456,
From what you are saying what I understand is
1. You will need an Html file that will be your front end.
2. This HTML file will contain the Javascript.
3. On the submit action...
Java by itself is not platform independant, it is the JVM which makes it platform independant. All java code runs withing the JVM and it is the JVM which interacts with the underlying OS.
Regards,...
Implement the java.io.Serializable interface
A normal class in Java cannot be private, but an inner class can be private. Inner classes are generally used in Swings to add listeners for various components.
Regards,
Sahil.
In the above program, you are passing an double to function that accepts an integer value. Since double is more precise than an integer (i.e its value is greater that int) hence Java does not do an...
The Java code that you compile gets converted to a form known a bytecode that is present in the .class files.
Every OS has its own JVM. The JVM takes this bytecode and then executes the program. So...
Checked exception is an exception that you have to handle in your program.
EG: IOException
Unchecked exceptions are not required to be handled in the program
EG: NullPointerException
You can use custom tags for this purpose.
Regards,
Sahil.
--Smile, It makes people wonder what you are thinking!!!:)
For all the primitive data types we have their corresponding objects - Eg: for int we have Integer and so on. These are known as wrapper classes.
Prior to Java 5, there were methods that accepted...
JSP is used for the design of a web page and servlet is used to code the logic that is present i.e. in the MVC (Model-View-Controller) architecture, the servlet is the controller and the JSP is the...
== is a compare value by reference. String is an object. So when you use ==,
it compares the references of the two objects ( c and "+"). To compare the values, use "+".equals(c).
Seeing your code,...
The very first thing that a C compiler does is:
It invokes the preprocessor. The function of the preprocessor is to replace all preprocessor directives with their appropriate substitution.
...
#define a 10
print() {
printf("%d..",a);
}
foo()
{
#undef a
#define a 50
}
main()
Hi,
An interface provides only the signatures of methods that any class implementing that interface will implement.
An abstract class provides implementation of the common functionalities present...
Are you using Swing? If yes,try setting the layout to Border Layout or Flow layout. If you set it to Border Layout, add the component as frame.add(comp, BorderLayout.NORTH) and frame.add(comp2,...
Hi,
The preprocessor is invoked by the compiler as the first phase in the translation process. The preprocessor replaces all occurrences of the macro with the value. In the above program the second...