Showing posts with label java simple facts. Show all posts
Showing posts with label java simple facts. Show all posts

Friday, 1 January 2016

String Concatenation in Java

Concatenating Strings in Java

How to add two Strings in Java

               In Java, there is class named String contains method concat() for concatenating stings. The concat method can be used as follows:

     Type 1: string1.cancat(string2);
     Type 2: "Sun rises ".concat("in the east");

               Another common way to add strings in java is with the help of the '+' operator. 

     Example: "Sun rises "+"in the east";

Tuesday, 11 August 2015

Difference between Methods and Constructors in Java

Methods Vs Constructors in Java

What is the difference between Methods and Constructors in Java?

               It is obvious that Constructor and Method in Java make confusion for the beginners. Here are few points which illustrate the difference between a constructor and method in Java.





It is not necessary to use the same name of the class to create a Method.

The name of the Constructor should be same as the class name it resides.


Method is an ordinary member function which is used to expose  the behavior of an object

Constructor is a member function of a class used to initialize the state of an object


Methods must have return type unless it is specified as void.

Constructor does not have a return type.


Compiler does not create a method in any case if one is not available.

Java compiler creates default constructor if the program doesn’t have one.


Methods invoked explicitly. 
Invoked using the dot operator.

Constructor invoked implicitly. i. e. Invoked using the keyword ‘new’.

               Hoping that the above table gives an idea about how Constructors are different from methods in Java.

Constructor Method Difference

Friday, 3 October 2014

Java Applet Security

How Java Applet Deals with Security?

Java keeps a "firewall" between a networked application and the computer.

Java Achieves this protection with the help of a Java Compatible Web Browser by confining a Java Program to the Java Execution Environment and not allowing its access to the others parts of the Computer.