What is the difference between Java 1.6 and 1.7?
Java 1.7 introduces a lot of small improvements including some new language enhancements. Language enhancements include:Strings in switch statements, try-with-resources statements, improved type inference for generic instance creation ("diamond"), simplified varargs method invocation, better integral literals, and improved exception handling (multi-catch).
Example of diamond operator: List
Java 1.7 also included support for dynamic languages.
Jave 6 was mostly incremental improvements to existing libraries, no new language features (except for the @Override).
For full list see Java Programming Language Enhancements.
What is the meaning of ten high level programming language?
'ten' is a number; google for 'high level programming language'
How do you close a frame when opening another frame in java?
There are many ways to accomplish this but one way I might accomplish this is with a WindowListener or WindowAdapter. Below is a skeleton structure:
package pkg;
public class ExampleMainFrame extends JDialog
{
public ExampleMainFrame(final Window parent)
{
super(parent);
// ... Do other stuff for initialization here or in another internal method
addWindowListener(new WindowAdapter()
{
public void WindowClosed(WindowEvent e)
{
(new ExampleDialog2(parent)).setVisible(true);
}
}
}
// ... Other methods
}
(In different .java source file)
package pkg
public class ExampleDialog2 extends JDialog
{
public class ExampleDialog2(final Window parent)
{
super(parent);
// ... Do other stuff for initialization here or in another internal method
}
// ... Other methods
}
Explanation:
WindowListener is an Interface - WindowAdapter is a class that defines empty method definitions for each of the methods so you can effectively define/override one of the methods and instantiate a WindowAdapter and it won't do anything but what you've overridden. In this example, I've overridden WindowClosed and upon that event occuring, it'll create and show the 2nd frame.
What is the name of the class of people in their nineties?
Presumably "nonagenarians", by extension from "octagenarians" (people in their eighties), although I have never heard the term in actual use.
Type safety is the degree to which the language prevents you from making typing errors. That is: assigning values of one type to variables of another type.
For example, in Java:
int i;
String s = "Not an integer";
i = s;
is a type error as you are trying to assign a value of type String to a variable of type int.
Java is moderately type safe as it will allow you to "type-cast" (automatically convert types) for some combinations but will give a compiler error for others.
What are the various character extraction function available in java?
JAVA provides a String class that provides the methods to extract the characters out of the given particular string from a String object. Now we shall discuss all the methods provided by JAVA in this blog.
charAt()To extract a particular character from the particular location from the string, charAt()method is used. General form:1char charAt(int where);Here, where is the index of the character tobe extracted from the string. For choosing the value of where we should keep only one thing in mind that the value should be a nonnegative value. This method returns the character at that particular location.
Example:1public class exam{
2public static void main(String args[]){
3String s="abc";
4char ch;
5ch=s.charAt(2);
6System.out.println("charAt returns: "+ch);
7}
8}
Output of above code is:
getChars()getChars() is used to extract more than one characters at a time. General form:1void getChars(int sourceStart,int sourceEnd,char target[],inttargetStart);Here,sourceStart specifies the start index of the substring, sourceEnd specifies an index that is one past the end of the desired substring. But the substring contains the characters 1 less than the actual value of sourceEnd. target[] will store the required characters. The index of the target array where the substring is to be stored is specified by the targetStart.
Example:01public class exam1{
02public static void main(String args[]){
03String s="Have a good day every one!!";
04int start=4;
05int end=11;
06char ch[]= new char[end-start];
07s.getChars(start,end,ch,0);
08System.out.println(ch);
09}
10}
Output of above code is:
getBytes()getBytes() stores the characters in an array of bytes, and it uses default character-to-byte conversions. General form:1byte[] getBytes();It is most useful when you are a String value into an environment that does not support 16-bit Unicode characters.
toCharArray()toCharArray() is used to convert all characters in a String object into a character array. It returns an array of characters for the entire string. General Form:1char[] toCharArray();The Do-While loop is what type of loop?
The do loop is similar to the while loop, except that the expression is not evaluated until after the do loop's code is executed. Therefore the code in a do loop is guaranteed to execute at least once. The following shows a do loop in action:
do {
System.out.println("Inside do while loop");
} while(false);
The System.out.println() statement will print once, even though the expression evaluates to false. Remember, the do loop will always run the code in the loop body at least once. Be sure to note the use of the semicolon at the end of the while expression.
True.
Defines the security policy for each application .Every Java Application can have its own Security manager.
What does import javax.swing.jaframe mean?
Its a Java programming language call to include a method called Jaframe which is is the Javax.Swing class Library.
What are the differences between gc methods of System and Runtime Classes in Java?
There is actually no difference between System.gc() and Runtime.gc(). They both essentially invoke the JVM's Garbage Collection operation.
The System.gc() is a static method so it's a little bit more convenient to use. The call System.gc() is effectively equivalent to the call:
Runtime.getRuntime().gc()
What are the methods is class diagram?
The methods in a class diagram represent the actions that the class can perform. For instance, a method with an add(x,y) method could add two integers while a getName() could return a variable containing the name of a person.
What is an unhandled exception?
An unhandled exception is an Exception that is thrown by execution but is never caught by the program, which results in a nasty Exception Stack. This could be avoided by catching the exception in a try-catch statement, but it is not always appropriate to catch every possible exception. Sometimes the exception is the result of the client making a mistake rather than something that occurred where it is thrown, therefore the client should be informed of the exception. But most of the time it is user friendly to not propagate exceptions.
Why do you need to write brackets after such command as getName in java?
The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.
The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.
The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.
The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.
The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.
The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.
The parentheses are used in methods to specify arguments. Some methods don't use arguments; but it would in fact be more confusing, not less, to omit the parentheses in this case - because the parentheses give some kind of consistency.
The parentheses also help make it clear when something written after a dot is a field, and when it is a method. For this reason, in languages that allow you to either write or not write the parentheses for methods without arguments, I would always write them, for clarity and consistency.
Why is everything whatever dollars and 99 cents?
when people hear 99 cents they think it's cheaper. It is psychology.
What does java and java fx do?
JAVA is Group Of Technologies Like Java SE, Java EE, Java ME
and Java FX is a Latest Technology Released From SUN Micro Systems
Sun Developed Java FX as Counterpart to Microsoft's Graphics Libraries and Rich Support of Visual Studio to GUI Classes of .NET Framework.
But in JAVA FX We can Do some advanced Graphics Operations in Programming Apart From AWT & Swing of Java SE and Rich Internet Application Technologies Like Enterprise Java Beans (EJB),JSP Of Java EE.
Java code to average and total a set of numbers?
The below method is written in the assumption that, the n numbers are sent as an ArrayList of Integer values.
public void computeSumAndAvg(ArrayList lst){ Iterator itr = lst.iterator();
int sum = 0;
float average = 0;
int count = 0;
while(itr.hasNext(){ Integer val = (Integer) itr.next();
sum = sum + val.intValue();
count++; }
average = sum/count;
System.out.println("Sum is: " + sum) ;
System.out.println("Average is: " + average) ; }
import java.util.Vector;
public class VectorTest {
/**
* @param args
*/
public static void main(String[] args) {
//instantiating a vector
Vector vct = new Vector();
//Add objects to a vector
vct.add("One");
//getting values from the vector
String val = (String) vct.get(0);
//vector size
System.out.println("Vector size is: " + vct.size());
//removing elements from a vector
vct.remove(0);
}
}