0

Java Programming Basics

Description: java
Number of Questions: 15
Created by:
Tags: java Java/Oracle /C/C++ Data Types Variables and Storage Classes Arrays and Pointers
Attempted 0/15 Correct 0 Score 0

What is the current java version number and its name?

  1. Standard Edition 7 and Tiger

  2. Standard Edition 7 and Dolphin

  3. Standard Edition 6 and Mustang

  4. Standard Edition 6 and Dolphin

  5. Standard Edition 7 and Mustang


Correct Option: B
Explanation:

Standard Edition 7 and Dolphin is the current java version's number and name.

Which of the following variable types is/are not serializable in Java?

  1. Instance

  2. Static

  3. Transient

  4. Both 1 and 2

  5. Both 2 and 3


Correct Option: E
Explanation:

if a user does not want any field to be a part of object's state, then declare it either static or transient based on his need and it will not be included during Java serialization process.

Which of the following is a thread safe class in Java?

  1. StringBuffer

  2. ArrayList

  3. HashMap

  4. StringBuilder

  5. String


Correct Option: A
Explanation:

StringBuffer is designed to be thread safe and all public methods in StringBuffer are synchronized.

What is the 'out' in the System.out.println() statement in Java?

  1. PrintWriter class object defined in System class

  2. Bufferwriter class defined in System class

  3. System class object

  4. PrintStream class defined in System class

  5. BufferReader class object


Correct Option: D
Explanation:

It is an object PrintStream class defined in System class. 'out' is declared as public, static and final.

Which of the following is the drawback of java when compared with other programming languages?

  1. Having multi threading feature

  2. Not having low level programming support

  3. Having robustness

  4. Not having pointers

  5. Not having struct data type


Correct Option: B
Explanation:

Low-level programming cannot be done directly, unlike in C.

Which of the following is a false statement?

  1. Catch statement can rethrow an exception in Java.

  2. Empty catch block is accepted by Java.

  3. Main is a daemon thread.

  4. Garbage collector is a daemon thread.

  5. Garbage collector can also run forcibly.


Correct Option: C
Explanation:

Main is not a daemon thread, also any thread stem from main will be non daemon because daemon is derived from parent Thread class.

How to get the descriptive information about the exception occurred in a program?

  1. multiple catch statements

  2. single catch with exception type as Exception

  3. printQueueTrace();

  4. printStackTrace();

  5. printLinkedlistTrace();


Correct Option: D
Explanation:

All exceptions inherit a method printStackTrace() from Throwable class. Its stores all the exceptions in stack manner and prints them out, when it is called.

Which of the following is not an advantage of innerclass in Java?

  1. Maintainability is easier.

  2. Encapslation is easily achieved.

  3. Better accesibility restrictions

  4. Inner class members are hidden from outer class.

  5. Inheritance is easily achieved.


Correct Option: E
Explanation:

Inner class is not inherited from the outer class.This is the disadvantage of inner class. 

Which of the following access modifers is assigned to a varible in java class, if explicitly, nothing is mentioned?

  1. Public

  2. Private

  3. Protected

  4. Default type

  5. It causes compile time error.


Correct Option: D
Explanation:

Default type for variable in java class

Choose the correct statement about the abstract class.

  1. An abstract class can be instantiated and must have a main method.

  2. An abstract class cannot be instantiated but has a main method.

  3. An abstract class cannot be instantiated and does not have a main method.

  4. An abstract class must be instantiated and does not have a main method.

  5. An abstract class also contains abstract methods.


Correct Option: B
Explanation:

An abstract class is one that cannot be instantiated. All other functionality of the class still exists and its fields, methods and constructors are all accessed in the same manner. You just cannot create an instance of the abstract class.

Which of the following is not a marker interface?

  1. java.io.Serializable

  2. java.lang.Cloneable

  3. java.util.EventListener

  4. Java.util.stack

  5. None of the above


Correct Option: D
Explanation:

Stack is not a marker interface.

Which of the following statements is not true?

  1. Constructor cannot be declared as final.

  2. Constructor returns the value.

  3. Constructor is just like a method invoked at the time of object creation.

  4. Constructor cannot be inherited.

  5. Constructor cannot be overloaded.


Correct Option: E
Explanation:

Constructor is just a method and it can be overloaded.

Which of the following are the main features of Java?

  1. Abstraction, inheritance, encapsulation, polymorphism

  2. Atomicity, polymorphism, interface

  3. Abstraction, inheritance, isolation

  4. Inheritance, encapsulation, durabilty

  5. Portability, consistency, durability


Correct Option: A
Explanation:

The features of Java are described as follows: Abstraction: Hiding unnecessary details from the user. Inheritance: Maintaining a hierarchy and reusability of code. Encapsulation: Protecting the data of a class by providing access only through methods. Polymorphism: Using same name for performing different functions. For example,function overloading.

In which of the following siituations does finally block execute?

  1. Return statement in catch block.

  2. System.exit() present in catch block.

  3. Exception occurred in finally block.

  4. The death of thread occurs before completion of execution.

  5. Break; statement in catch block.


Correct Option: A
Explanation:

Once execution enters the try block, the code in that finally block will definitely be executed.

Which of the following statements is/are true regarding a constructor?

  1. Calling one constructor from other constructor is possible.

  2. The default value of the Boolean type is false.

  3. The garbage collector invokes an object's finalize() method, when it detects that the object has become unreachable.

  4. The dot operator(.) is used to access the instance variables and methods of class objects. It is also used to access classes and sub-packages from a package.

  5. All of the above


Correct Option: E
Explanation:

All of the above statements are true

- Hide questions