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

Objective Questions-Java

The document contains 17 multiple choice questions about Java concepts and features. Some of the key topics covered include: - Bytecode execution by the JVM leading to Java's portability and security. - The use of pointers not being a Java feature. - The execution order of a class's methods, blocks and constructor. - Java being a platform independent language. - The .java file extension for Java code files. - Exception handling and polymorphism in Java.

Uploaded by

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

Objective Questions-Java

The document contains 17 multiple choice questions about Java concepts and features. Some of the key topics covered include: - Bytecode execution by the JVM leading to Java's portability and security. - The use of pointers not being a Java feature. - The execution order of a class's methods, blocks and constructor. - Java being a platform independent language. - The .java file extension for Java code files. - Exception handling and polymorphism in Java.

Uploaded by

neha yarrapothu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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

2. Which of the following is not a Java features?

a) Dynamic
b) Architecture Neutral
c) Use of pointers
d) Object-oriented

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

4. Which statement is true about Java?


a) Java is a sequence-dependent programming language
b) Java is a code dependent programming language
c) Java is a platform-dependent programming language
d) Java is a platform independent programming language
5. Which component is used to compile, debug and execute the java programs?
a) JRE
b) JIT
c) JDK
d) JVM
6. What is the extension of java code files?
a) .js
b) .txt
c) .class
d) .java
7. What will be the output of the following Java code? 32

class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
8. What is not the use of “this” keyword in Java?
a) Referring to the instance variable when a local variable has the same name
b) Passing itself to the method of the same class
c) Passing itself to another method
d) Calling another constructor in constructor chaining
9. Which of the following is a type of polymorphism in Java Programming?
a) Multiple polymorphism
b) Compile time polymorphism
c) Multilevel polymorphism
d) Execution time polymorphism
10. What is the extension of compiled java classes?
a) .txt
b) .js
c) .class
d) .java
11. Which exception is thrown when java is out of memory?
a) MemoryError
b) OutOfMemoryError
c) MemoryOutOfBoundsException
d) MemoryFullException
12. What will be the output of the following Java program?
class Alligator
{
public static void main(String[] args)
{
int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};
int [][]y = x;
System.out.println(y[2][1]);
}
}
a) Compilation Error
b) 2
c) 3
d) 7
13. Which of these are selection statements in Java?
a) break
b) continue
c) for()
d) if()
14. Which of these keywords is used to define interfaces in Java?
a) intf
b) Intf
c) interface
d) Interface
15. Which of these class is a superclass of every class in Java?
a) ArrayList class
b) Abstract class
c) Object class
d) String class
16. Which of these keywords can be used to prevent Method overriding in Java?
a) final
b) protected
c) static
d) constant
17. Which of these keywords are used for the block to be examined for exceptions?
a) check
b) throw
c) catch
d) try
18. Which one of the following is not an access modifier?
a) Protected
b) Void
c) Public
d) Private

You might also like