Very Short Questions Spring 2014 || Object-Oriented Programming

Very Short Questions Spring 2014

Very Short Questions Spring 2014 Object-Oriented Programming

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

  1. What is Java Virtual Machine and Bytecodes?

ANS- Java virtual machine is nothing but a virtual machine that runs the java code. Bytecodes are designed to be interpreted by a Java virtual machine. Java becomes platform-independence due to the fact that the same bytecodes can be executed by any JVM. \

2. Explain in brief JDK & JRE.

ANS- 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.

3. What is the scope of a variable?

ANS- Scope of a variable is the part of the program where the variable is accessible.  In Java, all identifiers are lexically (or statically) scoped, i.e.scope of a variable can determined at compile-time and independent of the function call stack. Java programs are organized in the form of classes. Every class is part of some package.

4. List Java’s primitive data types.

ANS- Primitive Data types in java are those data types that specify the type and size of data but do not provide any additional methods; examples of primitive data types available in java include:

  • byte
  • short
  • int
  • char
  • long
  • float, etc

5. Can we declare a class as private? Justify your answer.

ANS-Yes we can declare a class with a private access specifier. But not in the main class. We can declare private in inner classes only. So we can’t declare private in the main class but we can declare private in inner classes.

6. Differentiate between Method Overloading and Method Overriding.

No. Method Overloading Method Overriding
1) Method overloading is used to increase the readability of the program. Method overriding is used to provide the specific implementation of the method that is already provided by its superclass.
2) Method overloading is performed within the class. Method overriding occurs in two classes that have IS-A (inheritance) relationship.

7. Explain interfaces and packages.

ANS- Packages and Interfaces both acts as a container. The content in packages and interfaces can be used by the classes by importing and implementing it correspondingly. The basic difference between packages and interfaces is that a package contains a group of classes and interfaces whereas, an interface contains methods and fields.

8. How to throw and rethrow an exception?

ANS- The correct way to catch and re-throw an exception is to pass the caught exception object as the “rootCause” or inner exception parameter to the constructor of the new exception (note that not all exception constructors support inner exceptions, in which case a different wrapper exception should be used).

9. What is the purp0se of SimpleDataFormat class?

ANS- The java.text.SimpleDateFormat class provides methods to format and parse date and time in java. 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. What is the difference between A WT and swing?

ANS- Several consequences result from this difference between AWT and Swing. AWT is a thin layer of code on top of the OS, whereas Swing is much larger. Swing also has very much richer functionality. Using AWT, you have to implement a lot of things yourself, while Swing has them built-in.

You may also like Pokhara University, 2014 Spring Object Oriented Language

Be the first to comment

Leave a Reply

Your email address will not be published.


*