0% found this document useful (0 votes)
28 views

DBDA EANDC QB Core Java PDF

Uploaded by

Harsh Mantri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

DBDA EANDC QB Core Java PDF

Uploaded by

Harsh Mantri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

ACTS, C-DAC

Q. No. 1
Question:
Which of the following option leads to the portability and security of Java?

Answer Choices
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

Q. No. 2
Question:
Which of these cannot be used for a variable name in Java?

Answer Choices
A: identifier
B: keyword
C: identifier & keyword
D: none of the mentioned

Q. No. 3
Question:
Which of the below is not a memory leak solution?

Answer Choices
A: Code changes
B: JVM parameter tuning
C: Process restart
D: GC parameter tuning

ADP/DI/27_R00 Page 1 of 19
ACTS, C-DAC

Q. No. 4
Question:
Which of these can be overloaded?

Answer Choices
a) Methods
b) Constructors
c) Both A and B
d) None of the mentioned

Q. No. 5
Question:
What is the output of the following program?

public class Test{


private String function(){
return ("Test");
}
public final static String function(int data){
return ("Test123");
}
public static void main(String[] args){
Test obj = new Test();
System.out.println(obj.function());
}
}

Answer Choices
A: Test

ADP/DI/27_R00 Page 2 of 19
ACTS, C-DAC

A: Compilation error
B: Runtime error
D: None of these

Q. No. 6
Question:
Suppose a class has public visibility. In this class we define a protected method. Which
of the following statements is correct?

Answer Choices
A: This method is only accessible from inside the class itself and from inside all
subclasses.
B: In a class, you cannot declare methods with a lower visibility than the visibility of the
class in which it is defined.
C: From within protected methods you do not have access to public methods.
D: This method is accessible from within the class itself and from within all classes defined
in the same package as the class itself.

Q. No. 7
Question:
Which of the following is true about inheritance in Java?
1) Final methods can not be overridden
2) Protected members are accessible within a package and
inherited classes outside the package.
3) Protected methods are final.
4) We cannot override private methods.

Answer Choices
A: 1, 2 and 4
B: Only 1 and 2

ADP/DI/27_R00 Page 3 of 19
ACTS, C-DAC

C: 1, 2 and 3
D: 2, 3 and 4

Q. No. 8
Question:
What is the output of the following program?

import java.io.IOException;
class Derived {
public void getDetails() throws IOException //line 23 {
System.out.println("Derived class");
}
}
public class Test extends Derived {
public void getDetails() throws Exception //line 24 {
System.out.println("Test class");
}
public static void main(String[] args) throws IOException //line 25 {
Derived obj = new Test();
obj.getDetails();
}
}

Answer Choices
A: Compilation error due to line 23
B: Compilation error due to line 24
C: Compilation error due to line 25
D: None of the above

ADP/DI/27_R00 Page 4 of 19
ACTS, C-DAC

Q. No. 9
Question:
Which of the following is used to make an Abstract class?

Answer Choices
A: Making atleast one-member function as pure virtual(abstract) function
B: Making atleast one-member function as virtual function
C: Declaring as Abstract class using virtual keyword
D: Declaring as Abstract class using static keyword

Q. No. 10
Question:
What is the output of the following program?

class Base {
public final void show() {
System.out.println("Base::show() called");
}
}
class Derived extends Base {
public void show() {
System.out.println("Derived::show() called");
}
}
public class Main {
public static void main(String[] args) {
Base b = new Derived();
b.show();
}
}

ADP/DI/27_R00 Page 5 of 19
ACTS, C-DAC

Answer Choices
A: Derived::show() called
B: Base::show() called
C: Compiler Error
D: Exception

Q. No. 11
Question:
The concept of multiple inheritance is implemented in Java by
I. Extending two or more classes.
II. Extending one class and implementing one or more interfaces.
III. Implementing two or more interfaces.

Answer Choices
A: Only (II)
B: (I) and (II)
C: (II) and (III)
D: Only (III)

Q. No. 12
Question:
What is the output of the following program?

public class Outer {


private static int data = 10;
private static int LocalClass() {
class Inner {
public int data = 20;

ADP/DI/27_R00 Page 6 of 19
ACTS, C-DAC

private int getData() {


return data;
}
};
Inner inner = new Inner();
return inner.getData();
}

public static void main(String[] args) {


System.out.println(data * LocalClass());
}
}

Answer Choices
A: Compilation error
B: Runtime Error
C: 200
D: None of the above

Q. No. 13
Question:
In which of the following package Exception class exist?

Answer Choices
A: java.util
B: java.io
C: java.lang
D: java.net

Q. No. 14

ADP/DI/27_R00 Page 7 of 19
ACTS, C-DAC

Question:
Which of the below statement is/are true about Error?
I. An Error is a subclass of Throwable.
II. An Error is a subclass of Exception.
III. Error indicates serious problems that a reasonable application should not try to catch.
iV. An Error is a subclass of IOException.

Answer Choices
A: (I) and (IV)
B: (I) and (II)
C: (I) and (III)
D: (II) and (III)

Q. No. 15
Question:
Which of these value are returns under the case of normal termination of a program?

Answer Choices
A: 0
B: 1
C: 2
D: 3

Q. No. 16
Question:
What is the name of a data member of class Vector which is used to store a number of
elements in the vector?

Answer Choices
A: length

ADP/DI/27_R00 Page 8 of 19
ACTS, C-DAC

B: elements
C: elementCount
D: capacity

Q. No. 17
Question:
What will be the output of the following Java code?
class Output {
public static void main(String args[]) {
Double i = new Double(257.5);
boolean x = i.isNaN();
System.out.print(x);
}
}

Answer Choices
A: true
B: false
C: 0
D: 1

Q. No. 18
Question:
Which of the following cannot be Type parameterized?

Answer Choices
A: Overloaded Methods
B: Generic methods
C: Class methods

ADP/DI/27_R00 Page 9 of 19
ACTS, C-DAC

D: Overriding methods

Q. No. 19
Question:
Which function is used to perform some action when the object is to be destroyed?

Answer Choices
A: finalize()
B: delete()
C: main()
D: None of the mentioned

Q. No. 20
Question:
Which of these methods can be used to obtain set of all keys in a map?

Answer Choices
A: getAll()
B: getKeys()
C: keyall()
D: keySet()

Q. No. 21
Question:
Which of this method is used to change an element in a LinkedList Object?

Answer Choices
A: change()

ADP/DI/27_R00 Page 10 of
19
ACTS, C-DAC

B: set()
C: redo()
D: add()

Q. No. 22
Question:
Which of these class is not a member class of java.io package?

Answer Choices
A: String
B: StringReader
C: Writer
D: File

Q. No. 23
Question:
Which of these values is returned by read() method is end of file (EOF) is encountered?

Answer Choices
A: 0
B: 1
C: -1
D: Null

Q. No. 24
Question:
Which of these class extend InputStream class?

ADP/DI/27_R00 Page 11 of
19
ACTS, C-DAC

Answer Choices
A: ObjectStream
B: ObjectInputStream
C: ObjectOutput
D: ObjectInput

Q. No. 25
Question:
Which of the following constructor of class Thread is valid one?

Answer Choices
A: Thread(Runnable threadOb, int priority)
B: Thread(int priority)
C: Thread(Runnable threadOb, String threadName)
D: Thread(String threadName, int priority)

Q. No. 26
Question:
What is the output of the following program?

public class Test extends Thread implements Runnable {


public void run() {
System.out.printf("Test ");
}
public static void main(String[] args) throws InterruptedException {
Test obj = new Test();
obj.run();
obj.start();
}
}

ADP/DI/27_R00 Page 12 of
19
ACTS, C-DAC

Answer Choices
a) Runtime error
b) Compilation error
c) Test Test
d) None of the above

Q. No. 27
Question:
What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?

Answer Choices
A: 0 & 256
B: 0 & 1
C: 1 & 10
D: 1 & 256

Q. No. 28
Question:
What notifyAll() method do?

Answer Choices
A: Wakes up one threads that are waiting on this object's monitor
B: Wakes up all threads that are not waiting on this object's monitor
C: Wakes up all threads that are waiting on this object's monitor
D: None of the above

Q. No. 29
Question:

ADP/DI/27_R00 Page 13 of
19
ACTS, C-DAC

What is synchronization in reference to a thread?

Answer Choices
A: It’s a process of handling situations when two or more threads need access to a shared
resource
B: It’s a process by which many thread are able to access same shared resource
simultaneously
C: It’s a process by which a method is able to access many different threads
simultaneously
D: It’s a method that allow too many threads to access any information the require

Q. No. 30
Question:
Which of the following are methods of the Thread class?
I. yield()
II. sleep(long msec)
III. go()
IV. stop()

Answer Choices
A: (I), (II) and (IV)
B: (I) and (III)
C: Only (III)
D: All of the mentioned above

Q. No. 31
Question:
What will be the output of the following Java program?

import java.net.*;

ADP/DI/27_R00 Page 14 of
19
ACTS, C-DAC

class networking {
public static void main(String[] args) throws UnknownHostException {
InetAddress obj1 = InetAddress.getByName("cisco.com");
System.out.print(obj1.getHostName());
}
}

Answer Choices
A: cisco
B: cisco.com
C: www.cisco.com
D: none of the mentioned

Q. No. 32
Question:
How many ports of TCP/IP are reserved for specific protocols?

Answer Choices
A: 10
B: 1024
C: 2048
D: 512

Q. No. 33
Question:
Which of the following is not a JDBC connection isolation levels?

Answer Choices
A: TRANSACTION_NONE

ADP/DI/27_R00 Page 15 of
19
ACTS, C-DAC

B: TRANSACTION_READ_COMMITTED
C: TRANSACTION_REPEATABLE_READ
D: TRANSACTION_NONREPEATABLE_READ

Q. No. 34
Question:
Which of the following is advantage of using PreparedStatement in Java?

Answer Choices
A: Slow performance
B: Encourages SQL injection
C: Prevents SQL injection
D: More memory usage

Q. No. 35
Question:
Which of the following is method of JDBC batch process?

Answer Choices
A: setBatch()
B: deleteBatch()
C: removeBatch()
D: addBatch()

Q. No. 36
Question:
Which method Drops all changes made since the previous commit/rollback?

ADP/DI/27_R00 Page 16 of
19
ACTS, C-DAC

Answer Choices
A: public void rollback()
B: public void commit()
C: public void close()
D: public Statement createStatement()

Q. No. 37
Question:
On which of these does annotations can be used on in Java 8?

Answer Choices
A: Local variables
B: Super classes
C: Generic types
D: All of these

Q. No. 38
Question:
What needs to be implemented to use lambda expression ?

Answer Choices
A: Functional interface
B: Functional class
C: Functional method
D: Functional object

Q. No. 39
Question:
What will be the output of the following Java program?

ADP/DI/27_R00 Page 17 of
19
ACTS, C-DAC

class X {
int a;
double b;
}

class Y extends X {
int c;
}

class Output {
public static void main(String args[]) {
X a = new X();
Y b = new Y();
Class obj;
obj = b.getClass();
System.out.print(obj.getSuperclass());
}
}

Answer Choices
A: X
B: Y
C: class X
D: class Y

ADP/DI/27_R00 Page 18 of
19
ACTS, C-DAC

Q. No. 40
Question:
How private method can be called using reflection?

Answer Choices
A: getDeclaredFields
B: getDeclaredMethods
C: getMethods
D: getFields

ADP/DI/27_R00 Page 19 of
19

You might also like