Friday, July 3, 2015

Resources of java practice problems

To learn any programming language one must practice. It is the only way to become master in any particular language.

There are many sites for Java practice depending upon your expertise. There are some suggestions below.

For Experts:
  •  Hacker Rank
  •  Code Chef
  •  Coding Bat


For Beginners:

But if you want to start from beginning then I would recommend you to Merit CampusThere are various topics which you can read online. They also have good practice tests which will help you become expert in the field. There online compiler helps in checking the programs immediately with out having to install JDK on your machine or PC.

Java Topics:
http://java.meritcampus.com/java-tests?tc=mm32

Online Compiler:
http://java.meritcampus.com/java_compiler/run?tc=mm31

Also, expert training is provided by this site where experts will give online coaching to students.

Expert Training:
http://java.meritcampus.com/expert-java-training?tc=mm30

Hope that you will have a good programming journey.


Difference between string literal and object


String: String is class in java. It is used to hold the group of characters.


There are two ways of declaring strings:

1) String Literal

2) String Object


Example: 

i) String str="JAVA";

ii) String str=new String("JAVA");

The first type of string is a String Literal. 

The second type of string is an String object.


There is no difference in the content, but creating object occupies a lot of memory in your system. so JVM (Java Virtual Machine) uses some trick to reduce the cost of memory occupied by the string. JVM maintains a string Pool which contains all the unique string literals declared by your programs. 

So, Whenever you declare any String literal, JVM checks the string pool if that string is present in that pool then again memory is not occupied by that string instead both the string points to one memory location.' 

See this image for more information. 
                                                    Fig: String Pool


For more Details Refer following links: 

Is java easier than C?


JAVA is much more easier than C. 



JAVA is very Simple and easy to learn as very difficult Concepts of C like: 


  •  Pointers 

  •  Operator Overloading

  •  free() memory explicitly 




are removed from the JAVA. And many more features like "Garbage Collection" and "Security" as pointers are not there. 


For more features refer following link: 






To learn java you can refer books for theory knowledge like: 

Books on java:

1) Complete Reference 


2) Balaguruswamy 

Also, There are many Website from where you can learn java online: 

For Difficult Programs:

1) Codechef 

2) Hackerearth 
3) Hackerrank 






For Beginners: 
1) Meritcampus (Various Topics+ Online Compiler+ practice Tests + Expert Training)



2) W3school

C,C++,CSS and Java vs javascript


C,C++,CSS


C is a popular programming language developed by "Dennis Richie" where there is important concept of pointers but there is no objects at all. Everything is written inside main(). It is still used by many organizations as it work with core and basic memory functions like free(), malloc() and alloc() etc. 


C++ is like C but with object-oriented capabilities. You can define your own class and make objects of that class. 


There are many features of c++ like: 

  • Encapsulation 
  • object-oriented 
  • Inheritance 
  • Overriding and overloading 


CSS stands for Cascading style sheet. It is used to define style for HTML page. Instead of defining font for each and every tag of every page just create one css file and link it to every page of HTML. 

Advantages of CSS: 

1) Saves time and memory 
2) Sepration between content and presentation 

For more Details on above languages Refer following link: 






 JAVA VS Java Script: 


JAVA: Java is object-oriented programming language which is developed by "James Gosling" and his team and which was previously called as "OAK". 

Java is full-featured programming language with many features like: 

1) Platform independence 
2) Object-oriented 
3) Multithreaded 
4) secure 
5) Robust 
6) Distributed 
6) Simple and many more...


For more Details Refer following link: 



Java Script: Java script is interpreted language which is generally embedded inside an HTML page. It is client-side scripting language which is used to create interactivity within static HTML pages and decrease the burden of server by providing instant feedback to server. 

Java script is scripting language not programming language. 

For more Details Refer following link: 









Java applet vs application


JAVA Applet: Applet is a small program that doesn't have any main() method and which runs either in browser or in appletviewer. 


JAVA Application: Java application is a program with main() method which has input and display output on standard command prompt. 


There are many differences between JAVA Applet and JAVA Application: 

1) Applet requires appletviewer and application requires java interpreter.

2) Applet can not have access to local files on system whereas application has.

3) Applet has paint() method and application has main() method. 

4) Applet is required for building GUI based application.



                                                               Fig: Java Applet



For more Details Refer following link



Exceptions in java



 Exceptions are one of the important concept of Java.

Exception: Exceptions are nothing but Run-time error which comes in program due to Logical errors in program like "Divide by Zero", "Null pointer Exception" etc. Exception is a class in java. Sometimes there is no Compilation Error (Syntactical error) in your program but due to some errors at run-time like wrong user input error may arise and your program will be abruptly closed.



Fig: Exception Class Hierarchy

So, To avoid your program to be closed abruptly, you must know how to handle Exception by using "Try-Catch" block. 

There are two types of Exception:



1) System Defined (handled by throws/throw)



2) User Defined (handled by throw) 

There are various Exception classes in java like:


  •  ArrayIndexOutOfBoundsException
  •  DivideByZeroException
  •  IOException
  • NullPointerException and many more...



For  more Details Refer following link:



Garbage collection in Java


Garbage Collection is one the important feature of programming language like JAVA which is related with the memory management. At the end of program execution, objects which go out of scope or which are no longer referenced in the programs Java Virtual Machine (JVM) reclaims the memory associated with them. Unlike C++, there is no need of freeing the memory by using free() method explicitly; instead JVM automatically frees the memory allocated by objects.

Fig: Garbage Collection

finalize() method is invoked whenever object is collected for garbage.So, One can place the code for releasing resourcing or closing of files inside this method by overriding this.

For more Details Refer following link: