Java Interview Question And Answer | Java Interview Question And Answer For Fresher | Core Java Interview Question And Answare | Set 11

1.What is serialization ?
 Ans: Serialization is the process of writing complete state of java object into output stream, that stream can be file or byte array or stream associated with TCP/IP socket.

2.What does the Serializable interface do ?
 Ans: Serializable is a tagging interface; it prescribes no methods. It serves to assign the Serializable data type to the tagged class and to identify the class as one which the developer has designed for persistence. ObjectOutputStream serializes only those objects which implement this interface.

3.How do I serialize an object to a file ?
 Ans: To serialize an object into a stream perform the following actions:
          1. Open one of the output streams, for example FileOutputStream.
          2. Chain it with the ObjectOutputStream - Call the method writeObject() providing the instance of a Serializable object as an argument.
          3.Close the streams
         Java Code
         ---------

         try{
         fOut= new FileOutputStream("c:\\raj.ser");
         out = new ObjectOutputStream(fOut);
         out.writeObject(employee); //serializing
         System.out.println("An employee is serialized into c:\\emp.ser");

          } catch(IOException e){
       4.printStackTrace();

4.What are synchronized methods and synchronized statements?
 Ans: Synchronized methods are methods that are used to control access to a method or an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

5.Can you give few examples of final classes defined in Java API?
 Ans: java.lang.String, java.lang.Math are final classes.

6.How is final different from finally and finalize()?
 Ans: final is a modifier which can be applied to a class or a method or a variable. final class can't be inherited, final method can't be overridden and final variable can't be changed.

         finally is an exception handling code section which gets executed whether an exception is raised or not by the try block code segment.

         finalize() is a method of Object class which will be executed by the JVM just before garbage collecting object to give a final chance for resource releasing activity.

7.What is the importance of static variable?
 Ans: static variables are class level variables where all objects of the class refer to the same variable. If one object changes the value then the change gets reflected in all the objects.

8.Can we declare a static variable inside a method?
 Ans: Static varaibles are class level variables and they can't be declared inside a method. If declared, the class will not compile.

9.What is an Abstract Class and what is it's purpose?
 Ans: A Class which doesn't provide complete implementation is defined as an abstract class. Abstract classes enforce abstraction.

10.Can a abstract class be declared final?
 Ans: Not possible. An abstract class without being inherited is of no use and hence will result in compile time error.

11.What is use of a abstract variable?

 Ans: Variables can't be declared as abstract. only classes and methods can be declared as abstract.

12.Can you create an object of an abstract class?
 Ans: Not possible. Abstract classes can't be instantiated.


Previous Next


:: Click the links below for similar type Questions and answers ::

Java Interview Question And Answer | Java Interview Question And Answer For Fresher | Core Java Interview Question And Answare | Set 10

1.What methods java providing for Thread communications ?
 Ans: Java provides three methods that threads can use to communicate with each other: wait, notify, and notifyAll.

2.Can Java object be locked down for exclusive use by a given thread?
 Ans: Yes. You can lock an object by putting it in a "synchronized" block. The locked object is inaccessible to any thread other than the one that explicitly claimed it.

3.Can each Java object keep track of all the threads that want to exclusively access to it?
 Ans: Yes. Use Thread.currentThread() method to track the accessing thread.

4.Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?
 Ans: Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.

5.What invokes a thread's run() method?
 Ans: After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

6.What are three ways in which a thread can enter the waiting state?
 Ans: A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

7.What's new with the stop(), suspend() and resume() methods in JDK 1.2?
 Ans: The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.

8.What is synchronization and why is it important?
 Ans: With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often causes dirty data and leads to significant errors.

9.What is synchronized keyword? In what situations you will Use it?


 Ans: Synchronization is the act of serializing access to critical sections of code. We will use this keyword when we expect multiple threads to access/modify the same data. To understand synchronization we need to look into thread execution manner.

          Threads may execute in a manner where their paths of execution are completely independent of each other. Neither thread depends upon the other for assistance. For example, one thread might execute a print job, while a second thread repaints a window. And then there are threads that require synchronization, the act of serializing access to critical sections of code, at various moments during their executions. For example, say that two threads need to send data packets over a single network connection. Each thread must be able to send its entire data packet before the other thread starts sending its data packet; otherwise, the data is scrambled. This scenario requires each thread to synchronize its access to the code that does the actual data-packet sending. If you feel a method is very critical for business that needs to be executed by only one thread at a time (to prevent data loss or corruption), then we need to use synchronized keyword.

10.Name Component subclasses that support painting ?
 Ans: The Canvas, Frame, Panel, and Applet classes support painting.


Previous Next


:: Click the links below for similar type Questions and answers ::

Java Interview Question And Answer | Java Interview Question And Answer For Fresher | Core Java Interview Question And Answare | Set 09

1.What is a static method?
 Ans: A static method is a method that belongs to the class rather than any object of the class and doesn't apply to an object or even require that any objects of the class have been instantiated.

2.What is a protected method?
 Ans: A protected method is a method that can be accessed by any method in its package and inherited by any subclass of its class.

3.What is the difference between a static and a non-static inner class?
 Ans: A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.

4.What is the purpose of the System class?
 Ans: The purpose of the System class is to provide access to system resources.

5.What is the purpose of the finally clause of a try-catch-finally statement?
 Ans: The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.

6.What is difference between Path and Classpath?
 Ans: Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files.

7.What is thread?
 Ans: A thread is an independent path of execution in a system.

8.What is multi-threading?
 Ans: Multi-threading means various threads that run in a system.

9.How does multi-threading take place on a computer with a single CPU?
 Ans: The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.

10.How to create a thread in a program?
 Ans: You have two ways to do so. First, making your class "extends" Thread class. Second, making your class "implements" Runnable interface. Put jobs in a run() method and call start() method to start the thread.

11.How can we tell what state a thread is in ?

 Ans: Prior to Java 5, isAlive() was commonly used to test a threads state. If isAlive() returned false the thread was either new or terminated but there was simply no way to differentiate between the two.

        Starting with the release of Tiger (Java 5) you can now get what state a thread is in by using the getState() method which returns an Enum of Thread.States.


Previous Next


:: Click the links below for similar type Questions and answers ::

PHP Interview Question And Answare | PHP Interview Question And Answare for Fresher | Set 08

1.What is the functionality of MD5 function in PHP?
 Ans: string md5(string) .It calculates the MD5 hash of a string. The hash is a 32-character hexadecimal number.

2.Will comparison of string “10″ and integer 11 work in PHP?
 Ans: Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.

3.What’s the difference between accessing a class method via -> and via ::?
 Ans: :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.

4.How can I load data from a text file into a table?
 Ans: The MySQL provides a LOAD DATA INFILE command. You can load data from a file. Great tool but you need to make sure that:
            a) Data must be delimited
            b) Data fields must match table columns correctly

5.How can we know the number of days between two given dates using MySQL?
 Ans: Use DATEDIFF()
          SELECT DATEDIFF(NOW(),’2006-07-01′);

6.How can we change the name of a column of a table?
 Ans: This will change the name of column:
          ALTER TABLE table_name CHANGE old_colm_name new_colm_name

7.How can we change the data type of a column of a table?
 Ans: This will change the data type of a column:
         ALTER TABLE table_name CHANGE colm_name same_colm_name [new data type]

8.What is the difference between GROUP BY and ORDER BY in SQL?
 Ans: To sort a result, use an ORDER BY clause.
            The most general way to satisfy a GROUP BY clause is to scan the whole table and create a new temporary table where all rows from each group are consecutive, and then use this temporary table to discover groups and apply aggregate functions (if any).
            ORDER BY [col1],[col2],…[coln]; Tells DBMS according to what columns it should sort the result. If two rows will have the same value in col1 it will try to sort them according to col2 and so on. GROUP BY [col1],[col2],…[coln]; Tells DBMS to group (aggregate) results with same value of column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if you want to count all items in group, sum all values or view average.

9.What are the MySQL database files stored in system ?
 Ans: Data is stored in name.myd
          Table structure is stored in name.frm
           Index is stored in name.myi

10.How can we encrypt and decrypt a data presented in a table using MySQL?
 Ans: You can use functions: AES_ENCRYPT() and AES_DECRYPT() like:
            AES_ENCRYPT(str, key_str)
            AES_DECRYPT(crypt_str, key_str)

11.What is the difference between htmlentities() and htmlspecialchars()?
 Ans: htmlspecialchars() – Convert some special characters to HTML entities (Only the most widely used)
          htmlentities() – Convert ALL special characters to HTML entities


Previous Next


:: Click the links below for similar type Questions and answers ::

Set 01 | Set 02  | Set 03  | Set 04  | Set 05  | Set 06  | Set 07  | Set 08  | Set 09 

PHP Interview Question And Answare | PHP Interview Question And Answare for Fresher | Set 07

1.How can we destroy the session, how can we unset the variable of a session?
 Ans: session_unregister — Unregister a global variable from the current session
         session_unset — Free all session variables    

2.How can we destroy the cookie?
 Ans: Set the cookie in past.    

3.How many ways we can pass the variable through the navigation between the pages?
 Ans: GET/QueryString
          POST

4.What is the difference between ereg_replace() and eregi_replace()?
 Ans: eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.eregi_replace() function is identical to ereg_replace()
except that this ignores case distinction when matching alphabetic characters.   

5.What are the different functions in sorting an array?
 Ans: Sort()
          arsort(),
          asort(),
          ksort(),
          natsort(),
          natcasesort(),
          rsort(),
          usort(),
          array_multisort(),
          uksort().

6.What is the difference between ereg_replace() and eregi_replace()?
 Ans: eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.

7.How do I find out the number of parameters passed into function9. ?
 Ans: func_num_args() function returns the number of parameters passed in.

8.What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?
 Ans: In MySQL, the default table type is MyISAM.Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type.

         The '.frm' file stores the table definition.
         The data file has a '.MYD' (MYData) extension.
         The index file has a '.MYI' (MYIndex) extension,

9.If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?
 Ans: 100, it’s a reference to existing variable.

10.What is the difference between CHAR and VARCHAR data types?
 Ans: CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. For example, “Hello!” will be stored as “Hello! ” in CHAR(10) column.
     
          VARCHAR is a variable length data type. VARCHAR(n) will take only the required storage for the actual number of characters entered to that column. For example, “Hello!” will be stored as “Hello!” in VARCHAR(10) column.

11.How can we encrypt and decrypt a data present in a mysql table using mysql?
 Ans: AES_ENCRYPT() and AES_DECRYPT()


Previous Next


:: Click the links below for similar type Questions and answers ::

Set 01 | Set 02  | Set 03  | Set 04  | Set 05  | Set 06  | Set 07  | Set 08  | Set 09 

PHP Interview Question And Answare | PHP Interview Question And Answare for Fresher | Set 06

1.What is the difference between the functions unlink and unset?
 Ans: unlink() deletes the given file from the file system.
         unset() makes a variable undefined.  

2.How can we register the variables into a session?
 Ans: $_SESSION[’name’] = “Mizan”;   

3.How can we get the properties (size, type, width, height) of an image using PHP image functions?
 Ans: To know the Image type use exif_imagetype () function
          To know the Image size use getimagesize () function
          To know the image width use imagesx () function
          To know the image height use imagesy() function t  
 
4.How can we get the browser properties using PHP?

 Ans:  By using $_SERVER['HTTP_USER_AGENT'] variable.
  
5.What is the maximum size of a file that can be uploaded using PHP and how can we change this?
 Ans: By default the maximum size is 2MB. and we can change the following setup at php.iniupload_max_filesize = 2M   

6.How can we increase the execution time of a PHP script?
 Ans: by changing the following setup at php.inimax_execution_time = 30; Maximum execution time of each script, in seconds   

7.How can we optimize or increase the speed of a MySQL select query?
 Ans: 1.first of all instead of using select * from table1, use select column1, column2, column3.. from table1
          2.Look for the opportunity to introduce index in the table you are querying.
          3.use limit keyword if you are looking for any specific number of rows from the result set.

8.How can we register the variables into a session?
 Ans: session_register($session_var);

          $_SESSION['var'] = 'value';
   
9.What is the difference between characters \023 and \x23?
 Ans: The first one is octal 23, the second is hex 23.

10.How many ways can we get the value of current session id?
 Ans: session_id() returns the session id for the current session.
   


Previous Next


:: Click the links below for similar type Questions and answers ::

Set 01 | Set 02  | Set 03  | Set 04  | Set 05  | Set 06  | Set 07  | Set 08  | Set 09 

PHP Interview Question And Answare | PHP Interview Question And Answare for Fresher | Set 05

1.How can we find the number of rows in a table using MySQL?
 Ans: Use this for mysql
        >SELECT COUNT(*) FROM table_name;   
 
2.How can we find the number of rows in a result set using PHP?

 Ans: $result = mysql_query($sql, $db_link);
          $num_rows = mysql_num_rows($result);
          echo "$num_rows rows found";  
 
3.How many ways we can we find the current date using MySQL?

Ans: SELECT CURDATE();
         CURRENT_DATE() = CURDATE()
         for time use
         SELECT CURTIME();
         CURRENT_TIME() = CURTIME()

4.How can we find the number of rows in a result set using PHP?
 Ans: Here is how can you find the number of rows in a result set in PHP:
          $result = mysql_query($any_valid_sql, $database_link);
          $num_rows = mysql_num_rows($result);
          echo “$num_rows rows found”

5.What types of images that PHP supports ?
 Ans: Using imagetypes() function to find out what types of images are supported in your PHP engine.imagetypes() – Returns the image types supported.
         This function returns a bit-field corresponding to the image formats supported by the version of GD linked into PHP. The following bits are returned, IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM

6.What Is a Persistent Cookie?
 Ans: A persistent cookie is a cookie which is stored in a cookie file permanently on the browser's computer. By default, cookies are created as temporary cookies which stored only in the browser's memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:
       1.Temporary cookies can not be used for tracking long-term information.
       2.Persistent cookies can be used for tracking long-term information.
       3.Temporary cookies are safer because no programs other than the browser can access them.
       4.Persistent cookies are less secure because users can open cookie files see the cookie values.

7.What does a special set of tags <?= and ?> do in PHP?
 Ans: The output is displayed directly to the browser. 

8.What is the difference between mysql_fetch_object and mysql_fetch_array?
 Ans: MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array

9.How can I execute a PHP script using command line?
 Ans: Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program.
         Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

10.I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
 Ans: PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.


Previous Next


:: Click the links below for similar type Questions and answers ::

Set 01 | Set 02  | Set 03  | Set 04  | Set 05  | Set 06  | Set 07  | Set 08  | Set 09 

PHP Interview Question And Answare | PHP Interview Question And Answare for Fresher | Set 04

1.How can we know the number of days between two given dates using MySQL?
 Ans: Use DATEDIFF()

        SELECT DATEDIFF(NOW(),'2006-07-01');

2.How can we change the name of a column of a table?

 Ans: This will change the name of column:

         ALTER TABLE table_name CHANGE old_colm_name new_colm_name

3.What is the functionality of the function strstr and stristr?
 Ans: strstr() returns part of a given string from the first occurrence of a given substring to the end of the string. For example: strstr(“user@example.com”,”@”) will return “@example.com”.
        stristr() is idential to strstr() except that it is case insensitive.

4.What is the difference between ereg_replace() and eregi_replace()?
 Ans: eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.

5.How can we submit a form without a submit button?
 Ans: If you don’t want to use the Submit button to submit a form, you can use normal hyper links to submit a form. But you need to use some JavaScript code in the URL of the link. For example:
         <a href=”javascript: document.myform.submit();”>Submit Me</a> Why doesn’t the following code print the newline properly? <?php $str = ‘Hello, there.\nHow are you?\nThanks for visiting techpreparation’; print $str; ?>

        Because inside the single quotes the \n character is not interpreted as newline, just as a sequence of two characters – \ and n

6.What’s the special meaning of __sleep and __wakeup?
 Ans: __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them

7.How do you define a constant?
 Ans: Via define() directive, like define ("MYCONSTANT", 100);

8.What are the differences between require and include, include_once?
Ans: require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.

       But require() and include() will do it as many times they are asked to do.

9.What is meant by urlencode and urldecode?
Ans: urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode("10.00%") will return "10%2E00%25". URL encoded strings are safe to be used as part of URLs.
      urldecode() returns the URL decoded version of the given string.

10.How To Get the Uploaded File Information in the Receiving Script? 
 Ans: Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:
       $_FILES[$fieldName]['name'] - The Original file name on the browser system.
       $_FILES[$fieldName]['type'] - The file type determined by the browser.
       $_FILES[$fieldName]['size'] - The Number of bytes of the file content.
       $_FILES[$fieldName]['tmp_name'] - The temporary filename of the file in which the uploaded file was stored on the server.
       $_FILES[$fieldName]['error'] - The error code associated with this file upload.

       The $fieldName is the name used in the <INPUT TYPE=FILE, NAME=fieldName>.


Previous Next


:: Click the links below for similar type Questions and answers ::

Set 01 | Set 02  | Set 03  | Set 04  | Set 05  | Set 06  | Set 07  | Set 08  | Set 09 

PHP Interview Question And Answare | PHP Interview Question And Answare for Fresher | Set 03

1.What is the use of obj_start()?
 Ans: Its initializing the object buffer, so that the whole page will be first parsed (instead of parsing in parts and thrown to browser gradually) and stored in output buffer so that after complete page is executed, it is thrown to the browser once at a time.

2.Difference between mysql_connect and mysql_pconnect?
 Ans: There is a good page in the php manual on the subject, in short mysql_pconnect() makes a persistent connection to the database which means a SQL link that do not close when the execution of your script ends. mysql_connect()provides only for the databasenewconnection while using mysql_pconnect , the function would first try to find a (persistent) link that's already open with the same  host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection...
      the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use.

3.What is the difference between session_register and $_session?
 Ans: session_register() is used for register one or more global variables with the current session. While   $_SESSION[] array is used for storing one or more variables with in the current session.

4.What is the use of sprintf() function?
 Ans: The sprintf() function writes a formatted string to a variable.

         The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc.

5.Difference between mysql_connect and mysql_pconnect?
 Ans: mysql_connect()provides only for the databasenewconnection while using mysql_pconnect , the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection...
        the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use.

6.Explain about the $_GET variable of PHP?
 Ans: $_GET is used to collect or use values from a form with a method="GET".

         we can use it like EX : $_GET["name"]
         here, name is name/id of form element like text book for identification of them. but with the use of $_GET values can not be exceed up to 100 character.

7.How can we submit a form without a submit button?

 Ans: If you don't want to use the Submit button to submit a form, you can use normal hyper links to submit a form. But you need to use some JavaScript code in the URL of the link.

8.What is the functionality of MD5 function in PHP?

 Ans: string md5(string)
          It calculates the MD5 hash of a string. The hash is a 32-character hexadecimal number.

9.How can I load data from a text file into a table?
 Ans: The MySQL provides a LOAD DATA INFILE command. You can load data from a file. Great tool but you need to make sure that:
         a) Data must be delimited
         b) Data fields must match table columns correctly

10.Who is Known as Father of PHP?
  Ans: Rasmus Lerdorf


Previous Next


:: Click the links below for similar type Questions and answers ::

Set 01 | Set 02  | Set 03  | Set 04  | Set 05  | Set 06  | Set 07  | Set 08  | Set 09 

PHP Interview Question And Answare | PHP Interview Question And Answare for Fresher | Set 02

1.How many ways we can pass the variable through the navigation between the pages?
 Ans: At least 3 ways:
         1. Put the variable into session in the first page, and get it back from session in the next page.
         2. Put the variable into cookie in the first page, and get it back from the cookie in the next page.
         3. Put the variable into a hidden form field, and get it back from the form in the next page.

2.What’s the difference between md5(), crc32() and sha1() crypto on PHP?
 Ans: The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.

3.What is the maximum length of a table name, a database name, or a field name in MySQL?
 Ans: Database name: 64 characters

         Table name: 64 characters

         Column name: 64 characters

4.How many values can the SET function of MySQL take?
 Ans: MySQL SET function can take zero or more values, but at the maximum it can take 64 values.

5.What are the other commands to know the structure of a table using MySQL commands except EXPLAIN command?
 Ans: DESCRIBE table_name;

6.How can we find the number of rows in a table using MySQL?
 Ans: Use this for MySQL

         SELECT COUNT(*) FROM table_name;

7.How many ways we can we find the current date using MySQL?
 Ans: SELECT CURDATE();
          SELECT CURRENT_DATE();
          SELECT CURTIME();
          SELECT CURRENT_TIME();

8.Give the syntax of GRANT commands?
 Ans: The generic syntax for GRANT is as following

          GRANT [rights] on [database] TO [username@hostname] IDENTIFIED BY [password]

         Now rights can be:
          a) ALL privilages
          b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc.

        We can grant rights on all databse by usingh *.* or some specific database by database.* or a specific table by database.table_name.

9.What are encryption functions in PHP?
 Ans: CRYPT()
          MD5()

10.What is the difference between htmlentities() and htmlspecialchars()?
 Ans: htmlspecialchars() - Convert some special characters to HTML entities (Only the most widely used)
        htmlentities() - Convert ALL special characters to HTML entities


Previous Next


:: Click the links below for similar type Questions and answers ::

Set 01 | Set 02  | Set 03  | Set 04  | Set 05  | Set 06  | Set 07  | Set 08  | Set 09 

PHP Interview Question And Answare | PHP Interview Question And Answare for Fresher | Set 01

1.What's PHP ?
 Ans: The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.

2.What Is a Session?
 Ans: A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests.

        There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.
        Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.

3.What is meant by PEAR in php?
 Ans: PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wizard, and packing the strength and experience of PHP users into a nicely organised OOP library. PEAR also provides a command-line interface that can be used to automatically install "package

4.What is the difference between $message and $$message?
 Ans: $message is a simple variable whereas $$message is a reference variable.
         Example:
          $user = 'bob'is equivalent to

          $holder = 'user';
          $$holder = 'bob';

5.What are the differences between DROP a table and TRUNCATE a table?
 Ans: DROP TABLE table_name - This will delete the table and its data.

          TRUNCATE TABLE table_name - This will delete the data of the table, but not the table definition.

6.What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
 Ans: mysql_fetch_array – Fetch a result row as an associative array and a numeric array.
          mysql_fetch_object – Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows
          mysql_fetch_row() – Fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0

7.How do you call a constructor for a parent class?
 Ans: parent::constructor($value)

8.WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?
 Ans: Here are three basic types of runtime errors in PHP:

          1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although you can change this default behavior.

          2. Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.

          3. Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP's default behavior is to display them to the user when they take place.

9.What’s the special meaning of __sleep and __wakeup?
 Ans:  __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

10.What are the different functions in sorting an array?
 Ans: Sorting functions in PHP:
            asort()
            arsort()
            ksort()krsort()
            uksort()
            sort()
            natsort()


Previous Next


:: Click the links below for similar type Questions and answers ::

Set 01 | Set 02  | Set 03  | Set 04  | Set 05  | Set 06  | Set 07  | Set 08  | Set 09 

Java Interview Question And Answer | Java Interview Question And Answer For Fresher | Core Java Interview Question And Answare | Set 08

1.What is the purpose of a statement block?
 Ans: A statement block is used to organize a sequence of statements as a single statement group

2.What is a Java package and how is it used?
 Ans: A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.

3.What modifiers may be used with a top-level class?
 Ans: A top-level class may be public, abstract, or final.

4.What are wrapped classes?
 Ans: Wrapped classes are classes that allow primitive types to be accessed as objects.

5.Describe the wrapper classes in Java ?
 Ans: Wrapper class is wrapper around a primitive data type. An instance of a wrapper class contains, or wraps, a primitive value of the corresponding type.
    
        Following are the lists of the primitive types and the corresponding wrapper classes:
     
          Primitive     Wrapper
          boolean      java.lang.Boolean
          byte            java.lang.Byte
          char            java.lang.Character
          double        java.lang.Double
          float            java.lang.Float
          int               java.lang.Integer
          long            java.lang.Long
          short           java.lang.Short
          void            java.lang.Void

6.What are different types of inner classes ?
 Ans: Inner classes nest within other classes. A normal class is a direct member of a package. Inner classes, which became available with Java 1.1, are four types:
      
        1.Static member classes: A static member class is a static member of a class. Like any other static method, a static member class has access to all static methods of the parent, or top-level, class.
        2.Member Classes: A member class is also defined as a member of a class. Unlike the static variety, the member class is instance specific and has access to any and all methods and members, even the parent's this reference.
        3.Local Classes: Local Classes declared within a block of code and these classes are visible only within the block.
        4.Anonymous Classes: These type of classes does not have any name and its like a local class

7.Can a class be declared as static?
 Ans: No a class cannot be defined as static. Only a method, a variable or a block of code can be declared as static.

8.When will you define a method as static?
 Ans: When a method needs to be accessed even before the creation of the object of the class then we should declare the method as static.

9.What are the restriction imposed on a static method or a static block of code?
Ans: A static method should not refer to instance variables without creating an instance and cannot use "this" operator to refer the instance.

10.I want to print "Hello" even before main() is executed. How will you acheive that?
Ans:  Print the statement inside a static block of code. Static blocks get executed when the class gets loaded into the memory and even before the creation of an object. Hence it will be executed before the main() method. And it will be executed only once.


Previous Next


:: Click the links below for similar type Questions and answers ::

Java Interview Question And Answer | Java Interview Question And Answer For Fresher | Core Java Interview Question And Answare | Set 07

1.What is the purpose of declaring a variable as final?
 Ans: A final variable's value can't be changed. final variables should be initialized before using them.

2.What is the impact of declaring a method as final?
 Ans: A method declared as final can't be overridden. A sub-class can't have the same method signature with a different implementation.

3.I don't want my class to be inherited by any other class. What should i do?
 Ans: You should declared your class as final. But you can't define your class as final, if it is an abstract class. A class declared as final can't be extended by any other class.

4.What is finalize() method?
 Ans: finalize () method is used just before an object is destroyed and can be called just prior to garbage collection.

5.What are Transient and Volatile Modifiers?
 Ans: Transient: The transient modifier applies to variables only and it is not stored as part of its object’s Persistent state. Transient variables are not serialized.
     
        Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by  volatile can be changed unexpectedly by other parts of the program.

6.What is final, finalize() and finally?
 Ans: final : final keyword can be used for class, method and variables. A final class cannot be subclassed and it prevents other programmers from subclassing a secure class to invoke insecure methods. A final method can’t be overridden. A final variable can’t change from its initialized value.
         finalize() : finalize() method is used just before an object is destroyed and can be called just prior to garbage collection.
         finally : finally, a key word used in exception handling, creates a block of code that will be executed after a try/catch block has completed and before the code following the try/catch block. The finally block will execute whether or not an exception is thrown.
        
         For example, if a method opens a file upon exit, then you will not want the code that closes the file to be bypassed by the exception-handling mechanism. This finally keyword is designed to address this contingency.

7.What is UNICODE?
 Ans: Unicode is used for internal representation of characters and strings and it uses 16 bits to represent each other.

8.What is the difference between a public and a non-public class?
 Ans: A public class may be accessed outside of its package.
        A non-public class may not be accessed outside of its package.

9.To what value is a variable of the boolean type automatically initialized?
 Ans: The default value of the boolean type is false.
 
10.What is the difference between the prefix and postfix forms of the ++ operator?
 Ans: The prefix form performs the increment operation and returns the value of  the increment operation.

        The postfix form returns the current value all of the expression and then performs the increment operation on that value.
   

Previous Next


:: Click the links below for similar type Questions and answers ::

Java Interview Question And Answer | Java Interview Question And Answer For Fresher | Core Java Interview Question And Answare | Set 06

1.What is the argument of main() method?
 Ans: main() method accepts an array of String object as argument.

2.Can a main() method be overloaded?
 Ans: Yes. You can have any number of main() methods with different method signature and implementation in the class.

3.Can a main() method be declared final?
 Ans: Yes. Any inheriting class will not be able to have it's own default main() method.

4.Does the order of public and static declaration matter in main() method?
 Ans: No. It doesn't matter but void should always come before main().

5.What are the static fields & static Methods ?
 Ans: If a field or method defined as a static, there is only one copy for entire class, rather than one copy for each instance of class. static method cannot access non-static field or call non-static method

6.What are the Final fields & Final Methods ?
 Ans: Fields and methods can also be declared final.
         Final method: A final method cannot be overridden in a subclass.
         Final field: A final field is like a constant: once it has been given a value, it cannot be assigned to again.

7.What is user-defined exception in java ?
 Ans: User-defined expectations are the exceptions defined by the application developer which are errors related to specific application. Application Developer can define the user defined exception by inherited the Exception class as shown below. Using this class we can throw new exceptions for this we have  use throw keyword .
     
8.Can a class declared as private be accessed outside it's package?
 Ans: Not possible.

9.Can a class be declared as protected?
 Ans: A class can't be declared as protected. only methods can be declared as protected.

10.What is the access scope of a protected method?
 Ans: A protected method can be accessed by the classes within the same package or by the subclasses of the class in any package.

Previous Next


:: Click the links below for similar type Questions and answers ::

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes