Javascript Code
Please Note – this doesnt work with old version of js File


$('document').ready(function(){
$('#cboCity').live("change", function(){
alert('Hi there');
});

$('#btnChange').on("click", function(){
changeCities();
});
});

function changeCities()
{
strSelect = "<select id='cboCity' name='cboCity'><option>Chennai</option><option>Mumbai</option></select>";
$('#City').html(strSelect);
}

HTML Code

<input id="btnChange" type="button" name="btnChange" value="Change Me" /></pre>
<table>
<tbody>
<tr>
<td>
<div id="City">
<select id="cboCity" name="cboCity"><option>Chennai</option><option>Mumbai</option><option>Delhi</option><option>Kolkatta</option><option>Andrapradesh</option>
</select>

</div>
</td>
</tr>
</tbody>
</table>

Table Structure

 CREATE TABLE Areas(AreaName VARCHAR(255),
                    PinCode VARCHAR(255))
                    
INSERT INTO Areas(AreaName, PinCode)
          VALUES('Teynampet',   '6000018'), 
                ('Ramapuram',   '6000089'),
                ('TNagar',      '6000017'), 
                ('Mylapore',    '6000014'), 
                ('Gopalapuram', '6000087')

Procedure which returns multiple result sets

 DROP PROCEDURE IF EXISTS mp_test1;
 CREATE PROCEDURE mp_test1()
 BEGIN
   SELECT AreaName FROM Areas;
   SELECT PinCode FROM Areas; 
 END 

Procedure Call

 CALL mp_test1()

PHP Code To retrieve Records from Multiple Resultsets

   $mysqli	= new mysqli('localhost', 'root', '', 'test','3306');
	
   $query = "CALL mp_test1()";
	
   $i = 0;	
	
   if ($mysqli->multi_query($query)) 
   {
    do {		
	/* store first result set */
        if ($result = $mysqli->use_result()) 
	{
	  $j = 0;
	  
          while ($row = $result->fetch_row()) 
	  {
	     $arrResult[$i][$j] = $row[0];
	     $j++;
	  }
				
   	  $result->close();
         }
			
	if($mysqli->more_results()) 
	{
  	  $i = $i + 1;
	}			 
     } while ($mysqli->next_result());
   }
	
   print "
";
   print_r($arrResult);

Table Structure

CREATE TABLE Areas(AreaName VARCHAR(255),
                    PinCode VARCHAR(255))
                    
INSERT INTO Areas(AreaName, PinCode)VALUES
                 ('Teynampet', '6000018'), 
                 ('Ramapuram', '6000089'),
                 ('TNagar', '6000017'), 
                 ('Mylapore', '6000014'), 
                 ('Gopalapuram', '6000087')

Stored Procedure

DROP PROCEDURE IF EXISTS mp_test;
CREATE PROCEDURE mp_test(IN pArea VARCHAR(255))
   BEGIN
      SET @Query = '';
      SET @City  = '';
      SET @Query = 'SELECT PinCode FROM Areas';

      IF pArea != '' THEN
         SET @City = CONCAT(' WHERE AreaName = "', pArea, '"');
      END IF;
      
      SET @Query = CONCAT(@Query, @City);

 PREPARE stmt FROM @Query;
 
 EXECUTE stmt;
 DEALLOCATE PREPARE stmt;  
END 

How Static and Constructor will work when class is Extended

  public class Main2 extends A   
  {
   public static void main(String args[])
    {	
	   
    }
  }

  class A extends B 
  {
    A()
    {
      System.out.println("I am A Constrctor");
    }
	
    static
   {
      System.out.println("I am Static Method");
   }
	
   {
      System.out.println("Empty");
   }
 }

 class B
 {
   B()
   {
     System.out.println("I am B Constrctor");
   }
 }

OP:I am Static Method

How Static and Constructor will work when class object is Created

   public class Main2 extends A   
  {
   public static void main(String args[])
    {	
       A objA = new A();  
    }
  }

  class A extends B 
  {
    A()
    {
      System.out.println("I am A Constrctor");
    }
	
    static
   {
      System.out.println("I am Static Method");
   }
	
   {
      System.out.println("Empty");
   }
 }

 class B
 {
   B()
   {
     System.out.println("I am B Constrctor");
   }
 }

OP:I am Static Method
I am B Constrctor
Empty
I am A Constrctor

How to Store CSV Ids in Hidden Field
Script

function AddProjectId(pProjectId) 
{
    var arrProjectIds = new Array();
    var strComma = '';
    csvProjectIds = $('#hdnInterestedProjectIds').val();
    csvProjectIds = $.trim(csvProjectIds);
    
    if (csvProjectIds != '') 
    {
        arrProjectIds = csvProjectIds.split(', ');
        lngArrLength = arrProjectIds.length;
    } else {
        lngArrLength = 0;
    }
    
    if (arrProjectIds.indexOf(pProjectId) != 0) {
        if (lngArrLength > 0)
            strComma = ', ';
        csvProjectIds = csvProjectIds + strComma + pProjectId;
    }
    
    $('#hdnInterestedProjectIds').val(csvProjectIds);
}

function RemoveProjectId(pProjectId) 
{
    csvProjectIds = $('#hdnInterestedProjectIds').val();
    csvNewProjectIds = '';
    arrProjectids = csvProjectIds.split(', ');
    arrNewProjectIds = new Array();
    lngArrLength = arrProjectids.length;
    
    for (i = 0; i < lngArrLength; i++) 
    {
        if (arrProjectids[i] != pProjectId) 
        {
            arrNewProjectIds.push(arrProjectids[i]);
        }
    }
    
    for (i = 0; i < arrNewProjectIds.length; i++) 
    {
        strComma = '';
        
        if ((csvNewProjectIds != '') && (arrNewProjectIds.length != (arrNewProjectIds.length - 1)))
            strComma = ', ';
        
        csvNewProjectIds = csvNewProjectIds + strComma + arrNewProjectIds[i];
    }
    
    $('#hdnInterestedProjectIds').val(csvNewProjectIds);
}
<input type=”hidden” name=”hdnInterestedProjectIds” id=”hdnInterestedProjectIds”/>

How to Split CSV into array

   csvProjectIds = '1,2,3,4';
   arrProjectIds = csvProjectIds.split(',');				

Output

     arrProjectIds[0] = 1
     arrProjectIds[1] = 2
     arrProjectIds[2] = 3
     arrProjectIds[3] = 4

How to Find Element is in Array

   csvProjectIds = '1,2,3,4';
   arrProjectIds = csvProjectIds.split(',');				
   alert(arrProjectIds.indexOf('1'));

Output

 0

The indexOf Returns 0 incase the element is in the array or
-1 if not in the array

What would be the Output

public class Main 
{	
  static
  {
    System.out.println("My Name is Mugil");
  }
}

OP: My Name is Mugil
followed by exception in Main

public class Main 
{	
  static
  {
    System.out.println("My Name is Mugil");
  }
	
  public static void main(String args[])
  {
    {
      System.out.println("What is your Name");	 
    }
  }
}

OP: My Name is Mugil
What is your Name

public class Main 
{	
  public static void main(String args[])
  {
    {
      System.out.println("What is your Name");
    }
   }
}

OP: What is your Name

4.What is the order they are processed

public class Main 
{	
 public static void main(String args[])
 {
   {
     ClassA objA = new ClassA();
     System.out.println("What is your Name"); 
   }
 }
}

class ClassA 
{
  static
  {
    System.out.println("I am in ClassA Static");
  }
	
  ClassA()
  {
    System.out.println("I am in ClassA Constrctor");  
  }

  {
    System.out.println("I am in ClassA");
  }
}

OP:I am in ClassA Static
I am in ClassA
I am in ClassA Constrctor
What is your Name

Static blocks are initiated at first followed by Constructor followed by classA and content in empty class.

5.How to Use Object to invoke function in Class

public class Main2
{
 public static void main(String args[])
 {	
   new A().showName();
 }
}

class A 
{
  public void showName()
  {
    System.out.println("Hi there");
  }
}

OP : Hi there

6.How to Find Class of object

  public class Main3 
  {
   public static void main(String[] args) 
   {
     ClasB objB = new ClasB();
     
     if(objB instanceof ClasB)
     {
       System.out.println(objB.getClass().getName());	
     }		
    }
  }

  class ClasB
  {	
  }

Toggle Class does not work by the way you think

.ClassA
{        
  color : green;
}

.ClassB
{
  color : red;
}
 $('document').ready(function(){
   $('.ClassA').on('click', function(){
      alert($(this).attr('class'));
      $(this).toggleClass('ClassB')
   }); 
 });
<div>Class A</div>
<div>Class B</div>

After the first Time ClassA is Applied When you click ClassA both ClassA and ClassB will be applied to the same tag.

The alert message will display output some thing link ClassA ClassB

Final Modifier Assures that a Reference variable cannot be referenced to a different Object

 public class Main 
 {	
   public int Age;
   public static void main(String args[])
   { 	
     final Main objMain = new Main();
     Main objMain2 = new Main();
     objMain = objMain2;
   }	
 }

OP:Generates a Exception
The final local variable objMain cannot be assigned.