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.

Java TRAINING
Weekend / Weekday Batch

46.Define the default value for byte datatype in Java language.

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. What makes Java have its ‘write once and run anywhere’ (WORA) nature?

Well, the one-word answer is Bytecode. Java compiler converts all the Java programs into a specific Byte Code acting as a mediator language between the machine code and source code. ByteCode can run on any computer and has no platform dependency.

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. Why is byte data type more beneficial in Java?

As byte data type is almost four times smaller than an integer, so it can store more space for large arrays.
They can also be used in place of int, where their limits help to clarify the code.