Very Short Questions Spring 2017 || Object-Oriented Programming

Very Short Questions Spring 2017

Very Short Questions Spring 2017

The answers to very short questions of spring 2017 are given below:

1. Explain in brief JDK, JRE & 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. It physically exists. It contains JRE + development tools.

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) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode.

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

ANS-  Autoboxing and Unboxing: The automatic conversion of primitive data types into their equivalent Wrapper type is known as boxing and the opposite operation is known as unboxing.

3. Differentiate instance variable and static variable.

Instance variables Static (class) variables
Instance variables are declared in a class, but outside a method or any constructor or any block. Class variables are also known as static variables. They are declared with the static keyword in a class, but outside a method, or any constructor or a block.
Instance variables are created when an object is created with the use of the keyword ‘new’. Static variables are created when the program starts.

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

ANS- Final keyword in Java has three different uses:

  • create constants
  • prevent inheritance
  • prevent methods from being overridden.

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

ANS-The primitive data types available in java are:

  • Int
  • Boolean
  • Double
  • Float

6. How we can create a thread in java?

ANS- A thread can be created by implementing the Runnable interface and overriding the run () method. Then a Thread object can be created and the start () method called. The Main thread in Java is the one that begins executing when the program starts.

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

ANS- A Package can be defined as a grouping of related types (classes, interfaces, enumerations and annotations) providing access protection and namespace management.

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.

BASIS FOR COMPARISON STRING StringBuffer
Basic The length of the String object is fixed. The length of the StringBuffer can be increased.
Modification The string object is immutable. StringBuffer object is mutable.

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

ANS- The SimpleDateFormat is a concrete class for formatting and parsing date which inherits java.text.DateFormat class. Notice that formatting means converting date to string and parsing means converting string to date.

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

ANS- Swing supports the pluggable look and feel. Overall, it is more powerful than AWT. That is why Swing is better than AWT. Two reasons why Swing is better than AWT are given below:

  • AWT does not follow MVC but Swing does.
  • AWT components are heavyweight whereas Swing components are lightweight.

You may also like Pokhara University|| 2017 Spring Object Oriented Language||

Be the first to comment

Leave a Reply

Your email address will not be published.


*