Java Interview Questions and Answers Set 5

41.What is the difference between processes and threads ?

A process is an execution of a program, while a Thread is a single execution sequence within a process. A process can contain multiple threads. A Thread is sometimes called a lightweight process.

42.Can you access non static variable in static context ?

A static variable in Java belongs to its class and its value remains the same for all its instances. A static variable is initialized when the class is loaded by the JVM. If your code tries to access a non-static variable, without any instance, the compiler will complain, because those variables are not created yet and they are not associated with any instance.

43.What is J2EE?

J2EE means Java 2 Enterprise Edition. The functionality of J2EE is developing multitier web-based applications. The J2EE platform is consists of a set of services, application programming interfaces (APIs), and protocols.

44.What are the four components of J2EE application?

  • Application clients components.
  • Servlet and JSP technology are web components.
  • Business components (JavaBeans).
  • Resource adapter components

45. What are types of J2EE clients?

  • Applets
  • Application clients
  • Java Web Start-enabled clients, by Java Web Start technology.
  • Wireless clients, based on MIDP technology.

Weekend / Weekday Batch

46. What is considered as a web component?

Java Servlet and Java Server Pages technology components are web components. Servlets are Java programming language that dynamically receives requests and make responses. JSP pages execute as servlets but allow a more natural approach to creating static content.

47. What is JSF?

JavaServer Faces (JSF) is a user interface (UI) designing framework for Java web applications. JSF provides a set of reusable UI components, a standard for web applications. JSF is based on MVC design pattern. It automatically saves the form data to the server and populates the form date when display at the client side.

48. Define Hash table

HashTable is just like Hash Map, Collection having key(Unique), value pairs. Hashtable is a collection Synchronized object. It does not allow duplicate values or null values.

49. What is Hibernate?

Hibernate is an open source object-relational mapping and query service. In hibernate we can write HQL instead of SQL which save developers to spend more time on writing the native SQL. Hibernate has a more powerful association, inheritance, polymorphism, composition, and collections. It is a beautiful approach for persisting into the database using the Java objects. Hibernate also allows you to express queries using Java-based criteria.

50. What is the limitation of hibernate?

  • Slower in executing the queries than queries are used directly.
  • Only query language support for composite keys.
  • No shared references to value types.