Java Notes-5


Java™ Application Development on Linux® – Free 599 Page eBook

Enterprise Java Virtualization:

Understanding the TCO Implications

InfoWorld’s Java IDE Comparison Strategy Guide:

Java Essential Training

Apache Jakarta Commons: Reusable Java™ Components

Enabling Rapid ROI: With Java™ – Based Business Intelligence Applications:

State (instance variables) Each object (instance of a class) will have its own unique set of instance variables as defined in the class. Collectively, the
values assigned to an object’s instance variables make up the object’s state.
Behavior (methods) When a programmer creates a class, she creates methods for that class. Methods are where the class’ logic is stored. Methods are where the real work gets done. They are where algorithms get executed, and data gets manipulated.
Real life examples of Identifiers Names ;-)
Inheritance which allows code defined in one class to be reused in other classes.
Interfaces Interfaces are like a 100-percent abstract superclass that defines the methods a subclass must support, but not how they must be supported.
Cohesive classes Every class should have a focused set of responsibilities.
Limits to the number of characters? No limit to the number of characters an identifier can contain.
int _$; legal identifier? Yes
int e#; legal identifier? No
Why coding conventions? Why it is imp? Sun estimates that over the lifetime of a standard piece of code, 20 percent of the effort will go into the original creation and testing of the code, and 80 percent of the effort will go into the subsequent maintenance and enhancement of the
code.
Source File Declaration Rules?
strictfp is a keyword and can be used to modify a class or a method, but never a Marking a class as strictfp means that any method code in the class will conform to the IEEE 754 standard rules for floating points. Without that modifier, floating points used in the methods might behave in a platform-dependent way.
You might get a question that asks how you could fix a code sample that includes a method ending in a semicolon, but without an abstract modifier on the class or method. In that case, you could either mark the method and class abstract, or change the semicolon to code (like a curly brace pair). Remember, if you change a method from abstract to nonabstract,don’t forget to change the semicolon at the end of the method declaration into acurly brace pair!
Can you mark a class as both abstract and final? No
Interface When you create an interface, you’re defining a contract for what a class can do, without saying anything about how the class will do it.
final void bounce(); // final and abstract can never be used
// together, and abstract is implied
static void bounce(); // interfaces define instance methods
private void bounce(); // interface methods are always public
protected void bounce(); // (same as above)
four access control levels for Class n public
n protected
n default
n priva
The subclass can see the protected member only through inheritance if package is different. The subclass can see the protected member through inheritance & through object ref as well if package is same.
package com.impetus.ilabs.reflect;
public class ProtectedTest
{
protected int x = 9;
}
public class Test extends ProtectedTest
{
static class TempStatic
{
Test test;
}
interface NonStatic
{
Test test = new Test();
}
static ProtectedTest protectedTest = new ProtectedTest();
public void main(String[] args) {
//  System.out.println(protectedTest.x);
System.out.println(x);
System.out.println(NonStatic.test);}
}
Difference b/w int[] key; // Square brackets before name (recommended)
int key [];
A. public abstract class Canine { public Bark speak(); }
B. public abstract class Canine { public Bark speak() { } }
C. public class Canine { public abstract Bark speak(); }
D. public class Canine abstract { public abstract Bark speak(); }
1. enum A { A }
2. class E2 {
3. enum B { B }
4. void C() {
5. enum D { D } // because enums cannot be
local to a method.
6. }
7. }

Single Sign-On for Java and Web Applications

Bulletproof Java Code: A Practical Strategy for Developing Functional, Reliable, and Secure Java Code

Transforming a Generic Java IDE to Your Application Specific IDE:

The Java Virtual Appliance—No OS Required

BEA WebLogic® Operations Control: Application Virtualization for Enterprise Java

Enabling Rapid ROI: With Java™ – Based Business Intelligence Applications:

Other interesting FAQs related Posts on Java, you may like:

Java Notes – 1 (clean-clouds.com)

Java Notes – 2 (clean-clouds.com)

Java Notes – 3 (clean-clouds.com)

Java Notes -4 (clean-clouds.com)

Java Notes -5 (clean-clouds.com)

Java Notes -6 (clean-clouds.com)

Frequently Asked Questions in Java Part- 1 (clean-clouds.com)

Frequently Asked Questions in Java Part- 2 (clean-clouds.com)

Frequently Asked Questions in Java Part-3 (clean-clouds.com)

Frequently Asked Questions in Java Part-4 (clean-clouds.com)

Frequently Asked Questions in Java Part-5 (clean-clouds.com)

Frequently Asked Questions in Java Part-6 (clean-clouds.com)

Frequently Asked Questions in Java Part-7 (clean-clouds.com)

Frequently Asked Questions in Java Part-8 (clean-clouds.com)

Frequently Asked Questions in Java Part-9 (clean-clouds.com)

Frequently Asked Questions in Java Part-10 (clean-clouds.com)

Frequently Asked Questions in Java Part-11 (clean-clouds.com)

Frequently Asked Questions in Java Part-12 (clean-clouds.com)

Frequently Asked Questions in Java Part-13 (clean-clouds.com)

Frequently Asked Questions in Java Part-14 (clean-clouds.com)

About these ads

Java Notes-4


Note that, in certain situations an Inner class may not be able to extend some other particular class (for eg. a static inner class cannot extend another non-static inner class in the same class). But in general there is no restriction on what an inner class may or may not extend.
As the original method is returning Object the Overriding method must also declare the same return type ie. Object.
static methods cannot be abstract
The Java exception mechanism is integrated with the Java synchronization model, so that locks are released as synchronized statements and invocations of synchronized methods complete abruptly.
class Test
{
public static void main(String[] args)
{
String s = “going”;
print(s,  s = “gone”);
}static void print(String a, String b)
{
System.out.println(a +”, “+ b );
}
}
//going, gone
The assignment of the string “gone” to s occurs after the first argument to print has been evaluated.
If evaluation of an argument expression completes abruptly, no part of any argument expression to its right appears to have been evaluated.
Note that although sizes of char and short are same but char can hold a larger int value.
Note that both char and short have a range of 2 ^ 16 integer but  char can store only +ive integer ie. 0 to 2 ^16 and short can store  -ive and positive both( -2^15 to 2^15-1).
Both types are of 2 bytes.
A clone of a multidimensional arrayis shallow, which is to say that it creates only a single new array. Subarrays are shared, so ia and ja are different but ia[0] and ja[0] are same.FYI,
clone() method defined in object class is protected.
But an array object overrides it and has the same methods as the following class:class A implements Cloneable
{
public final int length = X;
public Object clone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{
throw new InternalError(e.getMessage());
}
}
}
clone method of array does not throw any checked exception
An abstract method is usually defined in an abstract classor an interface,for which implementation is provided in a subclass or a class implementing the interface.As static methods just have single copy per class and are interpreted at code compile time,not at runtime, so it is impossible to have polymorphic behaviour out of them.In other words, they cannot be overridden.An abstract class is one which cannot be instantiated but a static method defined in abstract class can be invoked without creating an instance.So there is no mechanism to ensure call of an abstract static method.
all array object get a public clone method
Although o refers to an object which is Runnable but the compiler doesn’t know about it. You have to do: Runnable r = (Runnable) o;
You can assign a subclass object reference to superclass reference without a cast but to assign a super class object reference to a subclass (or interface) reference you need an explicit cast as in options 2 and 5.
  Float f1 = new Float(Float.NaN);
Float f2 = new Float(Float.NaN);
System.out.println( “”+ (f1 == f2)+”  “+f1.equals(f2)+ “  “+(Float.NaN == Float.NaN) );
f1 == f2  is false simply because f1 and f2 are different objects and == tests whether two references point to same object or not.
f1.equals(f2) return because both are storing same value (ie. Float.NaN).
All NaNs are incomparable. A NaN is not equal to NaN. So Float.NaN != Float.NaN is true.
XXXX m ;
switch( m )
{
case 32  : System.out.println(“32″);   break;
case 64  : System.out.println(“64″);   break;
case 128 : System.out.println(“128″);  break;
}What type can ‘m’ be of so that the above code compiles and runs as expected ?
Note that, in certain situations an Inner class may not be able to extend some other particular class (for eg. a static inner class cannot extend another non-static inner class in the same class). But in general there is no restriction on what an inner class may or may not extend.
As the original method is returning Object the Overriding method must also declare the same return type ie. Object.
static methods cannot be abstract
The Java exception mechanism is integrated with the Java synchronization model, so that locks are released as synchronized statements and invocations of synchronized methods complete abruptly.
class Test
{
public static void main(String[] args)
{
String s = “going”;
print(s,  s = “gone”);
}static void print(String a, String b)
{
System.out.println(a +”, “+ b );
}
}
//going, gone
The assignment of the string “gone” to s occurs after the first argument to print has been evaluated.
If evaluation of an argument expression completes abruptly, no part of any argument expression to its right appears to have been evaluated.
Note that although sizes of char and short are same but char can hold a larger int value.
Note that both char and short have a range of 2 ^ 16 integer but  char can store only +ive integer ie. 0 to 2 ^16 and short can store  -ive and positive both( -2^15 to 2^15-1).
Both types are of 2 bytes.
A clone of a multidimensional array is shallow, which is to say that it creates only a single new array. Subarrays are shared, so ia and ja are different but ia[0] and ja[0] are same.FYI,
clone() method defined in object class is protected.
But an array object overrides it and has the same methods as the following class:class A implements Cloneable
{
public final int length = X;
public Object clone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{
throw new InternalError(e.getMessage());
}
}
}
clone method of array does not throw any checked exception
An abstract method is usually defined in an abstract class or an interface,for which implementation is provided in a subclass or a class implementing the interface.As static methods just have single copy per class and are interpreted at code compile time,not at runtime, so it is impossible to have polymorphic behaviour out of them.In other words, they cannot be overridden.An abstract class is one which cannot be instantiated but a static method defined in abstract class can be invoked without creating an instance.So there is no mechanism to ensure call of an abstract static method.
all array object get a public clone method
Although o refers to an object which is Runnable but the compiler doesn’t know about it. You have to do: Runnable r = (Runnable) o;
You can assign a subclass object reference to superclass reference without a cast but to assign a super class object reference to a subclass (or interface) reference you need an explicit cast as in options 2 and 5.
  Float f1 = new Float(Float.NaN);
Float f2 = new Float(Float.NaN);
System.out.println( “”+ (f1 == f2)+”  “+f1.equals(f2)+ “  “+(Float.NaN == Float.NaN) );
f1 == f2  is false simply because f1 and f2 are different objects and == tests whether two references point to same object or not.
f1.equals(f2) return because both are storing same value (ie. Float.NaN).
All NaNs are incomparable. A NaN is not equal to NaN. So Float.NaN != Float.NaN is true.
XXXX m ;
switch( m )
{
case 32  : System.out.println(“32″);   break;
case 64  : System.out.println(“64″);   break;
case 128 : System.out.println(“128″);  break;
}What type can ‘m’ be of so that the above code compiles and runs as expected ?
Three rules must be remembered about switch statement:
1. Only byte, char, short and int can be used as types of a switch variable.
2. The switch variable must be big enough to hold all the case constants.
So, if switch variable is of type char, the no case constant can be greater than 65535. as char’s range is from 0 to 65535.
3. All case labels should be COMPILE TIME CONSTANTS.

Java™ Application Development on Linux® – Free 599 Page eBook

Enterprise Java Virtualization:

Understanding the TCO Implications

InfoWorld’s Java IDE Comparison Strategy Guide:

Java Essential Training

Apache Jakarta Commons: Reusable Java™ Components

Enabling Rapid ROI: With Java™ – Based Business Intelligence Applications:

Three rules must be remembered about switch statement:
1. Only byte, char, short and int can be used as types of a switch variable.
2. The switch variable must be big enough to hold all the case constants.
So, if switch variable is of type char, the no case constant can be greater than 65535. as char’s range is from 0 to 65535.
3. All case labels should be COMPILE TIME CONSTANTS.
A break statement with no label attempts to transfer control to the innermost enclosing switch, while, do, or for statement; this statement, which is called the break target, then immediately completes normally. If no switch, while, do, or for statement encloses the break statement, a compile-time error occurs.A break statement with label Identifier attempts to transfer control to the enclosing labeled statement  that has the same Identifier as its label; this statement, which is called the break target, then immediately completes normally. In this case, the break target need not be a while, do, for, or switch statement.A continue statement with no label attempts to transfer control to the innermost enclosing while, do, or for statement; this statement, which is called the continue target, then immediately ends the current iteration and begins a new one. If no while, do, or for statement encloses the continue statement, a compile-time error occurs.

A continue statement with label Identifier attempts to transfer control to the enclosing labeled statement that has the same Identifier as its label; that statement, which is called the continue target, then immediately ends the current iteration and begins a new one. The continue target must be a while, do, or for statement or a compile-time error occurs. If no labeled statement with Identifier as its label contains the continue statement, a compile-time error occurs.

public class EqualTest
{
public static void main(String args[])
{
Integer i = new Integer(1) ;
Long m = new Long(1);
if( i.equals(m)) System.out.println(“equal”);   // 1
else System.out.println(“not equal”);
}
}
Signature of equals method is : boolean equals(Object o); So it can take any object.
All standard equals methods first check if the two object are of same class or not. If not then they immediately return false. Hence the choice 2.
class A
{
protected int i;
A(int i) {    this.i = i;    }
}
Which of the following would be a valid inner class for this class?
Very similar question has been asked in SCJP2
Why option 2 is not right :
Notice that class A does not define a no-argument constructor. Now, note that the inner class B does not define a constructor. Thus, class B relies on the default constructor B(). Class B’s default constructor looks like this:
public B() {}
However, Constructors implicitly call super(). So, class B’s default constructor actually looks like this:
public B()
{
super();
}
Now, as class A does not define a no-argument constructor the above code will not compile.
however, class B would be correct if changed to:
class B extends A
{
B()
{
super(1); // pass it any integer
}
// or
B(int number)
{
super(number);
}
}
you could also add a no-argument constructor to class A and leave class B as is.
The native methods (also known as JNI ) is a way a java program can access things that are not available normally to the JVM. For. eg. you may need to access a device driver for (say) Fax card. Now, java does not provide any API for such a device. So you need to acces the s/w that comes with the hardware. You can do it using JNI.
As you are aware, Java program runs on JVM and so is a little bit slower than exe files. If a program does some computaion intensive work (say) Graphical calculation that need a lot of CPU time then it is better to write such code in C/C++ and call it from Java code. This improves performance.
Also, when you have some legacy code written in any language, you’ll need to write some hookups into that code in C/C++ and then call the C/C++ code from Java.
Now, the other feature of print/println methods is that if they get null as input parameter, they print “null”. They do not try to call toString() on null.
So, if you have, Object o = null; System.out.println(o); will print null and will not throw NullPointerException.
Folowing EscapeSequences are available :
b /* u0008: backspace BS */
t /* u0009: horizontal tab HT */
n /* u000a: linefeed LF */
f /* u000c: form feed FF */
r /* u000d: carriage return CR */
” /* u0022: double quote ” */
‘ /* u0027: single quote ‘  */
/* u005c: backslash   */
short VARIABLE cannot be assigned to a char without explicit casting
The ranges of short (-2^15 to 2^15-1 ) and char (0 to 2^16) are different.
Even though s contains a value that a char can hold, the compiler will reject it because s is a variable.
Note that char c = Short.MAX_VALUE; will compile fine because Short.MAX_VALUE is a CONSTANT.
Basically, implicit ( ie. which does not require a cast) narrowing conversion occurs only if….
1. The RHS is a CONSTANT.
2. The value of RHS can be held by the variable type of LHS.
so, byte b = 130; won’t compile because although 130 is a constant but the value is too big to be held by a byte.(Range of byte is -128 to 127)And
int i = 100;
byte b = i;      will also not compile because although value is small enough to be held by a byte but the RHS is a Variable (ie. i).3. Implicit narrowing occurs only for byte char short and int.Remember it does not occur for long float and double.
so this won’t compile…
int i = 129L;

Single Sign-On for Java and Web Applications

Bulletproof Java Code: A Practical Strategy for Developing Functional, Reliable, and Secure Java Code

Transforming a Generic Java IDE to Your Application Specific IDE:

The Java Virtual Appliance—No OS Required

BEA WebLogic® Operations Control: Application Virtualization for Enterprise Java

Enabling Rapid ROI: With Java™ – Based Business Intelligence Applications:

Other interesting FAQs related Posts on Java, you may like:

Java Notes – 1 (clean-clouds.com)

Java Notes – 2 (clean-clouds.com)

Java Notes – 3 (clean-clouds.com)

Java Notes -4 (clean-clouds.com)

Java Notes -5 (clean-clouds.com)

Java Notes -6 (clean-clouds.com)

Frequently Asked Questions in Java Part- 1 (clean-clouds.com)

Frequently Asked Questions in Java Part- 2 (clean-clouds.com)

Frequently Asked Questions in Java Part-3 (clean-clouds.com)

Frequently Asked Questions in Java Part-4 (clean-clouds.com)

Frequently Asked Questions in Java Part-5 (clean-clouds.com)

Frequently Asked Questions in Java Part-6 (clean-clouds.com)

Frequently Asked Questions in Java Part-7 (clean-clouds.com)

Frequently Asked Questions in Java Part-8 (clean-clouds.com)

Frequently Asked Questions in Java Part-9 (clean-clouds.com)

Frequently Asked Questions in Java Part-10 (clean-clouds.com)

Frequently Asked Questions in Java Part-11 (clean-clouds.com)

Frequently Asked Questions in Java Part-12 (clean-clouds.com)

Frequently Asked Questions in Java Part-13 (clean-clouds.com)

Frequently Asked Questions in Java Part-14 (clean-clouds.com)

 

Frequently Asked Questions in Java Part-14


Disclaimer: “Sources Unknown”; Compilation only; I compiled it from various sources When I was exploring Java.

Question: What is the importance of static variable?

Answer: static variables are class level variables where all objects of the class refer to the same variable. If one object changes the value then the change gets reflected in all the objects.

Question: Can we declare a static variable inside a method?

Answer: Static variables are class level variables and they can’t be declared inside a method. If declared, the class will not compile.

Question: What is an Abstract Class and what is its purpose?

Answer: A Class which doesn’t provide complete implementation is defined as an abstract class. Abstract classes enforce abstraction.

Question: Can a abstract class be declared final?

Answer: Not possible. An abstract class without being inherited is of no use and hence will result in compile time error.

Question: What is use of a abstract variable?

Answer: Variables can’t be declared as abstract. only classes and methods can be declared as abstract.

Question: Can you create an object of an abstract class?

Answer: Not possible. Abstract classes can’t be instantiated.

Question: Can a abstract class be defined without any abstract methods?

Answer: Yes it’s possible. This is basically to avoid instance creation of the class.

Class C implements Interface I containing method m1 and m2 declarations. Class C has provided implementation for method m2. Can i create an object of Class C?

No not possible. Class C should provide implementation for all the methods in the Interface I. Since Class C didn’t provide implementation for m1 method, it has to be declared as abstract. Abstract classes can’t be instantiated.

Question: Can a method inside a Interface be declared as final?

Answer: No not possible. Doing so will result in compilation error. public and abstract are the only applicable modifiers for method declaration in an interface.

Question: Can an Interface implement another Interface?

Answer: Interfaces doesn’t provide implementation hence a interface cannot implement another interface.

Question: Can an Interface extend another Interface?

Answer: Yes an Interface can inherit another Interface, for that matter an Interface can extend more than one Interface.

Question: Can a Class extend more than one Class?

Answer: Not possible. A Class can extend only one class but can implement any number of Interfaces.

Question: Why is an Interface be able to extend more than one Interface but a Class can’t extend more than one Class?

Answer: Basically Java doesn’t allow multiple inheritance, so a Class is restricted to extend only one Class. But an Interface is a pure abstraction model and doesn’t have inheritance hierarchy like classes(do remember that the base class of all classes is Object). So an Interface is allowed to extend more than one Interface.

Question: Can an Interface be final?

Answer: Not possible. Doing so will result in compilation error.

Question: Can a class be defined inside an Interface?

Answer: Yes it’s possible.

Question: Can an Interface be defined inside a class?

Answer: Yes it’s possible.

Question: What is a Marker Interface?

Answer: An Interface which doesn’t have any declaration inside but still enforces a mechanism.

Question: Which OO Concept is achieved by using overloading and overriding?

Answer: Polymorphism.

Question: If i only change the return type, does the method become overloaded?

Answer: No it doesn’t. There should be a change in method arguments for a method to be overloaded.

Question: Why does Java not support operator overloading?

Answer: Operator overloading makes the code very difficult to read and maintain. To maintain code simplicity, Java doesn’t support operator overloading.

Question: Can we define private and protected modifiers for variables in interfaces?

Answer: No

Question: What is a local, member and a class variable?

Answer: Variables declared within a method are “local” variables. Variables declared within the class i.e. not within any methods are “member” variables (global variables). Variables declared within the class i.e. not within any methods and are defined as “static” are class variables

Question: What is the range of the short type?

Answer: The range of the short type is -(2^15) to 2^15 – 1.

Question: How is rounding performed under integer division?

Answer: The fractional part of the result is truncated. This is known as rounding toward zero.

Question: What are the legal operands of the instanceof operator?

Answer: The left operand is an object reference or null value and the right operand is a class, interface, or array type.

Question: Are true and false keywords?

Answer: The values true and false are not keywords.

Question: What is the difference between an if statement and a switch statement?

Answer: The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed.

Question: What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. import java.net.* versus import java.net.Socket)?

Answer: It makes no difference in the generated class files since only the classes that are actually used are referenced by the generated class file. There is another practical benefit to importing single classes, and this arises when two (or more) packages have classes with the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import java.util.* and javax.swing.* and then try to use “Timer”, I get an error while compiling (the class name is ambiguous between both packages). Let’s say what you really wanted was the javax.swing.Timer class, and the only classes you plan on using in java.util are Collection and HashMap. In this case, some people will prefer to import java.util.Collection and import java.util.HashMap instead of importing java.util.*. This will now allow them to use Timer, Collection, HashMap, and other javax.swing classes without using fully qualified class names in.

Question: Can a method be overloaded based on different return type but same argument type ?

Answer: No, because the methods can be called without using their return type in which case there is ambiguity for the compiler

Question: What happens to a static var that is defined within a method of a class ?

Answer: Can’t do it. You’ll get a compilation error

Question: What is constructor chaining and how is it achieved in Java ?

Answer: A child object constructor always first needs to construct its parent (which in turn calls its parent constructor.). In Java it is done via an implicit call to the no-args constructor as the first statement.

Question: Explain the usage of Java packages.

Answer: This is a way to organize files when a project consists of multiple modules. It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.

Question: Explain in your own words the “bottom line” benefits of the use of an interface.

Answer: The interface makes it possible for a method in one class to invoke methods on objects of other classes, without the requirement to know the true class of those objects, provided that those objects are all instantiated from classes that implement one or more specified interfaces. In other words, objects of classes that implement specified interfaces can be passed into methods of other objects as the generic type Object, and the methods of the other objects can invoke methods on the incoming objects by first casting them as the interface type.

Question: What are some advantages and disadvantages of Java Sockets?

Answer: Some advantages of Java Sockets:

Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications. Sockets cause low network traffic. Unlike HTML forms and CGI scripts that generate and transfer whole web pages for each new request, Java applets can send only necessary updated information.

Question: Some disadvantages of Java Sockets:

Answer: Security restrictions are sometimes overbearing because a Java applet running in a Web browser is only able to establish connections to the machine where it came from, and to nowhere else on the network   Despite all of the useful and helpful Java features, Socket based communications allows only to send packets of raw data between applications. Both the client-side and server-side have to provide mechanisms to make the data useful in any way.

Question: What is OOPS?

Answer: OOP is the common abbreviation for Object-Oriented Programming.

There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation.

Question: What is a working thread? –

Answer: A working thread, more commonly known as a worker thread is the key part of a design pattern that allocates one thread to execute one task. When the task is complete, the thread may return to a thread pool for later use. In this scheme a thread may execute arbitrary tasks, which are passed in the form of a Runnable method argument, typically execute(Runnable). The runnable tasks are usually stored in a queue until a thread host is available to run them. The worker thread design pattern is usually used to handle many concurrent tasks where it is not important which finishes first and no single task needs to be coordinated with another. The task queue controls how many threads run concurrently to improve the overall performance of the system. However, a worker thread framework requires relatively complex programming to set up, so should not be used where simpler threading techniques can achieve similar results.

Question: What is a green thread?

Answer: A green thread refers to a mode of operation for the Java Virtual Machine (JVM) in which all code is executed in a single operating system thread. If the Java program has any concurrent threads, the JVM manages multi-threading internally rather than using other operating system threads. There is a significant processing overhead for the JVM to keep track of thread states and swap between them, so green thread mode has been deprecated and removed from more recent Java implementations. Current JVM implementations make more efficient use of native operating system threads.

Question: What is the volatile  modifier for?

ANSWER:  The volatile modifier is used to identify variables whose values should not be optimized by the Java Virtual Machine, by caching the value for example. The volatile modifier is typically used for variables that may be accessed or modified by numerous independent threads and signifies that the value may change without synchronization.

Question: What is Internationalization?

Answer: It is the process of designing an application so that it can be adapted to various languages and regions without engineering changes. Sometimes the term internationalization is abbreviated as i18n, because there are 18 letters between the first “i” and the last “n.”

Localization is the process of adapting software for a specific region or language by adding locale-specific components and translating text. The term localization is often abbreviated as l10n, because there are 10 letters between the “l” and the “n.”

Java can display any Unicode characters through its windowing system AWT, provided that 1. You set the Java system property “user.language” appropriately, 2. The /usr/lib/java/lib/font.properties.language font set definitions are appropriate, and 3. The fonts specified in that file are installed. For example, in order to display text containing japanese characters, you would install japanese fonts and run “java -Duser.language=ja …”. You can combine font sets: In order to display western european, Greek and japanese characters simultaneously, you would create a combination of the files “font.properties” (covers ISO-8859-1), “font.properties.el” (covers ISO-8859-7) and “font.properties.ja” into a single file. ??This is untested??

The interfaces java.io.DataInput and java.io.DataOutput have methods called `readUTF’ and `writeUTF’ respectively. But note that they don’t use UTF-8; they use a modified UTF-8 encoding: the NUL character is encoded as the two-byte sequence 0xC0 0×80 instead of 0×00, and a 0×00 byte is added at the end. Encoded this way, strings can contain NUL characters and nevertheless need not be prefixed with a length field – the Cfunctions like strlen() and strcpy() can be used to manipulate them.

Other interesting FAQs related Posts on Java, you may like:

Java Notes – 1 (clean-clouds.com)

Java Notes – 2 (clean-clouds.com)

Java Notes – 3 (clean-clouds.com)

Java Notes -4 (clean-clouds.com)

Java Notes -5 (clean-clouds.com)

Java Notes -6 (clean-clouds.com)

Frequently Asked Questions in Java Part- 1 (clean-clouds.com)

Frequently Asked Questions in Java Part- 2 (clean-clouds.com)

Frequently Asked Questions in Java Part-3 (clean-clouds.com)

Frequently Asked Questions in Java Part-4 (clean-clouds.com)

Frequently Asked Questions in Java Part-5 (clean-clouds.com)

Frequently Asked Questions in Java Part-6 (clean-clouds.com)

Frequently Asked Questions in Java Part-7 (clean-clouds.com)

Frequently Asked Questions in Java Part-8 (clean-clouds.com)

Frequently Asked Questions in Java Part-9 (clean-clouds.com)

Frequently Asked Questions in Java Part-10 (clean-clouds.com)

Frequently Asked Questions in Java Part-11 (clean-clouds.com)

Frequently Asked Questions in Java Part-12 (clean-clouds.com)

Frequently Asked Questions in Java Part-13 (clean-clouds.com)

Frequently Asked Questions in Java Part-14 (clean-clouds.com)