Social Icons

Tuesday, January 29, 2013

Manual Testing Introduction and its Overview


What is Manual Testing ?
Testing is process execution of application in controlled manner with the intent of finding the errors. It is nothing but “Detection”.
The Quality Assurance involves through out the software development process to monitor and improve the process, making sure that agreed upon standards and procedures are followed and ensuring that problems are found and dealt with it.

It is oriented for “Prevention”.Solving problems is a high-visibility process; preventing problems is low-visibility.This is illustrated by an old parable.

Software Testing Def:
Testing is a process used to help identify the correctness, completeness and qualityof developed computer software. With that in mind, testing can never completely establish the correctness of computer software.

Software Industry:
In India itself, Software industry growth has been phenomenal.
IT field has enormously grown in the past 50 years.
IT industry in India is expected to touch 10,000 crores of which software share is dramatically increasing.

Software Crisis:
Software cost/schedules are grossly inaccurate.
Cost overruns of several times, schedule slippage’s by months, or even years are common.

Productivity of people has not kept pace with demand
Added to it is the shortage of skilled people.

Quality of software is than desired
Error rates of released software leave customer dissatisfied…Threatening the very business.

Purpose of Testing:
1. The main course of testing is to check for the existence of defects or errors in a program  or project or product, based up on some  predefined instructions or conditions.
2. The Purpose of Testing is to Analyze that the Product is according to Requirements.
3. To improve the quality of the product.
4. To satisfy the customers need.
5. To provide a Bug free software.

What is Software Quality:
Quality software is reasonably bug-free, delivered on time and within budget, meets requirements and/or expectations, and is maintainable.However, quality is a subjective term. It will depend on who the ‘customer’ is and their overall influence in the scheme of things.

A wide-angle view of the ‘customers’ of a software development project might include end-users, customer acceptance testers, customer contract officers, customer management, the development organisation’s management/accountants/testers/salespeople, future software maintenance engineers, stockholders, magazine reviewers, etc. 

Each type of ‘customer’ will have their own view on ‘quality’ - the accounting department might define quality in terms of profits while an end-user might define quality as user-friendly and bug-free. 

Quality Assurance:
“Quality Assurance” measures the quality of processes used to create a quality product.
Software Quality Assurance (‘SQA’ or ‘QA’) is the process of monitoring and improving all activities associated with software development, from requirements gathering, design and reviews to coding, testing and implementation.

It involves the entire software development process - monitoring and improving the process, making sure that any agreed-upon standards and procedures are followed, and ensuring that problems are found and dealt with, at the earliest possible stage. 

Unlike testing, which is mainly a ‘detection’ process, QA is ‘preventative’ in that it aims to ensure quality in the methods & processes – and therefore reduce the prevalence of errors in the software.

What’s the difference between QA and testing?
TESTING means “Quality Control”; and
QUALITY CONTROL measures the quality of a product; while
QUALITY ASSURANCE measures the quality of processes used to create a quality product.

Difference between static and dynamic testing?
  • Static testing is about prevention dynamic testing is about cure.
  • The static tools offer greater marginal benefits.
  • Static testing is many times more cost-effective than dynamic testing.
  • Static testing beats dynamic testing by a wide margin.
  • Static testing is more effective!
  • Static testing gives you comprehensive diagnostics for your code.
  • Static testing achieves 100 statement coverage in a relatively short time while dynamic testing often often achieves less than 50 statement coverage because dynamic testing finds bugs only in parts of the code that are actually executed.
  • Dynamic testing usually takes longer than static testing. Dynamic testing may involve running several test cases each of which may take longer than compilation.
  • Dynamic testing finds fewer bugs than static testing.
  • Static testing can be done before compilation while dynamic testing can take place only after compilation and linking.
  • Static testing can find all of the followings that dynamic testing cannot find: syntax errors code that is hard to maintain code that is hard to test code that does not conform to coding standards and ANSI violations.
  • Ya Dynamic testing invoves functional testing also.

Software Engineering Process
  • Consists of Three generic Phases:

Definition, Development, and Maintenance.
1. Definition (What)
Customer Contact, Planning, Requirement Analysis.
2. Development Phase (How)
Design, Coding, Testing.
3. Maintenance Phase (Change)
Correction, Adaptation, Enhancement, Reengineering.
4. Support Activities
Quality Assurance, Configuration Management.

                                                        NEXT

Monday, January 28, 2013

Types of Testing For an Application


MANUAL TESTING TYPES

Quality:  It is defined as the conformance to the customer specification.

Testing:  A Tester should suppose to identify the defects.

White box testing: Based on knowledge of the internal logic of an application’s code. Tests are based on coverage of code statements, branches, paths, conditions.

Test case:  Test case is a description of what to be tested, what data to be given and what actions to be done to check the actual result against the expected result.

Black box testing:  Not based on any knowledge of internal design or code. Tests are based on requirements and functionality.

Functionality testing:  Testing whether the functionality of the application is working or not and whether all the requirements have covered are not.

System testing:  The entire application tested according to the requirements.

Sanity testing:  Initial testing conducted on the application to check the proper behavior on the application.

Smoke testing:  Initial testing is conducted on over all application to check whether all the functionalities available to conduct detail testing on them.

Regression testing:  Retesting the bug after fixing or any modifications or enhancement done to the application and testing whether the existing functionalities are effecting to the privies functionalities or not.

Integration testing:  All the modules are integrated together and testing how modules are couple together and communication between the modules.
Usability testing: - Checking whether it is user friendliness or not.
i.              To check for the look and feel of application.
ii.             Where the end user can understand and can easily use the application.

User acceptance testing:  After all the bugs are fixed we have to test once again to make shore that the application meets the user requirements.

Severity:  how much the bug is effecting the application.

Priority:  When the bug is to be fixed.

Unit testing:  After completion of their reviews, programmer concentration on coding, to physically construct a soft ware. In this level, their will test every program through white box testing.

Recovery testing:  It is also known as reliability testing during this test, testing engineers validates that whether our application build change from abnormal state to normal state or not.

Compatibility testing:  It is also known as portability testing. During this test, testing engineer validates that whether our application build run on customer expectation platform or not.

Configuration testing: It is also known as hardware compatibility testing. During this test testing engineer validates that whether our application support different technology hardware devises or not.

                                                PREVIOUS                      NEXT

Friday, January 11, 2013

JAVA JDBC Questions with Answers For Freshers Paper -1



1. What is JDBC?
Ans: JDBC technology is an API (included in both J2SE and J2EE releases) that provides cross-DBMS connectivity to a wide range of SQL databases and access to other tabular data sources, such as spreadsheets or flat files. With a JDBC technology-enabled driver, you can connect all corporate data even in a heterogeneous environment

2. What are stored procedures?
Ans: A stored procedure is a set of statements/commands which reside in the database. The stored procedure is precompiled. Each Database has it’s own stored procedure language,

3. What is JDBC Driver ?
Ans: The JDBC Driver provides vendor-specific implementations of the abstract classes provided by the JDBC API. This driver is used to connect to the database.

4. What are the steps required to execute a query in JDBC?
Ans: First we need to create an instance of a JDBC driver or load JDBC drivers, then we need to register this driver with DriverManager class. Then we can open a connection. By using this connection , we can create a statement object and this object will help us to execute the query.

5. What is DriverManager ?
Ans: DriverManager is a class in java.sql package. It is the basic service for managing a set of JDBC drivers.

6. What is a ResultSet ?
Ans: A table of data representing a database result set, which is usually generated by executing a statement that queries the database.
A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.

7. What is Connection?
Ans: Connection class represents a connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.
A Connection object’s database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information is obtained with the getMetaData method.

8. What does Class.forName return?
Ans: A class as loaded by the classloader.

9. What is Connection pooling?
Ans: Connection pooling is a technique used for sharing server resources among requesting clients. Connection pooling increases the performance of Web applications by reusing active database connections instead of creating a new connection with every request. Connection pool manager maintains a pool of open database connections.

10. What are the different JDB drivers available?
Ans: There are mainly four type of JDBC drivers available. They are:
Type 1 :
 JDBC-ODBC Bridge Driver – A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers. Note that some ODBC native code and in many cases native database client code must be loaded on each client machine that uses this type of driver. Hence, this kind of driver is generally most appropriate when automatic installation and downloading of a Java technology application is not important. For information on the JDBC-ODBC bridge driver provided by Sun.

Type 2:
 Native API Partly Java Driver- A native-API partly Java technology-enabled driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS. Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.

Type 3:
 Network protocol Driver- A net-protocol fully Java technology-enabled driver translates JDBC API calls into a DBMS-independent net protocol which is then translated to a DBMS protocol by a server. This net server middleware is able to connect all of its Java technology-based clients to many different databases. The specific protocol used depends on the vendor. In general, this is the most flexible JDBC API alternative. It is likely that all vendors of this solution will provide products suitable for Intranet use. In order for these products to also support Internet access they must handle the additional requirements for security, access through firewalls, etc., that the Web imposes. Several vendors are adding JDBC technology-based drivers to their existing database middleware products.

Type 4: 
JDBC Net pure Java Driver – A native-protocol fully Java technology-enabled driver converts JDBC technology calls into the network protocol used by DBMSs directly. This allows a direct call from the client machine to the DBMS server and is a practical solution for Intranet access. Since many of these protocols are proprietary the database vendors themselves will be the primary source for this style of driver. Several database vendors have these in progress.

11. What is the fastest type of JDBC driver?
Ans: Type 4 (JDBC Net pure Java Driver) is the fastest JDBC driver. Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).

12. Is the JDBC-ODBC Bridge multi-threaded?
Ans: No. The JDBC-ODBC Bridge does not support multi threading. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won’t get the advantages of multi-threading.

13. What is cold backup, hot backup, warm backup recovery?
Ans: Cold backup means all these files must be backed up at the same time, before the database is restarted. Hot backup (official name is ‘online backup’ ) is a backup taken of each tablespace while the database is running and is being accessed by the users

14. What is the advantage of denormalization?
Ans: Data denormalization is reverse procedure, carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to replicate data for certain data.

15. How do you handle your own transaction ?
Ans: Connection Object has a method called setAutocommit ( boolean flag) . For handling our own transaction we can set the parameter to false and begin your transaction . Finally commit the transaction by calling the commit method.

JAVA JDBC Questions with Answers For Freshers Paper -2



1.What are the steps involved in establishing a JDBC connection?
Ans:  This action involves two steps: loading the JDBC driver and making the connection.

2. How can you load the drivers?
Ans:  Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it:
Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”);
Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ, you would load the driver with the following line of code:
Class.forName(”jdbc.DriverXYZ”);

3.What will Class.forName do while loading drivers?
Ans:   It is used to create an instance of a driver and register it with the
DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.

4.How can you make the connection?
Ans:   To establish a connection you need to have the appropriate driver connect to the DBMS.
The following line of code illustrates the general idea:
String url = “jdbc:odbc:Fred”;
Connection con = DriverManager.getConnection(url, “Fernanda”, “J8?);

5.How can you create JDBC statements and what are they?
Ans:  A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and then execute it, supplying the appropriate execute method with the SQL statement you want to send. For a SELECT statement, the method to use is executeQuery. For statements that create or modify tables, the method to use is executeUpdate. It takes an instance of an active connection to create a Statement object. In the following example, we use our Connection object con to create the Statement object
Statement stmt = con.createStatement();

6.How can you retrieve data from the ResultSet?
Ans:  JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to hold our results. The following code demonstrates declaring the ResultSet object rs.
ResultSet rs = stmt.executeQuery(”SELECT COF_NAME, PRICE FROM COFFEES”);
String s = rs.getString(”COF_NAME”);
The method getString is invoked on the ResultSet object rs, so getString() will retrieve (get) the value stored in the column COF_NAME in the current row of rs.

7.What are the different types of Statements?
Ans:  Regular statement (use createStatement method), prepared statement (use prepareStatement method) and callable statement (use prepareCall)

8.How can you use PreparedStatement? 
Ans:  This special type of statement is derived from class Statement.If you need a
Statement object to execute many times, it will normally make sense to use a PreparedStatement object instead. The advantage to this is that in most cases, this SQL statement will be sent to the DBMS right away, where it will be compiled. As a result, the PreparedStatement object contains not just an SQL statement, but an SQL statement that has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement’s SQL statement without having to compile it first.

9.PreparedStatement updateSales =con.prepareStatement("UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ?");

11.What does setAutoCommit do?
Ans:  When a connection is created, it is in auto-commit mode. This means that each individual SQL statement is treated as a transaction and will be automatically committed right after it is executed. The way to allow two or more statements to be grouped into a transaction is to disable auto-commit mode:
con.setAutoCommit(false);
Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly.
con.setAutoCommit(false);
PreparedStatement updateSales =
            con.prepareStatement( "UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ?");
updateSales.setInt(1, 50); updateSales.setString(2, "Colombian");
updateSales.executeUpdate();
PreparedStatement updateTotal =
            con.prepareStatement("UPDATE COFFEES SET TOTAL = TOTAL + ? WHERE COF_NAME LIKE ?");
updateTotal.setInt(1, 50);
updateTotal.setString(2, "Colombian");
updateTotal.executeUpdate();
con.commit();
con.setAutoCommit(true);

12.How do you call a stored procedure from JDBC?
Ans:  The first step is to create a CallableStatement object. As with Statement an and PreparedStatement objects, this is done with an open
Connection object. A CallableStatement object contains a call to a stored procedure.

13.CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");

14.ResultSet rs = cs.executeQuery();

15.How do I retrieve warnings?
Ans:  SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an
application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a
Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these
classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object:

16. SQLWarning warning = stmt.getWarnings();
if (warning != null)
{
System.out.println("n---Warning---n");
                   while (warning != null)
                 {
                         System.out.println("Message: " + warning.getMessage());
                          System.out.println("SQLState: " + warning.getSQLState());
                          System.out.print("Vendor error code: ");
                         System.out.println(warning.getErrorCode());
                         System.out.println("");
                           warning = warning.getNextWarning();
             }
    }

17 How can you move the cursor in scrollable result sets?
Ans:  One of the new features in the JDBC 2.0 API is the ability to move a result set’s cursor backward as well as forward. There are also methods that let you move the cursor to a particular row and check the position of the cursor.
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet srs = stmt.executeQuery(”SELECT COF_NAME, PRICE FROM COFFEES”);

The first argument is one of three constants added to the ResultSet API to indicate the type of a ResultSet object: TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE , and TYPE_SCROLL_SENSITIVE. 

The second argument is one of two ResultSet constants for specifying whether a result set is read-only or updatable: CONCUR_READ_ONLY and CONCUR_UPDATABLE.

 The point to remember here is that if you specify a type, you must also specify whether it is read-only or updatable. Also, you must specify the type first, and because both parameters are of type int , the compiler will not complain if you switch the order. 

Specifying the constant TYPE_FORWARD_ONLY creates a nonscrollable result set, that is, one in which the cursor moves only forward. If you do not specify any constants for the type and updatability of a ResultSet object, you will automatically get one that is TYPE_FORWARD_ONLY and CONCUR_READ_ONLY.

18. What’s the difference between TYPE_SCROLL_INSENSITIVE , and TYPE_SCROLL_SENSITIVE?
Ans:  You will get a scrollable ResultSet object if you specify one of these ResultSet constants.The difference between the two has to do with whether a result set reflects changes that are made to it while it is open and whether certain methods can be called to detect these changes. Generally speaking, a result set that is TYPE_SCROLL_INSENSITIVE does not reflect changes made while it is still open and one that is TYPE_SCROLL_SENSITIVE does. 

All three types of result sets will make changes visible if they are closed and then reopened:
32.       Statement stmt =
33.                   con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
34.       ResultSet srs =
35.                   stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");
36.       srs.afterLast();
37.       while (srs.previous())
38.       {
39.                   String name = srs.getString("COF_NAME");
40.                   float price = srs.getFloat("PRICE");
41.                   System.out.println(name + " " + price);
42.       }

43.       How to Make Updates to Updatable Result Sets?
Ans:  Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java programming language rather than having to send an SQL command. But before you can take advantage of this capability, you need to create a ResultSet object that is updatable. In order to do this, you supply the ResultSet constant CONCUR_UPDATABLE to the createStatement method.

44.       Connection con =
45.                   DriverManager.getConnection("jdbc:mySubprotocol:mySubName");
46.       Statement stmt =
47.                   con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
48.       ResultSet uprs =
            stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");


Java Interview Questions With Answers For Freshers Paper-3



1. What is transient variable?
 Ans: Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the value of the variable can't be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null.
   
2.  Name the container which uses Border Layout as their default layout?
 Ans:  Containers which uses Border Layout as their default are: window, Frame and Dialog classes.
    
3. What do you understand by Synchronization?
 Ans:  Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access one resource at a time. In non synchronized multithreaded application, it is possible for one thread to modify a shared object while another thread is in the process of using or updating the object's value. Synchronization prevents such type of data corruption.
E.g. Synchronizing a function:
public synchronized void Method1 () {
     // Appropriate method-related code.
}
E.g. Synchronizing a block of code inside a function:
public myFunction (){
    synchronized (this) {
            // Synchronized code here.
         }
}
  
4. What is Collection API?
 Ans: The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces.
Example of classes: HashSet, HashMap, ArrayList, LinkedList, TreeSet and TreeMap.
Example of interfaces: Collection, Set, List and Map.
   
5.What is similarities/difference between an Abstract class and Interface?
 Ans: Differences are as follows:
•           Interfaces provide a form of multiple inheritance. A class can extend only one other class.
•           Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
•           A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
•           Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual class. Abstract classes are fast.
Similarities:
•           Neither Abstract classes nor Interface can be instantiated.
 
6.  How to define an Abstract class?
 Ans: A class containing abstract method is called Abstract class. An Abstract class can't be instantiated.
Example of Abstract class:
abstract class testAbstractClass {
    protected String myString;
    public String getMyString() {
        return myString;
        }
    public abstract string anyAbstractFunction();
}
     
7. How to define an Interface?
 Ans: In Java Interface defines the methods but does not implement them. Interface can include constants. A class that implements the interfaces is bound to implement all the methods defined in Interface.
Emaple of Interface:

public interface sampleInterface {
    public void functionOne();

    public long CONSTANT_ONE = 1000;
}
   
8. Explain the user defined Exceptions?
 Ans: User defined Exceptions are the separate Exception classes defined by the user for specific purposed. An user defined can created by simply sub-classing it to the Exception class. This allows custom exceptions to be generated (using throw) and caught in the same way as normal exceptions.
Example:
class myCustomException extends Exception {
     // The class simply has to exist to be an exception
}
  
9. Explain the new Features of JDBC 2.0 Core API?
 Ans: The JDBC 2.0 API includes the complete JDBC API, which includes both core and Optional Package API, and provides inductrial-strength database computing capabilities.
New Features in JDBC 2.0 Core API:
•           Scrollable result sets- using new methods in the ResultSet interface allows programmatically move the to particular row or to a position relative to its current position
•           JDBC 2.0 Core API provides the Batch Updates functionality to the java applications.
•           Java applications can now use the ResultSet.updateXXX methods.
•           New data types - interfaces mapping the SQL3 data types
•           Custom  mapping of user-defined types (UTDs)
•           Miscellaneous features, including performance hints, the use of character streams, full precision for java.math.BigDecimal values, additional security, and support for time zones in date, time, and timestamp values.
    
10. Explain garbage collection?
 Ans:  Garbage collection is one of the most important features of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program can’t directly free the object from memory; instead it is the job of the garbage collector to automatically free the objects that are no longer referenced by a program. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. I Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected.
   
11. How you can force the garbage collection?
 Ans:  Garbage collection automatic process and can't be forced. 
 
12. What is OOPS?
Answer: OOP is the common abbreviation for Object-Oriented Programming. 
 
13. Describe the principles of OOPS.
 Ans: There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation. 
 
14.  Explain the Encapsulation principle.
 Ans:  Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper. 
 
15. Explain the Inheritance principle.
 Ans: Inheritance is the process by which one object acquires the properties of another object. 
 
16. Explain the Polymorphism principle.
Answer: The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as as general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as "one interface, multiple methods". 
 
17.  Explain the different forms of Polymorphism.
 Ans: From a practical programming viewpoint, polymorphism exists in three distinct forms in Java:
•           Method overloading
•           Method overriding through inheritance
•           Method overriding through the Java interface

18. What are Access Specifiers available in Java?
 Ans: Access Specifiers are keywords that determine the type of access to the member of a class. These are:
•           Public
•           Protected
•           Private
•           Defaults
 
19.  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 table lists 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
 
20.  Read the following program:
public class test {
public static void main(String [] args) {
    int x = 3;
    int y = 1;
   if (x = y)
     System.out.println("Not equal");
  else
    System.out.println("Equal");
 }
}

21. What is the result?
   A. The output is “Equal”
   B. The output in “Not Equal”
   C. An error at " if (x = y)" causes compilation to fall.
   D. The program executes but no output is show on console.
 Ans: C

22. what is the class variables?
 Ans: When we create a number of objects of the same class, then each object will share a common copy of variables. That means that there is only one copy per class, no matter how many objects are created from it. Class variables or static variables are declared with the static keyword in a class, but mind it that it should be declared outside outside a class. These variables are stored in static memory. Class variables are mostly used for constants, variable that never change its initial value. Static variables are always called by the class name. This variable is created when the program starts i.e. it is created before the instance is created of class by using new operator and gets destroyed when the programs stops. The scope of the class variable is same a instance variable. The class variable can be defined anywhere at class level with the keyword static. It initial value is same as instance variable. When the class variable is defined as int then it's initial value is by default zero, when declared boolean its default value is false and null for object references. Class variables are associated with the class, rather than with any object. 

23.  What is the difference between the instanceof and getclass, these two are same or not ?
 Ans:  instanceof is a operator, not a function while getClass is a method of java.lang.Object class. Consider a condition where we use
if(o.getClass().getName().equals("java.lang.Math")){ }
This method only checks if the classname we have passed is equal to java.lang.Math. The class java.lang.Math is loaded by the bootstrap ClassLoader. This class is an abstract class. This class loader is responsible for loading classes. Every Class object contains a reference to the ClassLoader that defines. getClass () method returns the runtime class of an object. It fetches the java instance of the given fully qualified type name. The code we have written is not necessary, because we should not compare getClass.getName (). The reason behind it is that if the two different class loaders load the same class but for the JVM, it will consider both classes as different classes so, we can't compare their names. It can only gives the implementing class but can't compare a interface, but instanceof operator can.
The instanceof operator compares an object to a specified type. We can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface. We should try to use instanceof operator in place of getClass() method. Remember instanceof operator and getClass are not same. Try this example; it will help you to better understand the difference between the two.
Interface one{
}

Class Two implements one {
}
Class Three implements one {
}

public class Test {
public static void main(String args[]) {
one test1 = new Two();
one test2 = new Three();
System.out.println(test1 instanceof one); //true
System.out.println(test2 instanceof one); //true
System.out.println(Test.getClass().equals(test2.getClass())); //false
}
}

24. Is Iterator a Class or Interface? What is its use?
 Ans:  Iterator is an interface which is used to step through the elements of a Collection.
Question : When you declare a method as abstract method ?
Answer : When i want child class to implement the behavior of the method.        
Question : Can I call a abstract method from a non abstract method ?
Answer : Yes, We can call a abstract method from a Non abstract method in a Java abstract class        
Question : What is the difference between an Abstract class and Interface in Java ? or can you explain when you use Abstract classes ?
Answer : Abstract classes let you define some behaviors; they force your subclasses to provide others. These abstract classes will provide the basic funcationality of your applicatoin, child class which inherited this class will provide the funtionality of the abstract methods in abstract class. When base class calls this method, Java calls the method defined by the child class.
•           An Interface can only declare constants and instance methods, but cannot implement default behavior.
•           Interfaces provide a form of multiple inheritance. A class can extend only one other class.
•           Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
•           A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
•           Interfaces are slow as it requires extra indirection to find corresponding method in the actual class. Abstract classes are fast