Wednesday 21 August 2013

Disadvantage of java...............

Disadvantage are also categorized here...................

Even though Java is projected as the most demanded language of the times, but has its own disadvantages. Of course, they are very minor in nature and need not be considered as drawbacks compared to the advantages it brings forward.
a) Slow performance: The first and foremost drawback everyone accepts is Java's slow speed of execution. Of course it is designed so to get the affect of platform-independent feature. Designers do trying to increase the performance in other aspects like the introduction of JIT (Just-In-Time) compiler.
b) No support for low-level programming: With Java, low-level programming cannot be done as it is intended to be portable across platforms.
c) Poor features in GUI: Java supports GUI controls but with less features. For example, an image cannot be placed on a button. The is overcome with the introduction of javax.swing package. Swing controls come with abundant features that are comparable with any GUI available.

d) No control over garbage collection: Garbage collection is one of the built-in features of Java and is entirely managed by JVM. programmer is not given any handles to control the garbage collection to make coding simple. For this reason, Java does not come with delete(), free(), malloc() and sizeof() etc. functions.
What Java Can't Do?
Even though Java is termed as a production language where productivity is very high, but still it cannot do certain things. The productivity is possible due to the abundant classes available in Java API that can cater to the very specific needs of the programmer. Java includes a few thousands of classes with JDK 1.5 that takes care of many minute aspects of coding. Even though it is hyped so heavily, but it cannot be used to develop low-level programming. Using Java, a new OS or new protocols or DVD burning software etc. cannot be programmed.
Reference:
- See more at: http://way2java.com/java-introduction/java-
http://way2java.com/java-introduction/java-drawbacks/

Top 10 java interview question

Basically there are 1000 and thousand Interview quetion but still i think student ..must see these..
1-What is volatile in java
2-What is synchronization in java
3-what is String pooling in java
4-What is transient in java
5-What java is useful for transaction
6-Why only java not .net
7-what happens in case of deadlock
8-what is hash map and hash table in java
9-why there is contract between equals method  and hascode
10-what is jconsole in java

once it's get done we have next step

Top 10 tough core Java interview questions answers programming

developer must know all it...

once the level or tough is done..we have tricky question...Student must learn it also...

Top 10 Tricky Java interview questions and Answers


..........
+ashu negi these are top 10 question for fresher......................
All the best

Thursday 1 August 2013

java 1.8 ......

dk 1.8:-
it has come with oustanding feature. some of the feature has been driven from other language but .overall it's a great featurs for developer.
http://docs.oracle.com/javase/8/docs/api/

1.Lamda Expressions

I started with lambda expressions as this is probably the most sought after feature in the language after probably Generics/Annotations in Java 5.
http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html

Here’s the syntax:

1
(argtype arg...) -> { return some expression.. probably using these arguments }
What it does is that it reduces the code where it is obvious, such as in an anonymous innerclass. (Swing action handlers just got sexy, yay!)

So, a thread can be changed as:

1
Runnable oldRunner = new Runnable(){
2
    public void run(){
3
        System.out.println("I am running");
4
    }
5
};
6
Runnable java8Runner = () ->{
7
    System.out.println("I am running");
8
};
Similar to Scala, type inference is also possible in Lambdas. Consider the following available example:

1
Comparator c = (a, b) -> Integer.compare(a.length(), b.length());
Here, the types of a,b (In this case String, from the Comparator interface) are inferred as the compare method is implemented.

The symbol used to separate the block from arguments, -> is quite similar to => already used in Scala and if you are good at it, there is not much reason to switch as you will feel the way lambdas are implemented in java is inadequate(and verbose), but for a good ‘ol java programmer, this is the way to go.

2.Generic Type changes and improvements

Taking clues from Lambdas, generic collections can also infer the data types to be used to an extent. The methods for instance using a generic collection need not specify genric types. Hence, the following method

1
SomeClass.method();
Can be called simply ignoring the type information:

1
SomeClass.method();
The type can be inferred by the method signature, which is helpful in nested calls like

1
myCollection.sort().removeUseless().beautify();
3. Stream Collection Types (java.util.stream)

A stream is a iterator that allows a single run over the collection it is called on. Along with Lambdas, this is another noteworthy feature to watch out for. You can use streams to perform functional operations like filer or map/reduce over collections which can be streamed as individual elements using Stream objects. Streams can run sequentially or parallely as desired. The parallel mode makes use of fork/join framework and can leverage power of multiple cores.

Example:

1
List guys = list.getStream.collect(Collectors.toList())
can also be implemented parallely as

1
List guys = list.getStream.parallel().collect(Collectors.toList()
Another nice example that reduces the collection to a single item is by calling reduce algorithem.

1
int sum = numberList.stream().reduce(0, (x, y) -> x+y);
or,

1
int sum = numberList.stream().reduce(0, Integer::sum);
4. Functional Interfaces (java.util.function)

These interfaces contain some default methods which need not be implemented and can run directly from the interface. This helps with existing code – changing interfaces need not make all the classes implementing it implement new methods. This is similar to Traits in Scala and functional interfaces will be compatible with lambdas.

5. Nashorn – The Node.js on JVM

This is the javascript engine that enables us to run javascript to run on a  jvm. It is similar to the V8 engine provided by chrome over which Node.js runs. It is compatible with Node.js applications while also allowing actual Java libraries to be called by the javascript code running on server. This is exciting to say at the least as it marries scalability and asynchronous nature of Node.js with safe and widespread server side Java middleware directly.

6. Date/Time changes (java.time)

http://download.java.net/jdk8/docs/api/java/time/package-summary.html

The Date/Time API is moved to java.time package and Joda time format is followed. Another goodie is that most classes are Threadsafe and immutable.

7. Type Annotations

Now annotations can be used to decorate generic types itself.

Eg:

1
List<@Nullable String>
which is not desired always, but can prove to be useful in certain circumstances. Apart from decorating Generic types, it can also be used in constructors and casting.

1
new @NonEmpty @Readonly List(myNonEmptyStringSet)
2
new @Interned MyObject()
3

4
myString = (@NonNull String) myObject;
Even the array objects can be annoted:

1
@NotNull String[] arr;
The inclusion of RuntimeVisibleTypeAnnotations and RuntimeInvisibleTypeAnnotations attributes which cause the .class file to save the annotation information.

8.Other – (nice to have) Changes

Reflection api is slightly increased with the support of TypeName, GenericString, etc.

String.join() method is a welcome addition as a lot of self created utility classes are created instead. So, the following example

1
String abc= String.join(" ", "Java", "8");
Will get evaluated as “Java 8?.

In the Collections package, the Comparator interface is revamped and methods like reversed, comparing and thenCOmparing have been added which allow easy customization of comparison over multiple fields. Other libraries like the Concurrency and NIO have also been updated but is nothing noteworthy for following up and is keeping with the changes in the api.

Overall, Java8 is well thought of and is making mainstream java concise and picking some good parts of Scala/Clojure for the improving its syntax and addressing much sought features.