1. Which command is used for running Java programs?
- Java
- Javae
- Javac
- Javar
2. Which is the right syntax for creating object?
- Emp e
- Emp e=new Emp()
- Emp e=new Emp
- Emp e=Emp()
3. Which keyword is used for defining constants?
- const
- final
- define
- none of the above
4. Which access specifier allows members to be accessed only from the class and child classes?
- public
- private
- protected
- Default
5. Which of the following is checked exception?
- Arithmetic
- ArrayIndexOutOfBoundException
- FileNotFoundException
- SQLException
6. Which keywork is used for deriving an interface?
- extends
- derives
- implements
- inherit
7. Which class is character stream class?
- FileReader
- FileStream
- FileInputStream
- RandomFile
8. Which of the following is not container?
- Frame
- Panel
- Dialog
- TextField
9. Which interface needs to be implemented for handling button click events?
- ActionListener
- KeyListener
- ClickListener
- All of the above
10. Which JDBC driver is also called thin driver?
- Type 1
- Type 2
- Type 3
- Type 4
MCQ Final Paper 2079(i)
1. What is constructor?
- Same named function as class name
- Input function that initializes variables
- Function that is used to construct class in java
- Garbage collector function
2. Why super keyword is used in inheritance?
- To represent the sub class and super class
- To access member of parent class
- To derive new.class
- To reference to member of derived classes
3. Why JDBC is there in java?
- To create web form
- To handle file
- To create database and execute queries
- To initialize object
4. How new class is derived from old class in java?
- class child extends parent{}
- class child implements parent{}
- class child: public parent{}
- class child as parent{}
5. Why static keyword is always there in front of main method in Java?
- Because static keyword should be used for void methods
- Because main method is public
- Because main method is built in method
- Because main method needs to be invoked before any object instantiation
6. Which of the following is not the valid loop statement in Java?
- while(true){}
- for(datatype var: array){}
- for(false){}
- do{}while(false);
7. What is late binding in Java?
- Association of methods and classes in runtime
- Association of object and methods in runtime
- Association of derived class and base class in runtime
- All of the above
8. Which of the following method is used to execute alter statement of SQL in Java program?
- createStatement()
- execute()
- executeUpdate()
- executeQuery()
9. Which of the following is not the string methods in Java?
- trim()
- String()
- indexOf()
- gets()
10. Exception class in Java is derived from
- Throwable
- JavaLangException
- RuntimeException
- CompileTimeException
MCQ Final Paper 2077
1. What stands for JRE?
- Java Runtime Environment
- JVM Runtime Environment
- Java Robust Environment
- JVM Robust Environment
2. Which statement is used for terminating loops?
- break
- terminate
- final
- None of the above
3. Which statement is false about constructors?
- It does not have return type
- Its name is same as the name of class
- It cannot contain arguments
- It is invoked automatically
4. Which of the following is valid syntax of single inheritance?
- class extends class B
- class A: class B
- class A extends B
- class A: B
5. Which keyword is used for accessing members of parent class?
- parent
- base
- super
- sup
6. How many numbers of threads can be in ready state at a time?
- one
- two
- four
- Many
7. Which of the following is byte stream class?
- FileReader
- FileWriter
- FileInputStream
- All of the above
8. Which package contains classes related to event handling?
- Java.awt
- Javax.swing
- Java.awt.event
- Javax.swing.event
9. What is name of method used for running Insert commands in JDBC?
- execute
- executeUpdate
- executeQuery
- executelnsert
10. Which of the following is default access specifier for interfaces?
- private
- public
- protected
- default
MCQ Final Paper 2076
1. Which of these keywords is used by a class to use an interface defined previously?
- import
- Import
- implements
- Implements
2. In a java program, which of the following is true about package declaration?
- must precede
- must succeed
- may precede or succeed
- None
3. Which method is called internally by Thread start() method?
- execute()
- run()
- launch()
- main()
4. Using which keyword we can access value of the instance variables and class variables inside the method of the class?
- super
- final
- this
- either super or this
5. Which component is used to compile, debug and execute java program?
- JVM
- JDK
- JIT
- JRE
6. Which of these keywords is not a part of exception handling?
- try
- finally
- thrown
- catch
7. Which of the following statements about abstract methods/classes in Java is true?
- An abstract class cannot be instantiated.
- Constructors can be abstract.
- A subclass of an abstract class must defined the abstract methods.
- Static methods may be declared abstract.
8. Which keyword is used to insert interface by another interface?
- public
- implements
- extends
- class
9. What type of event is generated when the user presses the enter key in a JTextField?
- ActionEvent
- ActionListener
- TextEvent
- ItemEvent
10. Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?
- Type 1
- Type 2
- Type 3
- Type 4
MOST PROBABLE
- Which feature of Java allows a method to have multiple forms?
✔ Polymorphism
Inheritance
Encapsulation
Abstraction -
Which keyword is used to achieve inheritance in Java?
✔ extends
implements
inherits
super -
Which of the following is not a primitive data type in Java?
int
float
✔ String
char -
What is the default value of an int variable in Java class?
✔ 0
null
undefined
1 -
Which method is used to compare two strings in Java?
compare()
==
✔ equals()
match() -
Which memory area is used for object storage in Java?
Stack
✔ Heap
Register
Cache -
Which keyword is used to prevent inheritance in Java?
✔ final
static
abstract
private -
What is JVM in Java?
Java Variable Machine
✔ Java Virtual Machine
Java Verified Machine
Java Visual Model -
Which collection allows duplicate elements?
Set
Map
✔ List
Tree -
Which of the following is used for dynamic method dispatch?
Method overloading
✔ Method overriding
Constructor
Static method -
Which keyword is used to handle exceptions?
try
throw
✔ catch
all of the above -
What is the parent class of all classes in Java?
String
✔ Object
Class
System -
Which operator is used for object comparison?
=
==
✔ equals()
:= -
Which of the following is not a feature of Java?
Platform independent
Object oriented
✔ Use of pointers
Secure -
Which interface is used for sorting collections?
✔ Comparable
Runnable
Serializable
Cloneable - Which keyword is used to create object in Java?
new ✔ new
create
object
make -
Which of the following is a runtime exception?
IOException
SQLException
✔ ArithmeticException
FileNotFoundException -
Which method is the entry point of Java program?
start()
run()
main() ✔ main()
init() -
Which keyword is used to refer current object?
this ✔ this
super
self
current -
Which of the following is used for thread creation?
Runnable ✔ Runnable
Stream
Collection
Map -
Which package is imported by default in Java?
java.util
java.io
java.lang ✔ java.lang
java.awt -
Which operator is used for logical AND in Java?
&
&& ✔ &&
||
! -
Which loop executes at least once?
for
while
do-while ✔ do-while
foreach -
Which keyword is used for exception throwing?
throw ✔ throw
catch
try
final -
Which of the following is not OOP concept?
Inheritance
Polymorphism
Compilation ✔ Compilation
Encapsulation -
Which class is used for file handling in Java?
Scanner
File ✔ File
String
System -
Which JDBC method is used to fetch data?
executeUpdate()
execute()
executeQuery() ✔ executeQuery()
runQuery() -
Which keyword prevents method overriding?
final ✔ final
static
private
abstract -
Which interface is used for input stream?
OutputStream
InputStream ✔ InputStream
Reader
Writer -
Which AWT component is used for text input?
Label
Button
TextField ✔ TextField
Checkbox -
Which of the following is used to handle mouse events?
KeyListener
MouseListener ✔ MouseListener
ActionListener
ItemListener -
Which collection does not allow duplicate elements?
List
ArrayList
Set ✔ Set
Vector -
Which keyword is used to inherit interface?
extends ✔ extends
implements
inherit
super -
Which is not a valid Java access modifier?
public
private
protected
internal ✔ internal -
Which class is parent of all exception classes?
Object
Throwable ✔ Throwable
Error
Runtime - Which keyword is used to declare an interface?
interface ✔ interface
class
implements
abstract - Which of the following is not a feature of Java?
Object-oriented
Platform independent
Pointer arithmetic ✔ Pointer arithmetic
Secure - Which method is used to start a thread?
run()
execute()
start() ✔ start()
begin() - Which class is used to read input from keyboard in Java?
Scanner ✔ Scanner
Buffer
Input
ReaderOnly - Which keyword is used for memory allocation in Java?
malloc
alloc
new ✔ new
create - Which statement is used to exit from loop?
exit
stop
break ✔ break
return - Which of the following is a wrapper class?
int
float
Integer ✔ Integer
char - Which keyword is used for multiple inheritance in Java?
extends
implements ✔ implements
inherits
super - Which exception occurs when array index is wrong?
NullPointerException
IOException
ArrayIndexOutOfBoundsException ✔ ArrayIndexOutOfBoundsException
ArithmeticException - Which method converts string to integer?
parseInt() ✔ parseInt()
toString()
valueOf()
convert() - Which of the following is immutable in Java?
Array
String ✔ String
Object
List - Which keyword is used to define constant variable?
final ✔ final
const
static
define - Which method is used to print output in Java?
print()
System.out.println() ✔ System.out.println()
echo()
write() - Which JDBC object is used to execute SQL query?
Connection
Statement ✔ Statement
ResultSet
Driver - Which loop is best for fixed number of iterations?
while
do-while
for ✔ for
if - Which class is used for writing to a file?
FileReader
FileWriter ✔ FileWriter
FileInput
FileOutput - Which keyword is used for exception handling block?
try ✔ try
loop
check
error - Which of the following is not a Java keyword?
static
void
main ✔ main
class - Which method is used to compare two objects?
equals() ✔ equals()
compare()
check()
same() - Which package contains AWT classes?
java.io
java.util
java.awt ✔ java.awt
java.net
0 comments:
Post a Comment