Thursday, 24 November 2016

JQuery - Introduction

jQuery is a small, light-weight and fast JavaScript library. It is cross-platform and supports different types of browsers. It is very useful for data manipulation.
  • jQuery is a small, fast and lightweight JavaScript library.
  • jQuery is platform-independent.
  • jQuery means "write less do more".
  • jQuery simplifies AJAX call and DOM manipulation.
jQuery features:
  • HTML manipulation
  • DOM manipulation
  • DOM element selection
  • CSS manipulation
  • Effects and Animations
  • Utilities
  • AJAX
  • HTML event methods
  • JSON Parsing
  • Extensibility through plug-in
To starts with,
  • A $ sign to define/access jQuery
  • A (selector) to "query (or find)" HTML elements
  • A jQuery action() to be performed on the element(s)

jQuery Syntax:

The jQuery syntax is tailor-made for selecting HTML elements and performing some action on the element(s).

Basic syntax is: $(selector).action()

$(this).hide() - hides the current element.
$("p").hide() - hides all elements.
$(".test").hide() - hides all elements with class="test".
$("#test").hide() - hides the element with id="test".

Tuesday, 22 November 2016

Initializing a blank final variable in Java

How to initialize a blank final variable in Java?

Example Java Program to demonstrate the initialization of blank final variable using Constructor

                  A field can be declared as final. Doing so prevents its contents from being modified, A final variable that is not initialized at the time of declaration is known as blank final variable. The blank final variable can be only initialized using its constructor method.

                  As per the coding convention, it is common to use all upper case letters to represent a final variable. 


                    final in REGNO = 15480;


//Java Program to demonstrate the initialization of blank final variable using Constructor
class FinalInitialize
     final int VALUE;
     FinalInitialize(){       // Constructor
          VALUE=10;           // Initialized final variable inside constructor
          System.out.println("Final Value is : "+VALUE);
public class InitializeFinal {
     public static void main(String[] args) {
          new FinalInitialize();

               In the above program, The FinalInitialize() constructor initiate the value of the final variable VALUE.

Sunday, 13 November 2016

Java Program to find the Volume of a Box

Volume of a Box in Java

                  The below program demonstrates simple class creation and perform volume calculation of a box.


class Box {
double width;
double height;
double depth;
public class BoxJavaProgram {
    public static void main(String[] args){
        Box mybox = new Box();
        double vol;
        mybox.width = 20;
        mybox.height = 30;
        mybox.depth = 10;
        vol = mybox.width * mybox.height * mybox.depth;
        System.out.println("Volume is " + vol);


Volume is 6000.0

Thursday, 10 November 2016

Difference between Instance and Object in Java

Difference between class object and class instance in java

               The new operator instantiates a class by allocating memory for a new object and returning a reference to that memory. The phrase "instantiating a class" means the same thing as "creating an object." When you create an object, you are creating an "instance" of a class, therefore "instantiating" a class.

Object and Instance in Java
Difference between object and instance in Java

It is obvious to get confused by the words class object and class instance. A class is a template for an object and an object is an instance of a class. To make it clear, we can also say that the instance of a class is object.

There is no need of differentiating the words object and instance as both doesn’t make any difference when is used interchangeably.

For Example:

class Animal

Object of class Animal and instance of class Animal are same. When you create an instance of the class animal, the instance is an object and the type of that object is “class Animal”.