Java Interview Questions


  1. What is the diffrence between an Abstract class and Interface ?
  2. What is user defined exception ?
  3. What do you know about the garbate collector ?
  4. What is the difference between C++ & Java ?
  5. Explain RMI Architecture?
  6. How do you communicate in between Applets & Servlets ?
  7. What is the use of Servlets ?
  8. What is JDBC? How do you connect to the Database ?
  9. In an HTML form I have a Button which makes us to open another page in 15 seconds. How will do you that ?
  10. What is the difference between Process and Threads ?
  11. What is the difference between RMI & Corba ?
  12. What are the services in RMI ?
  13. How will you initialize an Applet ?
  14. What is the order of method invocation in an Applet ?
  15. When is update method called ?
  16. How will you pass values from HTML page to the Servlet ?
  17. Have you ever used HashTable and Dictionary ?
  18. How will you communicate between two Applets ?
  19. What are statements in JAVA ?
  20. What is JAR file ?
  21. What is JNI ?
  22. What is the base class for all swing components ?
  23. What is JFC ?
  24. What is Difference between AWT and Swing ?
  25. Considering notepad/IE or any other thing as process, What will happen if you start notepad or IE 3 times? Where 3 processes are started or 3 threads are started ?
  26. How does thread synchronization occurs inside a monitor ?
  27. How will you call an Applet using a Java Script function ?
  28. Is there any tag in HTML to upload and download files ?
  29. Why do you Canvas ?
  30. How can you push data from an Applet to Servlet ?
  31. What are 4 drivers available in JDBC ?
  32. How you can know about drivers and database information ?
  33. If you are truncated using JDBC, How can you know ..that how much data is truncated ?
  34. And What situation , each of the 4 drivers used ?
  35. How will you perform transaction using JDBC ?
  36. In RMI, server object first loaded into the memory and then the stub reference is sent to the client ? or whether a stub reference is directly sent to the client ?
  37. Suppose server object is not loaded into the memory, and the client request for it , what will happen?
  38. What is serialization ?
  39. Can you load the server object dynamically? If so, what are the major 3 steps involved in it ?
  40. What is difference RMI registry and OSAgent ?
  41. To a server method, the client wants to send a value 20, with this value exceeds to 20,. a message should be sent to the client ? What will you do for achieving for this ?
  42. What are the benefits of Swing over AWT ?
  43. Where the CardLayout is used ?
  44. What is the Layout for ToolBar ?
  45. What is the difference between Grid and GridbagLayout ?
  46. How will you add panel to a Frame ?
  47. What is the corresponding Layout for Card in Swing ?
  48. What is light weight component ?
  49. Can you run the product development on all operating systems ?
  50. What is the webserver used for running the Servlets ?
  51. What is Servlet API used for conneting database ?
  52. What is bean ? Where it can be used ?
  53. What is difference in between Java Class and Bean ?
  54. Can we send object using Sockets ?
  55. What is the RMI and Socket ?
  56. How to communicate 2 threads each other ?
  57. What are the files generated after using IDL to Java Compilet ?
  58. What is the protocol used by server and client ?
  59. Can I modify an object in CORBA ?
  60. What is the functionality stubs and skeletons ?
  61. What is the mapping mechanism used by Java to identify IDL language ?
  62. Diff between Application and Applet ?
  63. What is serializable Interface ?
  64. What is the difference between CGI and Servlet ?
  65. What is the use of Interface ?
  66. Why Java is not fully objective oriented ?
  67. Why does not support multiple Inheritance ?
  68. What it the root class for all Java classes ?
  69. What is polymorphism ?
  70. Suppose If we have variable ' I ' in run method, If I can create one or more thread each thread will occupy a separate copy or same variable will be shared ?
  71. In servlets, we are having a web page that is invoking servlets username and password ? which is cheks in the database ? Suppose the second page also If we want to verify the same information whethe it will connect to the database or it will be used previous information?
  72. What are virtual functions ?
  73. Write down how will you create a binary Tree ?
  74. What are the traverses in Binary Tree ?
  75. Write a program for recursive Traverse ?
  76. What are session variable in Servlets ?
  77. What is client server computing ?
  78. What is Constructor and Virtual function? Can we call Virtual funciton in a constructor ?
  79. Why we use OOPS concepts? What is its advantage ?
  80. What is the middleware ? What is the functionality of Webserver ?
  81. Why Java is not 100 % pure OOPS ? ( EcomServer )
  82. When we will use an Interface and Abstract class ?
  83. What is an RMI?
  84. How will you pass parameters in RMI ? Why u serialize?
  85. What is the exact difference in between Unicast and Multicast object ? Where we will use ?
  86. What is the main functionality of the Remote Reference Layer ?
  87. How do you download stubs from a Remote place ?
  88. What is the difference in between C++ and Java ? can u explain in detail ?
  89. I want to store more than 10 objects in a remote server ? Which methodology will follow ?
  90. What is the main functionality of the Prepared Statement ?
  91. What is meant by static query and dynamic query ?
  92. What are the Normalization Rules ? Define the Normalization ?
  93. What is meant by Servelet? What are the parameters of the service method ?
  94. What is meant by Session ? Tell me something about HTTPSession Class ?
  95. How do you invoke a Servelt? What is the difference in between doPost and doGet methods ?
  96. What is the difference in between the HTTPServlet and Generic Servlet ? Expalin their methods ? Tell me their parameter names also ?
  97. Have you used threads in Servelet ?
  98. Write a program on RMI and JDBC using StoredProcedure ?
  99. How do you sing an Applet ?
  100. In a Container there are 5 components. I want to display the all the components names, how will you do that one ?
  101. Why there are some null interface in java ? What does it mean ? Give me some null interfaces in JAVA ?
  102. Tell me the latest versions in JAVA related areas ?
  103. What is meant by class loader ? How many types are there? When will we use them ?
  104. How do you load an Image in a Servlet ?
  105. What is meant by flickering ?
  106. What is meant by distributed Application ? Why we are using that in our applications ?
  107. What is the functionality of the stub ?
  108. Have you used any version control ?
  109. What is the latest version of JDBC ? What are the new features are added in that ?
  110. Explain 2 tier and 3 -tier Architecture ?
  111. What is the role of the webserver ?
  112. How have you done validation of the fileds in your project ?
  113. What is the main difficulties that you are faced in your project ?
  114. What is meant by cookies ? Explain ?
  115. Problem faced in your earlier project
  116. How OOPS concept is achieved in Java
  117. Features for using Java
  118. How does Java 2.0 differ from Java 1.0
  119. Public static void main – Explain
  120. What are command line arguments
  121. Explain about the three-tier model
  122. Difference between String & StringBuffer
  123. Wrapper class. Is String a Wrapper Class
  124. What are the restriction for static method
  125. Purpose of the file class
  126. Default modifier in Interface
  127. Difference between Interface & Abstract class
  128. Can abstract be declared as Final
  129. Can we declare variables inside a method as Final Variables
  130. What is the package concept and use of package
  131. How can a dead thread be started
  132. Difference between Applet & Application
  133. Life cycle of the Applet
  134. Can Applet have constructors
  135. Differeence between canvas class & graphics class
  136. Explain about Superclass & subclass
  137. Difference between TCP & UDP
  138. What is AppletStub
  139. Explain Stream Tokenizer
  140. What is the difference between two types of threads
  141. Checked & Unchecked exception
  142. Use of throws exception
  143. What is finally in exception handling
  144. Vector class
  145. What will happen to the Exception object after exception handling
  146. Two types of multi-tasking
  147. Two ways to create the thread
  148. Synchronization
  149. I/O Filter
  150. How can you retrieve warnings in JDBC
  151. Can applet in different page communicate with each other
  152. Four driver Manager
  153. Features of JDBC 20
  154. Explain about stored procedures
  155. Servlet Life cycle
  156. Why do you go for servlet rather than CGI
  157. How to generate skeleton & Stub classes
  158. Explain lazy activation
  159. Firewalls in RMI

  1. Have a Java Problems
  2. Do you have a Java Question?

  1. Java Books
  2. Java Certification, Programming, JavaBean and Object Oriented Reference Books

  1. Best Regards,
  2. Java Programming Hints and Tips

  1. All the site contents are Copyright © www.sap-img.com and the content authors. All rights reserved.
  2. All product names are trademarks of their respective companies.
  3. The site www.sap-img.com is not affiliated with or endorsed by any company listed at this site.
  4. Every effort is made to ensure the content integrity. Information used on this site is at your own risk.
  5. The content on this site may not be reproduced or redistributed without the express written permission of
  6. www.sap-img.com or the content authors.

Definitions



 · Encapsulation::
Encapsulation is the mechanism that binds together code and the data it manipulates and keeps both safe from outside interference and misuse.
· Inheritance :
Inheritance is the process by which one object acquires the properties of another object.
· Polymorphism :
Polymorphism is a feature that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of actions.
· Code Blocks :
Two or more statements which is allowed to be grouped into blocks of code is otherwise called as Code Blocks.This is done by enclosing the statements between opening and closing curly braces.
· Floating-point numbers:
Floating-point numbers which is also known as real numbers, are used when evaluating expressions that require fractional precision.
· Unicode:
Unicode defines a fully international character set that can represent all of the characters found in all human languages. It is a unification of dozens of character sets, such as Latin, Greek, Arabic and many more.
· Booleans:
Java has a simple type called boolean, for logical values. It can have only on of two possible values, true or false.
· Casting:
A cast is simply an explicit type conversion. To create a conversion between two incompatible types, you must use a cast.
· Arrays:
An array is a group of like-typed variables that are referred to by a common name. Arrays offer a convenient means of grouping related information. Arrays of any type can be created and may have one or more dimension.
· Relational Operators:
The relational operators determine the relationship that one operand has to the other. They determine the equality and ordering.
· Short-Circuit Logical Operators:
The secondary versions of the Boolean AND and OR operators are known as short- circuit logical operators. It is represented by || and &&..
· Switch:
The switch statement is Java’s multiway branch statement. It provides an easy way to dispatch execution to different parts of your code based on the value of an experession.
· Jump Statements:
Jump statements are the statements which transfer control to another part of your program. Java Supports three jump statements: break, continue, and return.
· Instance Variables:
The data, or variable, defined within a class are called instance variable.

Relational Database


  A relational database is a database that conforms to the relational model, and refers to a database's data and schema (the database's structure of how that data is arranged). Common usage of the term "Relational database management system" technically refers to the software used to create a relational database, but sometimes mistakenly refers to a relational database.

Relations or tables

Main articles: Relation (mathematics) and Table (database)

A relation is defined as a set of tuples that all have the same attributes. This is usually represented by a table, which is organized into rows and columns. In a relational database, all of the data stored in a column should be in the same domain. In practice this means that values stored in a single column must all be of the same data type and conform to the same constraints.

The relational model specifies that the tuples of a relation should have no specific order and that the tuples, in turn, should impose no order on the attributes. In the relational model specific tuples are retrieved by using the projection operator over the relation. The relational selection operation is equivalent to the SQL SELECT query, possibly with a WHERE clause to limit results. In the relational model attributes must be referenced explicitly by name in all operations, while the SQL standard allows both unnamed columns in result sets and the shorthand asterisk (*) notation in queries.

The SQL standard requires columns to have a defined order. All data stored in a computer must have an order, as the memory of a computer is linear. Also, when the data is returned, there must be an order in which the data is returned because transfer protocols are also linear. Note, however, that in SQL the order of columns and rows returned in a result set is never guaranteed unless explicitly specified by the user.


Relvars

Main articles: Relvar and View (database)

A relvar is a "relation variable". In a relational database, all data are stored and accessed via relations. The data that are actually stored in the database are stored as relations. These relations are sometimes called "base relvars". This is equivalent to a "table". Other relvars do not have their data stored in them, but are a result of applying relational operations, to other relvars. These relvars are sometimes called "derived relvars", meaning that their information is derived from other sources. These are equivalent to "views" or "queries". Derived relvars are convenient in that though they may grab information from several relvars, it is presented externally as a single relvar for a simpler perspective. Also, it can be used as an abstraction layer.

Derived relvars are not always considered part of a relational database, partially because they are not essential to the functioning of the database.




Main article: data domain

A data domain (or usually just domain), is the set of possible values for a given attribute. Because it does constrain the values the data can hold, it could be considered a constraint, but because attributes must specify a domain, it could just be considered part of the relation's definition. Mathematically, a domain can be expressed as "all values for this attribute must be an element of the specified set."

In relational database implementations every data type has an associated data domain. The character data value 'ABC', for instance, is not part of the data domain for an integer attribute. The integer value '123', however, is part of the data domain for an integer attribute


Constraints



Main article: Constraint

Constraints are a way of providing restrictions on the kinds of data that can be stored in the relations. These are usually defined (formally) in the form of expressions that result in a boolean value, indicating whether or not the constraint holds. Constraints are a way of implementing business rules into the database.

Under the strictest sense, constraints are not considered part of the relational database, but because of the integral role that they play in organizing data, they are usually considered part of the database.

In practice, constraints provide users the ability to further restrict and refine the data domain for a given attribute. For instance, constraints can be used to restrict the data domain of an integer attribute to the values '1' to '10'.


Keys



Main article: Superkey

A tuple usually represents some object and its associated data, whether that object is a physical object or a concept. A key is a kind of constraint that requires that the object, or critical information about the object, is not duplicated. For example, a family might like to have a constraint such that no two people in the immediate family have the same name. If information about family members were stored in a database, a key could be placed over the family member's name. In a University, they have no such luxury. Each student is typically assigned a Student ID, which are used as keys for individual students stored in the school database. Keys can have more than one column, for example, a nation may impose a restriction that a province can't have two cities by the same name. So, when cities are stored in a relation, there would be a key defined over province and city name. This would allow for two different provinces to have a town called Springfield (because their province would be different), but not two cities with the same name in the same province. A key over more than one attribute is called a compound key. Theoretically, a key can even be over zero attributes. This would enforce that there cannot be more than one tuple in the relation.


Foreign keys

Main article: Foreign key

A foreign key is not a key by the previous definition. Rather, a foreign key is a reference to a key in another table, meaning that the referencing tuple has, as part of its attributes, the values of a key in the referenced tuple that corresponds to the relationship.

A foreign key could be described formally as "For all tuples in the referencing relation projected over the referencing attributes, there must exist a tuple in the referenced relation projected over those same attributes such that the values in each of the referencing attributes match the corresponding values in the referenced attributes".

Transition constraints

Main article: Transition constraint

A transition constraint is a way of enforcing that the data doesn't enter an impossible state because of a previous state. For example, it shouldn't be possible for a person to change from being "married" to being "single, never married". The only valid states after "married" might be "divorced", "widowed", or "deceased".


Other constraints

Other constraints of various different kinds can be created to enforce various kinds of business rules. They can be as simple as "the number of cars an individual owns must be non-negative" or complex patterns like "If the work that an employee performs is 'Hazardous Materials Transport' then that employee's age must be at least 18 years, and the employee's certifications must include 'Hazmat endorsement', and company insurance for that employee must include life insurance."

Stored procedures

Main article: Stored procedure

A stored procedure is executable code that is associated with the database. Stored procedures usually store how to perform common operations, like inserting a tuple into a relation, or gathering statistical information about usage patterns. Frequently they are used as an application programming interface (API) for security or simplicity. These are usually written as Imperative programming code extending the Data Definition Language and/or the Data Manipulation Language for the DBMS.

Stored procedures are not always considered part of a relational database, partly because they are not essential to the functioning of the database.


Indices

Main article: Index (database)

An index is a way of providing quicker access to the data in a relational database. Indices can be created on any combination of attributes on a relation. Then when tuples in a relation need to be looked up, similar to how a book's index works, the index can be accessed. Rather than having to check all of the tuples, the index tells the DBMS where the tuple is. Indices are usually implemented via B+ trees.

Indices are usually not considered part of the database, as they are considered an implementation detail, though indices are usually maintained by the same group that maintains the other parts of the database.


Relational operations

Main article: Relational algebra

Queries made against the relational database, and the derived relvars in the database are expressed in a relational calculus or a relational algebra. In his original relational algebra, Dr. Codd introduced eight relational operators in two groups of four operators each. The first four operators were based on the traditional mathematical set operations:
The union operator combines the tuples of two relations and removes all duplicate tuples from the result. The relational union operator is equivalent to the SQL UNION operator.
The intersection operator produces the set of tuples that two relations share in common. Intersection is implemented in SQL in the form of the INTERSECT operator.
The difference operator acts on two relations and produces the set of tuples from the first relation that do not exist in the second relation. Difference is implemented in SQL in the form of the EXCEPT or MINUS operator.
The cartesian product of two relations is a join that is not restricted by any criteria, resulting in every tuple of the first relation being matched with every tuple of the second relation. The cartesian product is implemented in SQL as the CROSS JOIN join operator.

The remaining operators proposed by Dr. Codd involve special operations specific to relational
The selection, or restriction, operation retrieves tuples from a relation, limiting the results to only those that meet a specific criteria, i.e. a subset of terms of set theory. The SQL equivalent of selection is the SELECT query statement with a WHERE clause.
The projection operation is essentially a selection operation in which duplicate tuples are removed from the result. The SQL GROUP BY clause, or the DISTINCT keyword implemented by some SQL dialects, can be used to remove duplicates from a result set.
The join operation defined for relational databases is often referred to as a natural join. In this type of join, two relations are connected by their common attributes. SQL's approximation of a natural join is the INNER JOIN join operator.
The relational division operation is slightly more complex operation, which involves essentially using the tuples of one relation (the dividend) to partition a second relation (the divisor). The relational division operator is effectively the opposite of the cartesian product operator (hence the name).

Other operators have been introduced or proposed since Dr. Codd's introduction of the original eight including relational comparison operators and extensions that offer support for nesting and hierarchical data, among others.