Oops
Oops
=====================================================================
=====================================================================
3. Which component is used to compile, debug and execute the java programs?
Answers
1. JRE
2. JIT
**3. JDK
4. JVM
=====================================================================
class Test
{
int i;
}
class Main{
public static void main(String[] args)
{ Test t;
System.out.println(t.i);
}
}
Answers
1. 0
2. garbage value
**3. compiler error
4. runtime error
=====================================================================
Answers
1. More than one method with same name but different number or type of parameters
2. More than one method with same name but different number of parameter
3. More than one method with same name, same number of parameters but different
type of parameters
**4. More than one method with same name, same number of parameters and same type
of parameters but return type is different
=====================================================================
Answers
**1. Encapsulation
2. Inheritance
3. Polymorphism
4. Abstraction
=====================================================================
class Main {
public static void main(String[] args) {
Base b = new Derived();
b.show();
}
}
Answers
1. Base::show() called
2. Derived::show() called
**3. Compiler error
4. Runtime error
=====================================================================
Answers
**1. super
2. this
3. extent
4. extends
=====================================================================
Answers
1. String class
**2. Object class
3. Abstract class
4. ArrayList class
=====================================================================
Answers
**1. Casting subtype to supertype
2. Casting super type to subtype
3. Casting subtype to super type and vice versa
4. Casting anytype to any other type
=====================================================================
Answers
1. 38 43
**2. 39 44
3. 295 300
4. 295.04 300
=====================================================================
Answers
**1. Integer
2. Long
3. Byte
4. Double
=====================================================================
Answers
**1. main method
2. finalize method
3. static method
4. private method
=====================================================================
Answers
1. String
2. StringBuffer
3. StringBuilder
**4. Both StringBuffer and StringBuilder
=====================================================================
15. Which of these method of class String is used to compare two String objects for
their equality?
Answers
**1. equals()
2. Equals()
3. isequal()
4. Isequal()
=====================================================================
16. Which of these process occur automatically by the java runtime system?
Answers
**1. Serialization
2. Garbage collection
3. File Filtering
4. All of the mentioned
=====================================================================
17. Which of the following class we can used to read the data in the form of
character from text file?
Answers
1. FileWriter
**2. FileReader
3. FileInputStream
4. FileOutputStream
=====================================================================
Answers
**1. 0
2. 1
3. 2
4. 3
=====================================================================
Answers
1. Cannot Instantiate Generic Types with Primitive Types
2. Cannot Create Instances of Type Parameters
3. Cannot Overload a Method Where the Formal Parameter Types of Each Overload Erase
to the Same Raw Type
**4. All of the above
=====================================================================
Answers
1. String
2. Object
3. void
**4. Function
=====================================================================
21. While iteration is on and some other thread tries to modify the collection then
iterator throws following exception?
Answers
**1. ConcurrentModificationException
2. CollectionModificationException
3. RandomAccessException
4. None of the above
=====================================================================
22. Which of these methods can be used to obtain a array from an ArrayList object?
Answers
1. Array()
2. convertArray()
**3. toArray()
4. covertoArray()
=====================================================================
Answers
1. override equals method
2. override hashCode method
**3. Both of the above
4. None of the above
=====================================================================
Answers
1. Time.getUTC();
2. Date.getUTC();
**3. Instant.now();
4. TimeZone.getUTC();
=====================================================================
Answers
1. Caught base class exception
2. Caught derived class exception
**3. Compiler Error because base class exception is caught before derived class
4. Compiler Error because derived is not throwable
=====================================================================
Answers
1. Errors are abnormal conditions in application
2. Error indicates some serious problems that our application should not try to
catch
**3. Error is unchecked Exception
4. Error is a subclass of Throwable
=====================================================================
Answers
**1. catch(X x) can catch subclasses of X where X is a subclass of Exception
2. Any statement that can throw an Exception must be enclosed in a try block
3. The Error class is a RuntimeException
4. Any statement that can throw an Error must be enclosed in a try block
=====================================================================
Answers
1. Serializable
**2. Externalizable
3. FileFilter
4. ObjectInput
=====================================================================
Answers
1. Thread consumes cpu in best possible manner
2. Threads enables multi-processing
3. Threads can execute any part of process. And same part of process can be
executed by multiple Threads.
**4. All
=====================================================================
Answers
1. By Extending Thread class
2. Implementing Runnable interface
3. By using Executor framework - which can internally form threads
**4. All of the above
=====================================================================
Answers
1. Variables and Methods
2. Methods and Classes
3. Variables and Classes
**4. Methods and Blocks
=====================================================================
Answers
1. Green threads are user-level threads
2. Green threads are high level threads
3. Green threads are OS level threads
**4. None
=====================================================================
Answers
1. Random and synchronized
2. Parallel and random
3. Sequential and random
**4. Sequential and parallel
=====================================================================
Answers
1. EMPTY_LIST
2. EMPTY_SET
3. EMPTY_MAP
**4. All the answers are true
=====================================================================
Answers
**1. Run Time
2. Can Occur Any Time
3. Compilation Time
4. None of the mentioned
=====================================================================
Answers
**1. Initial memory; Maximum memory
2. Initial memory
3. Maximum memory
4. Maximum; Initial memory
=====================================================================
Answers
1. x.delete()
2. x.finalize()
3. Runtime.getRuntime().gc()
**4. Only the garbage collection system can destroy an object
=====================================================================
38. Which of these class relies upon its subclasses for complete implementation of
its methods?
Answers
1. Object class
**2. abstract class
3. ArrayList class
4. None of the mentioned
=====================================================================
Answers
1. Interfaces specifies what class must do but not how it does
2. Interfaces are specified public if they are to be accessed by any code in the
program
3. All variables in interface are implicitly final and static
**4. All variables are abstract and methods are static if interface is defined
public
=====================================================================
40. What happens when we access the same variable defined in two interfaces
implemented by the same class?
Answers
1. Compilation failure
2. Runtime Exception
3. The JVM is not able to identify the correct variable
**4. The interfaceName.variableName needs to be defined
=====================================================================
*********************End******************
=====================================================================