Very Short Questions Spring 2017 || Object-Oriented Programming

Very Short Questions Spring 2017

Very Short Questions Spring 2017

The answers to the Very Short Questions Spring 2017 are given below:

  1. Explain in brief JDK, JRE and JVM.

ANS- JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a software development environment that is used to develop Java applications and applets.

JRE is an acronym for Java Runtime Environment. It is also written as Java RTE. The Java Runtime Environment is a set of software tools that are used for developing Java applications.

A Java virtual machine (JVM), an implementation of the Java Virtual Machine Specification, interprets compiled Java binary code for a computer’s processor so that it can perform a Java program’s instructions.

2. What do you mean by Autoboxing and Auto-unboxing?

ANS- Autoboxing is the process by which a primitive type is automatically encapsulated (boxed) into its equivalent type wrapper whenever an object of that type is needed.

Auto-unboxing is the process by which the value of a boxed object is automatically extracted (unboxed) from a type wrapper when its value is needed.

3. Differentiate the instance variable and static variable.

ANS-

Instance Variable

Static Variable

Instance variable, which is associated with a particular instance of a type, or a local variable. A static variable is usually associated with a type.

4. What is the use of the final keyword in java?

ANS- The final keyword is used in java to help in improving performance and they are safely shared in a multithreading environment without additional synchronization overhead. Also, the Final keyword allows JVM to the optimized method, variable or class.

5. List all types of primitive data types available in java.

ANS- All the primitive data types available in java are given below:

  • Double
  • Int
  • Boolean
  • Float

6. How we can create a thread in java?

ANS- A thread in java can be created by implementing the runnable interface and overriding the run method. The main thread in java is the thread that executes when the program starts. All the child threads are spawned from the main thread and it is the last thread to finish execution.

7. What do you mean by package? Why package is important?

ANS- A package is a namespace that organizes a set of related classes and interfaces. Conceptually we can think of packages as being similar to different folders on our computer. The package is important because it helps to order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc.

8. Differentiate String Buffer and String Builder class.

String Buffer

String Builder

String Builder is unsynchronized. String Builder is synchronized.

9. What is the purpose of the Simple Date Format class?

ANS- Simple Date Format is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting, parsing and normalization.

10. Why swing is better than AWT. Give any two reasons?

ANS- Swing is better than AWT because:

  • Swing is platform-independent whereas AWT is platform dependent.
  • AWT uses native code (the gui code) that was already there in the OS but swing builds every component from the scratch.

You may also like Pokhara University || Spring 2017 || Object-Oriented Programming || BBA/ BCIS

Be the first to comment

Leave a Reply

Your email address will not be published.


*