Thursday, June 13, 2013

Eager and Lazy Loading


The JVM must be able to load JVM class files. The JVM class loader loads referenced JVM classes that have not already been linked to the runtime system. Classes are loaded implicitly because:

  • The initial class file - the class file containing the public static void main(String args[]) method - must be loaded at startup.
  • Depending on the class policy adopted by the JVM, classes referenced by this initial class can be loaded in either a lazy or eager manner.

An eager class loader loads all the classes comprising the application code at startup. 

Lazy class loaders wait until the first active use of a class before loading and linking its class file.

The first active use of a class occurs when one of the following occurs:
  • An instance of that class is created
  • An instance of one of its subclasses is initialized
  • One of its static fields is initialized

Certain classes, such as ClassNotFoundException, are loaded implicitly by the JVM to support execution. You may also load classes explicitly using thejava.lang.Class.forName() method in the Java™ API, or through the creation of a user class loader.


Friday, June 29, 2012

Communicate with Multiple USB / Serial Port


When requirement will come to listen more than one USB / Serial Port in Java, make some changes in Java/jdk/jre/lib/javax.comm.properties file. By default the Application will listen only one port at a time but after make the changes simultaneously it'll listen multiple ports. changes need to be done: open the above mentioned file add the following line in particular section # Paths to server-side serial port devices serpath0 = /dev/ttyS0 #added.... serpath1 = /dev/ttyS1 serpath2 = /dev/ttyACM0 serpath3 = /dev/ttyACM1

Friday, May 18, 2012

Low Graphic Mode Error in Ubuntu



If the low graphic mode error comes in Ubuntu:
sudo apt-get update
sudo apt-get -d install --reinstall gdm
sudo apt-get remove --purge gdm
sudo apt-get install gdm
sudo apt-get install Ubuntu-desktop
sudo dpkg-reconfigure -phigh xserver-xorg
sudo reboot

how to start the wireless internet if the machine run in low graphic mode
when the GUI is unable to load press ALT+F2 key and open other terminal
login with credentials
type startx
type iwlist scan (for searching the network, if wireless is down then type sudo ifconfig up)
for registering with network type iwconfig essid (like interface=>ra0  essid=>“MyNetwork”).
If the above command not work then type nm-applet

Sunday, April 15, 2012

Set the Java_Home and Maven M2_HOME

Write the below line in /etc/bash.bashrc

// user jdk path
JAVA_HOME=/home/test/java/jdk1.6.0_30
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
PATH=$PATH:JAVA_HOME

//user maven path (expecting extract in /usr/local/apache-maven/)
M2_HOME=/usr/local/apache-maven/apache-maven-3.0.4
export M2_HOME
M2=$M2_HOME/bin
export PATH=$M2:$PATH

Monday, February 14, 2011

Find Files By Access, Modification Date / Time Under Linux or UNIX

I don't remember where I saved pdf and text files under Linux. I have downloaded files from the Internet a few months ago. How do I find my pdf or text files?

You need to use the find command. Each file has three time stamps, which record the last time that certain operations were performed on the file:

[a] access (read the file's contents) - atime

[b] change the status (modify the file or its attributes) - ctime

[c] modify (change the file's contents) - mtime

You can search for files whose time stamps are within a certain age range, or compare them to other time stamps.

You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago. For example to find file in last 2 months (60 days) you need to use -mtime +60 option.

-mtime +60 means you are looking for a file modified 60 days ago.
-mtime -60 means less than 60 days.
-mtime 60 If you skip + or - it means exactly 60 days.
So to find text files that were last modified 60 days ago, use
$ find /home/you -iname "*.txt" -mtime -60 -print

Display content of file on screen that were last modified 60 days ago, use
$ find /home/you -iname "*.txt" -mtime -60 -exec cat {} \;

Count total number of files using wc command
$ find /home/you -iname "*.txt" -mtime -60 | wc -l

You can also use access time to find out pdf files. Following command will print the list of all pdf file that were accessed in last 60 days:
$ find /home/you -iname "*.pdf" -atime -60 -type -f

List all mp3s that were accessed exactly 10 days ago:
$ find /home/you -iname "*.mp3" -atime 10 -type -f

There is also an option called -daystart. It measure times from the beginning of today rather than from 24 hours ago. So, to list the all mp3s in your home directory that were accessed yesterday, type the command
$ find /home/you -iname "*.mp3" -daystart -type f -mtime 1

Where,

-type f - Only search for files and not directories
-daystart option

The -daystart option is used to measure time from the beginning of the current day instead of 24 hours ago. Find out all perl (*.pl) file modified yesterday, enter:

find /nas/projects/mgmt/scripts/perl -mtime 1 -daystart -iname "*.pl"
You can also list perl files that were modified 8-10 days ago, enter:
To list all of the files in your home directory tree that were modified from two to four days ago, type:

find /nas/projects/mgmt/scripts/perl -mtime 8 -mtime -10 -daystart -iname "*.pl"
-newer option

To find files in the /nas/images directory tree that are newer than the file /tmp/foo file, enter:

find /etc -newer /tmp/foo
You can use the touch command to set date timestamp you would like to search for, and then use -newer option as follows

touch --date "2010-01-05" /tmp/foo
# Find files newer than 2010/Jan/05, in /data/images
find /data/images -newer /tmp/foo

Monday, December 6, 2010

instance of in JAVA

Sometimes, knowing the type of an object during run time is useful. For example, you might have one thread of execution that generates various types of objects, and another thread that processes these objects. In this situation, it might be useful for the processing thread to know the type of each object when it receives it. Another situation in which knowledge of an object's type at run time is important involves casting. In Java, an invalid cast causes a run-time error. Many invalid casts can be caught at compile time. However, casts involving class hierarchies can produce invalid casts that can be detected only at run time. For example, a superclass called A can produce two subclasses, called B and C. Thus, casting a B object into type A or casting a C object into type A is legal, but casting a B object into type C (or vice versa) isn't legal. Because an object of type A can refer to objects of either B or C, how can you know, at run time, what type of object is actually being referred to before attempting the cast to type C? It could be an object of type A, B, or C. If it is an object of type B, a run-time exception will be thrown. Java provides the run-time operator instanceof to answer this question.
The instanceof operator has this general form:

object instanceof type

Here, object is an instance of a class, and type is a class type. If object is of the specified type or can be cast into the specified type, then the instanceof operator evaluates to true. Otherwise, its result is false. Thus, instanceof is the means by which your program can obtain run-time type information about an object.

The following program demonstrates instanceof:

// Demonstrate instanceof operator.
class A {
int i, j;
}
class B {
int i, j;
}
class C extends A {
int k;
}
class D extends A {
int k;
}
class InstanceOf {
public static void main(String args[]) {
A a = new A();
B b = new B();
C c = new C();
D d = new D();
if(a instanceof A)
System.out.println("a is instance of A");
if(b instanceof B)
System.out.println("b is instance of B");
if(c instanceof C)
System.out.println("c is instance of C");
if(c instanceof A)
System.out.println("c can be cast to A");
if(a instanceof C)
System.out.println("a can be cast to C");
System.out.println();
// compare types of derived types
A ob;
ob = d; // A reference to d
System.out.println("ob now refers to d");
if(ob instanceof D)
System.out.println("ob is instance of D");
System.out.println();
ob = c; // A reference to c
System.out.println("ob now refers to c");
if(ob instanceof D)
System.out.println("ob can be cast to D");
else
System.out.println("ob cannot be cast to D");
if(ob instanceof A)
System.out.println("ob can be cast to A");
- 230 -
System.out.println();
// all objects can be cast to Object
if(a instanceof Object)
System.out.println("a may be cast to Object");
if(b instanceof Object)
System.out.println("b may be cast to Object");
if(c instanceof Object)
System.out.println("c may be cast to Object");
if(d instanceof Object)
System.out.println("d may be cast to Object");
}
}

The output from this program is shown here:

a is instance of A
b is instance of B
c is instance of C
c can be cast to A
ob now refers to d
ob is instance of D
ob now refers to c
ob cannot be cast to D
ob can be cast to A
a may be cast to Object
b may be cast to Object
c may be cast to Object
d may be cast to Object

The instanceof operator isn't needed by most programs, because, generally, you know the type of object with which you are working. However, it can be very useful when you're writing generalized routines that operate on objects of a complex class hierarchy

Private final methods

If one class have one private final method so what happen if another class is try to overridden the same method in another class:
for reference check the below example

class Raptor{
private final void test(){
System.out.println("i am final of Raptor");
}
}

class Hawk extends Raptor {
public final void test(){
System.out.println("i am the final of Hawk");
}

public static void main(String[] args) {
Hawk hawk_obj = new Hawk();
hawk_obj.test();
}
}

Result:
compile and program may run the output is "i am the final of Hawk", because the test function is private and it'll never available in another class so the final method never be override in another class rule is not applicable.

Java Constructor don't have return type:

Constructor never return in Java and if you see the constructor have return type, so it's not a constructor it's a method with the same name of class...
class Bird {
public String Bird() {
return ("I am bird");
}
public static void main (String args[]){
Bird b - new Bird(); // object creation and assign the Reference to variable
b.Bird(); // now the function call
}

Good use of static, constructor and init blocks

class Bird {
{
System.out.print("b1 ");
}

public Bird() {
System.out.print("b2 ");
}
}

class Raptor extends Bird {
static {
System.out.print("r1 ");
}

public Raptor() {
System.out.print("r2 ");
}

{
System.out.print("r3 ");
}
static {
System.out.print("r4 ");
}
}

class Hawk extends Raptor {
public static void main(String[] args) {
System.out.print("pre ");
new Hawk();

System.out.println("hawk ");
/*Raptor rap = new Raptor();
if (rap instanceof Raptor){
System.out.println("i m working");
}*/
}
}


Guess what is the answer: r1 r4 pre b1 b2 r3 r2 hawk
static always related with class not with instance so they run when the class initialized, next turn for constructor but here we have init blocks so first the init blocks have run then the constructor come in picture from top to bottom, super class init => constructor => child class init => constructor...

Friday, August 13, 2010

Serialization (Store the Objects) and Deserialization (Restore the objects) in Java

Serialization:
Objects have a state and behavior.
Behavior (methods) lives Class (in memory term Stack), state (instance variable) lives with in each objects (Heap), serialization is the way to save the state of object.
If you are writing a game, you're gonna need a Save/Restore Game Feature.

Deserialization: the whole point of serializing an object is so that you can restore it back to the original state at some later date, in a different run of JVM (which might not even be the same JVM that was running at the time the object was serialized).
Deserialization is lot like serialization in reverse.


import java.io.*;
import java.lang.*;

class Model implements Serializable {//mandatory to implement serializable interface(contains not any method).
int id;

String name;

public Integer getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;

}
}

public class SampleProgram {

public static void main(String args[]) {
Model model = new Model();
model.setId(10);
model.setName("aayush");

System.out.println("the out put before serialize " + model.getId()
+ " " + model.getName() + " i am going to finish");
try {

System.out.println("Serialize start");
//create a file or use a existing file.
FileOutputStream file = new FileOutputStream("inpu.ser");
//connect the file like from source to destination
ObjectOutputStream obj = new ObjectOutputStream(file);
//writing object
obj.writeObject(model);
//closing
obj.close();

}
catch (Exception ex) {

ex.printStackTrace();

}
//declare reference value null
model = null;

try {
System.out.println("i am going to restore");
//restoring start
ObjectInputStream restore = new ObjectInputStream(
new FileInputStream("inpu.ser"));
//reading object with type cast
Model model_restore = (Model) restore.readObject();
//closing
restore.close();
//output
System.out.println(model_restore.getName());

}
catch (Exception exe) {
exe.printStackTrace();
}

}
}

Friday, August 6, 2010

Is OuterClass able to access the InnerClass Methods and Variables (Vice-Versa)?

In Main method both classes are unable to access the variables and methods but outside the Main method InnerClass has a right to access the OuterClass variables and Methods (even private also), but what about the OuterClass?
OuterClass has also right to access the InnerClass Variables and Methods...

How : innerclass_object and outerclass_obect
These two objects on the heap have a special bond, The inner can use the outer's variable (and vice-versa).

See the example:


public class OuterClass {
private String str;

// create the instance of innerclass...
InnerClass obj = new InnerClass();

private class InnerClass {
int i;

public int getI() {

// intialize the outerclass private variable
str = "aayushjain";
System.out.println(str);
return i;
}

public void setI(int i) {
this.i = i;

}

}

public void trial() {
System.out.println("hello i from outerclass");

// call the Inner Class methods
obj.setI(100);
System.out.println(obj.getI());
}

public static void main(String args[]) {
OuterClass obj_out = new OuterClass();

// unbale to access the innerclass methods.....
/* obj_out.getI(); */

OuterClass.InnerClass obj_inner = obj_out.new InnerClass();

obj_inner.setI(10);
System.out.println(obj_inner.getI());

// unable to access the outerclass methods..
/* obj_inner.trial(); */
obj_out.trial();

}
}

Thursday, August 5, 2010

How to Bulk file Rename in Linux

How to Bulk Rename Files in Linux (Terminal or GUI)

If you have a directory of files that you would like to bulk rename, you can use the rename command from the terminal.

The syntax for the rename command is:

rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

-v means "verbose" and it will output the names of the files when it renames them. It is a good idea to use this feature so you can keep track of what is being renamed. It is also a good idea to do a test run with -n which will do a test run where it won't rename any files, but will show you a list of files that would be renamed.

Here is an example of the rename command:

rename -n ’s/\.htm$/\.html/’ *.htm

The -n means that it's a test run and will not actually change any files. It will show you a list of files that would be renamed if you removed the -n. In the case above, it will convert all files in the current directory from a file extension of .htm to .html.

If the output of the above test run looked ok then you could run the final version:

rename -v ’s/\.htm$/\.html/’ *.htm

The -v is optional, but it's a good idea to include it because it is the only record you will have of changes that were made by the rename command as shown in the sample output below:

$ rename -v 's/\.htm$/\.html/' *.htm
3.htm renamed as 3.html
4.htm renamed as 4.html
5.htm renamed as 5.html

The tricky part in the middle is a Perl substitution with regular expressions, highlighted below:

rename -v ’s/\.htm$/\.html/’ *.htm

Tip: There is an intro to Perl regular expression here

Basically the "s" means substitute. The syntax is s/old/new/ — substitute the old with the new.

A . (period) has a special meaning in a regular expression — it means "match any character". We don't want to match any character in the example above. It should match only a period. The backslash is a way to "escape" the regular expression meaning of "any character" and just read it as a normal period.

The $ means the end of the string. \.htm$ means that it will match .htm but not .html.

It's fairly basic — substitute .htm with .html:

's/\.htm$/\.html/'

The last part of the command, highlighted below, means to apply the rename command to every file that ends with .htm (the * is a wildcard).

rename -v ’s/\.htm$/\.html/’ *.htm

Other Example
Maybe you have a digital camera that takes photos with filenames something like 00001234.JPG, 00001235.JPG, 00001236.JPG. You could make the .JPG extension lowercase with the following command executed from the same directory as the images:

rename -v 's/\.JPG$/\.jpg/' *.JPG

Here is the output of the above command:

$ rename -v 's/\.JPG$/\.jpg/' *.JPG
00001111.JPG renamed as 00001111.jpg
00001112.JPG renamed as 00001112.jpg
00001113.JPG renamed as 00001113.jpg

That is simple enough, as it is similar to the .html example earlier. You could also bulk rename them with something descriptive at the beginning like this:

Tip: Before trying more complicated renaming like in the example below, do a test run with the -n option as described at the beginning of this tutorial.

rename -v 's/(\d{8})\.JPG$/BeachPics_$1\.jpg/' *.JPG

or you can combine the two commands like below example

find -name '*.JPG' | rename -v 's/(\d{8})\.JPG$/BeachPics_$1\.jpg/' *.JPG

Friday, July 30, 2010

Java Static Function

Q. Can we override the Static function in Java ?
A. Yes we can override the Static function in Java see the sample recipe

class Sample implements Over {

public static int simple(int a, int b) {
int c = a + b;
return c;
}
}
class Overloading extends Sample {

public static int simple(int a, int b) {
int c = a * b;
return c;

}
public static void main(String[] args) {
        Sample sam = new Sample(22, 90);
        Overloading obj = new Overloading();
          obj.simple(10,20); // here the sub class function call
         sam..simple(10,20); // here the super class function call
}
}


Saturday, February 6, 2010

Type Hint in PHP

Type Hint in PHP.
Day by day PHP introduces new strong OOPS concepts earlier i used the Type Hinting (earlier it's available in Hot cup of Java) in type hint we restrict the input type parameter like this:

class DAO{function add(Model $model){}}
here we restrict the input parameter is object type & also object of Model class.
but yet it's have some limitation, available for object and array not for integer, float etc

Sunday, January 24, 2010

PHP Unit Test Case

How to Install PHPUnit Test ?
1. First Create the environment variable of pear:
check where u install the php /usr/local/php/bin/
2. open the file : /etc/environment
3. add the path in PATH
4. logout (otherwise environment not reflect)
5. sudo /usr/local/php/bin/pear channel-discover pear.phpunit.de
6. if after the above command he is asking for upgrade the pear:
7. use this command : sudo usr/local/php/bin/pear upgrade PEAR
8. sudo usr/local/php/bin/pear install phpunit/PHPUnit

now start programming.



Thursday, December 24, 2009

Reliance Broadband+, Tata Photon+ Detects in Ubuntu 9, Detect Plug2surf

Hello,
Sometime it's become a big problem for Ubuntu user to detect the USB broadband device, in some forums everybody suggest KPP installer or some changes in wv.conf file, this is a big myth follow a simple steps and enjoy...:

Plug in your device to computer:

1. Enable your networking.
2. In networking option choose mobile boradband
3. Click ADD and welcome screen appear
4 click forward choose country then service provider
5. if service provider not in list choose another (Reliance not in list).
6. click on summary and apply change then enter / edit the user name & password
or phone number (if required) then save & connect
7. See in the right side of top panel one image start moving and give u welcome message....enjoy internet it works

Monday, December 21, 2009

What is FEDERATED Engine / how use to it.

what is FEDERATED engine.

The FEDERATED storage engine is available beginning with MySQL 5.0.3. It is a storage engine that accesses data in tables of remote databases rather than in local tables.

How to Use FEDERATED Tables

The procedure for using FEDERATED tables is very simple. Normally, you have two servers running, either both on the same host or on different hosts. (It is possible for aFEDERATED table to use another table that is managed by the same server, although there is little point in doing so.)

First, you must have a table on the remote server that you want to access by using aFEDERATED table. Suppose that the remote table is in the federated database and is defined like this:

CREATE TABLE test_table ( id INT(20) NOT NULL AUTO_INCREMENT, name VARCHAR(32) NOT NULL DEFAULT '', other INT(20) NOT NULL DEFAULT '0', PRIMARY KEY (id), INDEX name (name), INDEX other_key (other) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

The example uses a MyISAM table, but the table could use any storage engine.

Next, create a FEDERATED table on the local server for accessing the remote table:

CREATE TABLE federated_table ( id INT(20) NOT NULL AUTO_INCREMENT, name VARCHAR(32) NOT NULL DEFAULT '', other INT(20) NOT NULL DEFAULT '0', PRIMARY KEY (id), INDEX name (name), INDEX other_key (other) ) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://fed_user@remote_host:9306/federated/test_table';

(Before MySQL 5.0.13, use COMMENT rather than CONNECTION.)

The basic structure of this table should match that of the remote table, except that theENGINE table option should be FEDERATED and the CONNECTION table option is a connection string that indicates to the FEDERATED engine how to connect to the remote server.

Note:

You can improve the performance of a FEDERATED table by adding indexes to the table on the host, even though the tables will not actually be created locally. The optimization will occur because the query sent to the remote server will include the contents of the WHERE clause will be sent to the remote server and executed locally. This reduces the network traffic that would otherwise request the entire table from the server for local processing.

The FEDERATED engine creates only the test_table.frm file in the federateddatabase.

The remote host information indicates the remote server to which your local server connects, and the database and table information indicates which remote table to use as the data source. In this example, the remote server is indicated to be running asremote_host on port 9306, so there must be a MySQL server running on the remote host and listening to port 9306.

Tuesday, November 10, 2009

Using PHP Namespaces

PHP 5.3 introduces a much requested feature for object-oriented programmers: namespaces. At the time of this writing, version 5.3 of PHP was in development, but is planned on being released in the near future.

One of the purposes object-oriented programming is to remove ambiguous development and data access items. This basically means identifying common functionality and creating the most reusable framework possible, typically in the form of classes. When creating this functionality, you will begin to have issues with naming conventions and narrowing down functionality even further. To resolve this scoping issue, namespaces allow you to contain those bits of code even more.


It seems that PHP will be going with a similar namespace setup as C++. In order to declare a namespace, you will use the “namespace” keyword.

PHP
  1. namespace MyNamespace;
  2. class Test {
  3. public function hello() {
  4. echo ‘Hello’;
  5. }
  6. }
  7. ?>

The declaration above simply states that all elements contained in this script will be referenced with the “MyNamespace” namespace. You will need to place the “namespace” declaration at the top of the script.

In order to use a portion of functionality within this script, we will use the Scope Resolution Operator and instantiate the “Test” class.

  1. // Requiring the namespace file is a good indication that you don’t need to use namespaces, but this is only an example!
  2. require(‘the_file_above.php’);
  3. $test = new MyNamespace::Test();
  4. $test->hello();
  5. // Prints ‘hello’
  6. ?>

Monday, October 19, 2009

LAMP - Apache, PHP, MySQL Installation easy steps

Some like it binary some like compiling, I am amongst the compiling ones..
here are some easy steps that I usually follow to compile Apache, PHP to my machine.

  1. Apache
    1. ./configure --prefix=/usr/local/apache2.2.6 --enable-so --enable-proxy --enable-rewrite --enable-expires --enable-headers --enable-deflate --enable-ssl
    2. sudo make
    3. sudo make install
    4. cd /usr/local
    5. ln -s apache2.2.6 apache
    6. cd
  2. PHP
    1. ./configure --prefix=/usr/local/php5.2.5 --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-pdo-mysql --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib
    2. sudo make
    3. sudo make install
    4. cd /usr/local
    5. ln -s php5.2.5 php
    6. Configure Apache httpd.conf for PHP module
      1. LoadModule php5_module modules/libphp5.so
      2. AddType application/x-httpd-php .php .phtml

Wednesday, October 7, 2009

Advanced Php Questions...

1. What is Indexing and how we create describe his merits and demerits.

Indexes are created on a per column basis. If you have a table with the columns: name, age, birthday and employeeID and want to create an index to speed up how long it takes to find employeeID values in your queries, then you would need to create an index for employeeID. When you create this index, MySQL will build a lookup index where employeeID specific queries can be run quickly. However, the name, age and birthday queries would not be any faster.

Indexes are something extra that you can enable on your MySQL tables to increase performance,c but they do have some downsides. When you create a new index MySQL builds a separate block of information that needs to be updated every time there are changes made to the table. This means that if you are constantly updating, inserting and removing entries in your table this could have a negative impact on performance.

If you are creating a new MySQL table you can specify a column to index by using the INDEX term as we have below. We have created two fields: name and employeeID (index).
CREATE TABLE employee_records (name VARCHAR(50),employeeID INT,
INDEX (employeeID) );

2. Upload the file use Ajax.

3. How to save the other image in ur server dynamically.

4. If we have a n number of category in table, how we find the main parent of the last node.

5. Describe the sequence of mysql query,
(a) primary->subquery->sub-sub query
(b) primary-> primary-> subquery.
(c) sub-subquery->subquery-> primary.

6. if a table contain a salary of employee, how following query return a result.
select salary form employee_table order by salary desc.
select salary form employee_table order by salary 2 desc.

give the answer.

7. what is NDB & how it configure?

8. If one table holds the data of employee, so what is return by following query after remove the parenthesis.

select (salary*2)+(3/salary)*(1.3+salary) from employee.

9. what is session and describe its default life time & how we increase it?

Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site.

A visitor accessing your web site is assigned a unique id, the so-called session id. This is either stored in a cookie on the user side or is propagated in the URL.

default time is 1440 seconds and after make a changes in php.ini session life time change.

10. difference between Innodb and Myissam table engine?
Innodb support the foreign key constraints myissam not.
Innodb support the rollback and commit myissam not.
myissam is default Engine of mysql it occupies less memory in compare of Innodb.

11. Diff between Primary key and Unique key.
primary must be integer and notnull, and only 1 primary in key in one table, many unique key assign in one table and not limitation of integer and not null.

12. MySql Injection

13. Crontab
cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris.
Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.

14.how we find a size of file
filesize($filename);

15. what is union n mysql explain with example;
SQL UNION allows you to combine two or more result sets from select statements into a single result set. The usage of using SQL UNION is as follows:

SELECT statement UNION [DISTINCT | ALL] SELECT statement UNION [DISTINCT | ALL]

The column list of each individual SELECT statement must have the same data type. By default the UNION removes all duplicated rows from the result set even if you don’t explicit using DISTINCT after the UNION keyword. If you use UNION ALL explicitly, the duplicated rows will remain in the result set. Let’s practice with couples of examples which use SQL UNION. Suppose you want to combine customers and employees into one, you just perform the following query:
SELECT customerNumber id, contactLastname name FROM customers UNION SELECT employeeNumber id,firstname name FROM employees
Here is the excerpt of the output
    id  name          
------ ---------------
103 Schmitt
112 King
114 Ferguson
119 Labrune
121 Bergulfsen
124 Nelson
125 Piestrzeniewicz
128 Keitel
129 Murphy
131 Lee
In order to use ORDER BY to sort the result you have to use it after the last SELECTstatement. It would be the best to parenthesize all the SELECT statements and place ORDER BY after the last one. Suppose we use the want to sort the combination of employees and customers in the query above we can do as follows:
(SELECT customerNumber id,contactLastname name FROM customers) UNION (SELECT employeeNumber id,firstname name FROM employees) ORDER BY name,id
First it orders the result set by name and then by id What if we don’t use alias for each column in the SELECT statement? MySQL uses the column names in the first SELECTstatement as the label of the result therefore you can rewrite the query above as follows:
(SELECT customerNumber, contactLastname FROM customers) UNION (SELECT employeeNumber, firstname FROM employees) ORDER BY contactLastname, customerNumber
or you can also use the column position in the ORDER BY clause like following query
(SELECT customerNumber, contactLastname FROM customers) UNION (SELECT employeeNumber,firstname FROM employees) ORDER BY 2, 1