Unit - 1 Introduction To Oop and Java Fundamentals: Cs8392 Object Oriented Programming It/Jjcet
Unit - 1 Introduction To Oop and Java Fundamentals: Cs8392 Object Oriented Programming It/Jjcet
Unit - 1 Introduction To Oop and Java Fundamentals: Cs8392 Object Oriented Programming It/Jjcet
1) Which of the following option leads to the portability and security of Java?
a. Bytecode is executed by JVM
b. The applet makes the Java code secure and portable
c. Use of exception handling
d. Dynamic binding between objects
6) What is the return type of the hashCode() method in the Object class?
a. Object
b. int
c. long
d. void
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
11) Which of the following tool is used to generate API documentation in HTML
format from doc comments in source code?
a. javap tool
b. javaw command
c. Javadoc tool
d. javah command
13) Which method of the Class.class is used to determine the name of a class
represented by the class object as a String?
a. getClass()
b. intern()
c. getName()
d. toString()
14) In which process, a local variable has the same name as one of the instance
variables?
a. Serialization
b. Variable Shadowing
c. Abstraction
d. Multi-threading
15) Which of the following is true about the anonymous inner class?
a. It has only methods
b. Objects can't be created
c. It has a fixed class name
d. It has no class name
a. Complete
b. Iomplede
c. Cimpletd
d. Coipletd
25) What is meant by the classes and objects that dependents on each other?
a. Tight Coupling
b. Cohesion
c. Loose Coupling
d. None of the above
26) Given,
int values[ ] = {1,2,3,4,5,6,7,8,9,10};
for(int i=0;i< Y; ++i)
System.out.println(values[i]);
Find the value of value[i]?
a. 10
b. 11
c. 15
d. None of the above
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
27) What should be the execution order, if a class has a method, static block,
instance block, and constructor, as shown below?
public class First_C {
public void myMethod()
{
System.out.println("Method");
}
{
System.out.println(" Instance Block");
}
public void First_C()
{
System.out.println("Constructor ");
}
static {
System.out.println("static block");
}
public static void main(String[] args) {
First_C c = new First_C();
c.First_C();
c.myMethod();
}
}
a. Instance block, method, static block, and constructor
b. Method, constructor, instance block, and static block
c. Static block, method, instance block, and constructor
d. Static block, instance block, constructor, and method
28) Which of the following creates a List of 3 visible items and multiple selections
abled?
a. new List(false, 3)
b. new List(3, true)
c. new List(true, 3)
d. new List(3, false)
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
31) Which function among the following can’t be accessed outside the class in java
in same package?
a) public void show()
b) void show()
c) protected show()
d) static void show()
***
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
2) Given that Student is a class, how many reference variables and objects are
created by the following code?
Student studentName, studentId;
studentName = new Student();
Student stud_class = new Student();
a. Three reference variables and two objects are created.
b. Two reference variables and two objects are created.
c. One reference variable and two objects are created.
d. Three reference variables and three objects are created.
3) Given,
ArrayList list = new ArrayList();
What is the initial quantity of the ArrayList list?
a. 5
b. 10
c. 0
d. 100
a. No error
b. Method is not defined properly
c. Constructor is not defined properly
d. Extra parentheses
8. Which syntax among the following shows that a member is private in a class?
a) private: functionName(parameters)
b) private(functionName(parameters))
c) private functionName(parameters)
d) private::functionName(parameters)
13. Which of these keywords cannot be used for a class which has been declared
final?
a) abstract
b) extends
c) abstract and extends
d) none of the mentioned
14. If a class inheriting an abstract class does not define all of its function then it
will be known as?
a) Abstract
b) A simple class
c) Static class
d) None of the mentioned
19. If super class and subclass have same variable name, which keyword should be
used to use super class?
a) super
b) this
c) upper
d) classname
22. Which of the following is the correct way of implementing an interface salary
by class manager?
a) class manager extends salary {}
b) class manager implements salary {}
c) class manager imports salary {}
d) none of the mentioned
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
25. What happens when we access the same variable defined in two interfaces
implemented by the same class?
a) Compilation failure
b) Runtime Exception
c) The JVM is not able to identify the correct variable
d) The interfaceName.variableName needs to be defined
30. If class A and class B are derived from class C and class D, then
________________
a) Those are 2 pairs of single inheritance
b) That is multilevel inheritance
c) Those is enclosing class
d) Those are all independent classes
***
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
4) Which of these classes are the direct subclasses of the Throwable class?
a. RuntimeException and Error class
b. Exception and VirtualMachineError class
c. Error and Exception class
d. IOException and VirtualMachineError class
8. Which of these keywords must be used to handle the exception thrown by try
block in some rational manner?
a) try
b) finally
c) throw
d) catch
a)0
b)05
c)CompilationError
d) Runtime Error
12. Which of the following handles the exception when a catch is not used?
a) finally
b) throw handler
c) default handler
d) java run time system
17. Which of these exceptions will occur if we try to access the index of an array
beyond its length?
a) ArithmeticException
b) ArrayException
c) ArrayIndexException
d) ArrayIndexOutOfBoundsException
18. Which of these class is related to all the exceptions that are explicitly thrown?
a) Error
b) Exception
c) Throwable
d) Throw
19. Which of these keywords is used to by the calling function to guard against the
exception that is thrown by called function?
a) try
b) throw
c) throws
d) catch
22. Which of these is used to read a string from the input stream?
a) get()
b) getLine()
c) read()
d) readLine()
23. Which of these class is used to read characters and strings in Java from
console?
a) BufferedReader
b) StringReader
c) BufferedStreamReader
d) InputStreamReader
26. Which of these exception is thrown in cases when the file specified for writing
is not found?
a) IOException
b) FileException
c) FileNotFoundException
d) FileInputException
27. Which of these values is returned by read() method is end of file (EOF) is
encountered?
a) 0
b) 1
c) -1
d) Null
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
5) If three threads trying to share a single object at the same time, which condition
will arise in this scenario?
a. Time-Lapse
b. Critical situation
c. Race condition
d. Recursion
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
7) Which of the following modifiers can be used for a variable so that it can be
accessed by any thread or a part of a program?
a. global
b. transient
c. volatile
d. default
9. Which of this method can be used to make the main thread to be executed last
amongall the threads?
a) stop()
b) sleep()
c) join()
d) call()
10. Which of this method is used to find out that a thread is still running or not?
a) run()
b) Alive()
c) isAlive()
d) checkRun()
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
11. Which of these method is used to explicitly set the priority of a thread?
a) set()
b) make()
c) setPriority()
d) makePriority()
13. Which of these type parameters is used for a generic methods to return and
accept any type of object?
a) K
b) N
c) T
d) V
16. Which of the following allows us to call generic methods as a normal method?
a) Type Interface
b) Interface
c) Inner class
d) All of the mentioned
CS8392 OBJECT ORIENTED PROGRAMMING IT/JJCET
30. Which of the following will ensure the thread will be in running state?
a) yield()
b) notify()
c) wait()
d) Thread.killThread()
***
CS8392 OBJECT ORIENTED PTOGRAMMING IT/JJCET
2) Which of these operators can be used to get run time information about an
object?
a) getInfo
b) Info
c) instanceof
d) getinfoof
a. Graphics class
b. Component class
c. Both A & B
d. None of the above
12) Which is the container that doesn't contain title bar and MenuBars but it can
have other components like button, textfield etc?
a. Window
b. Frame
c. Panel
d. Container
13) Which method is used to set the graphics current color to the specified color
in the graphics class?
14) In Graphics class which method is used to draws a rectangle with the
specified width and height?
15) Which object can be constructed to show any number of choices in the visible
window?
a. Labels
b. Choice
c. List
d. Checkbox
CS8392 OBJECT ORIENTED PTOGRAMMING IT/JJCET
***