Cutm1031 JT MCQ 6
Cutm1031 JT MCQ 6
ANDHRA PRADESH
EXAMINATION CELL
MODULE NO: 1
S.
NO
1 What will be the output of the following
Java code?
class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
A 32 YES
B 33
C 24
D 25
2 Which of the following is not an OOPS
concept in Java?
A Polymorphism
B Inheritance
C Compilation YES
D Encapsulation
3 An expression involving byte, int, and
literal numbers is promoted to which of
these?
A int YES
B long
C byte
D float
4 Which of the following for loops will be
an infinite loop?
A for(; ;)
B for(i=0 ; i<1; i--)
C for(i=0; ; i++)
D All of the above YES
5 What will be the output of the following
Java code?
class area {
public static void main(String args[])
{
double r, pi, a;
r = 9.8;
pi = 3.14;
a = pi * r * r;
System.out.println(a);
}
}
A 301.5656 YES
B 301
C 301.56
D 301.56560000
6 Which of these coding types is used for
data type characters in Java?
A ASCII
B ISO-LATIN-1
C UNICODE YES
D None of the mentioned
7 Which one is a valid declaration of a
boolean?
A boolean b1 = 1;
B boolean b2 = ‘false’;
C boolean b3 = false; YES
D boolean b4 = ‘true’
8 What will be the output of the following
Java program?
class mainclass {
public static void main(String args[])
{
char a = 'A';
a++;
System.out.print((int)a);
}
}
A 66 YES
B 67
C 65
D 64
9 What will be the output of the following
Java program?
class mainclass {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
if (var1)
System.out.println(var1);
else
System.out.println(var2);
}
}
A 0
B 1
C true YES
D false
10 Which of these can not be used for a
variable name in Java?
A identifier
B keyword YES
C identifier & keyword
D none of the mentioned
11 What will be the output of the following
Java program?
class dynamic_initialization
{
public static void main(String args[])
{
double a, b;
a = 3.0;
b = 4.0;
double c = Math.sqrt(a * a + b
* b);
System.out.println(c);
}
}
A 5.0 YES
B 25.0
C 7.0
D Compilation Error
12 Which of these is necessary condition for
automatic type conversion in Java?
A The destination type is smaller than
source type
B The destination type is larger than YES
source type
C The destination type can be larger or
smaller than source type
D None of the mentioned
13 What is Truncation is Java?
A Floating-point value assigned to an YES
integer type
B Integer value assigned to floating
type
C Floating-point value assigned to an
Floating type
D Integer value assigned to floating
type
14 What will be the output of the following
Java code?
class char_increment
{
public static void main(String args[])
{
char c1 = 'D';
char c2 = 84;
c2++;
c1++;
System.out.println(c1 + " " + c2);
}
}
A EU YES
B UE
C VE
D UF
15 What will be the output of the following
Java program?
class increment
{
public static void main(String args[])
{
double var1 = 1 + 5;
double var2 = var1 / 4;
int var3 = 1 + 5;
int var4 = var3 / 4;
System.out.print(var2 + " " +
var4);
}
}
A 11
B 01
C 1.5 1 YES
D 1.5 1.0
16 What will be the output of the following
Java program?
class Modulus
{
public static void main(String args[])
{
double a = 25.64;
int b = 25;
a = a % 10;
b = b % 10;
System.out.println(a + " " + b);
}
}
A 5.640000000000001 5 YES
B 5.640000000000001 5.0
C 55
D 5 5.640000000000001
17 What will be the output of the following
Java program?
class Output
{
public static void main(String args[])
{
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
b++;
++a;
System.out.println(a + " " + b + " "
+ c);
}
}
A 324
B 323
C 234
D 344 YES
18 Which of these statements are
incorrect?
class bitwise_operator
{
public static void main(String args[])
{
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d);
}
}
A 72 YES
B 77
C 75
D 52
20 Which of these is returned by “greater
than”, “less than” and “equal to”
operators?
A Integers
B Floating – point numbers
C Boolean YES
D None of the mentioned
21 Which of the following operators can
operate on a boolean variable?
1. &&
2. ==
3. ?:
4. +=
A 3&2
B 1&4
C 1, 2 & 4
D 1, 2 & 3 YES
22 Which of these operators can skip
evaluating right hand operand(skip
evaluating right hand operand when
output can be determined by left
operand alone)?
A !
B |
C &
D && YES
23 What will be the output of the following
Java code?
class bool_operator
{
public static void main(String args[])
{
boolean a = true;
boolean b = !true;
boolean c = a | b;
boolean d = a & b;
boolean e = d ? b : c;
System.out.println(d + " " + e);
}
}
A false false
B true ture
C true false
D false true YES
24 What will be the output of the following
Java code?
class ternary_operator
{
public static void main(String args[])
{
int x = 3;
int y = ~ x;
int z;
z = x > y ? x : y;
System.out.print(z);
}
}
A 0
B 1
C 3 YES
D -4
25 What will be the output of the following
Java code?
class Output
{
public static void main(String args[])
{
boolean a = true;
boolean b = false;
boolean c = a ^ b;
System.out.println(!c);
}
}
A 0
B 1
C false YES
D true
26 Which of these statements are
incorrect?
A Equal to operator has least precedence
B Brackets () have highest precedence
C Division operator, /, has higher YES
precedence than multiplication operator
D Addition operator, +, and subtraction
operator have equal precedence
27 What will be the output of the following
Java code?
class operators
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
int var3;
var3 = ++ var2 * var1 / var2 +
var2;
System.out.print(var3);
}
}
A 10
B 11
C 12 YES
D 56
28 Which of these lines of Java code will
give better performance?
1. a | 4 + c >> b & 7;
2. (a | ((( 4 * c ) >> b ) & 7 ))
class selection_statements
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}
A 1
B 2 YES
C 3
D 4
32 What will be the output of the following
Java program?
class comma_operator
{
public static void main(String args[])
{
int sum = 0;
for (int i = 0, j = 0; i < 5 & j < 5; +
+i, j = i + 1)
sum += i;
System.out.println(sum);
}
}
A 5
B 6 YES
C 14
D compilation error
33 What will be the output of the following
Java program?
class jump_statments
{
public static void main(String args[])
{
int x = 2;
int y = 0;
for ( ; y < 10; ++y)
{
if (y % x == 0)
continue;
else if (y == 8)
break;
else
System.out.print(y + " ");
}
}
}
A 1357
B 2468
C 13579 YES
D 123456789
34 What would be the output of the
following code snippet if variable a=10?
if(a<=0)
{
if(a==0)
{
System.out.println("1 ");
}
else
{
System.out.println("2 ");
}
}
System.out.println("3 ");
A 12
B 23
C 13
D 3 YES
35 What is true about do statement?
A do statement executes the code of a YES
loop at least once
B do statement does not get execute if
condition is not matched in the first
iteration
C do statement checks the condition at the
beginning of the loop
D do statement executes the code more
than once always
36 Which of the following is not a valid flow
control statement?
A exit() YES
B Break
C Continue
D return
37 Which concept of Java is achieved by
combining methods and attribute into a
class?
A Encapsulation YES
B Inheritance
C Polymorphism
D Abstraction
38 Which component is responsible for
converting bytecode into machine
specific code?
A JVM
B JDK YES
C JIT
D JRE
39 Which component is responsible to run
java program?
A JVM
B JDK
C JIT
D JRE YES
40 What is the extension of compiled java
classes?
A .class YES
B .java
C .txt
D .js
41 What is use of interpreter?
A They convert bytecode to machine
language code
B They read high level code and execute YES
them
C They are intermediated between JIT and
JVM
D It is a synonym for JIT
B alloc
C new YES
D give
class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
obj.width = 10;
obj.height = 2;
obj.length = 10;
int y = obj.width * obj.height *
obj.length;
System.out.print(y);
}
}
A 12
B 200 YES
C 400
D 100
class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
System.out.println(obj);
}
}
A 0
B 1
C Runtime error
int i = 1, j = 10;
do
{ if(i > j)
{
break;
}
j--;
} while (++i < 5);
System.out.println("i = " + i + " and j = " +
j);
A i = 6 and j = 5
B i = 5 and j = 5
C i = 6 and j = 4
D i = 5 and j = 6 YES
continue;
}
System.out.println(i);
}
}
}
B 1,2,3,4, YES
C 1,2,3,4
D Compiler error
A 1,2,3,4,1,2,3,4,
B 1,2,3,4, YES
C 1,2,3,1,2,3,
D 1,2,3,
ANDHRA PRADESH
EXAMINATION CELL
MODULE NO: 2
S. MCQ
NO
1 What will be the output of the following
Java program?
import java.lang.reflect.*;
class Additional_packages
{
public static void main(String args[])
{
try
{
Class c =
Class.forName("java.awt.Dimension");
Field fields[] =
c.getFields();
for (int i = 0; i <
fields.length; i++)
System.out.println(fields[i]);
}
catch (Exception e)
{
System.out.print("Exception");
}
}
}
import java.lang.reflect.*;
class Additional_packages
{
public static void main(String args[])
{
try
{
Class c =
Class.forName("java.awt.Dimension");
Constructor
constructors[] = c.getConstructors();
for (int i = 0; i <
constructors.length; i++)
System.out.println(constructors[i]);
}
catch (Exception e)
{
System.out.print("Exception");
}
}
}
D Runtime Error
3 Which of this package is used for
invoking a method remotely?
A java.rmi YES
B java.awt
C java.util
D java.applet
4 Which of these class allows us to get real
time data about private and protected
member of a class?
A java.io
B GetInformation
C ReflectPermission YES
D MembersPermission
5 Which of this package is used for
handling security related issues in a
program?
A java.security YES
B java.lang.security
C java.awt.image
D java.io.security
6 Which of this package is used for
analyzing code during run-time?
A java.applet
B java.awt
C java.io
D java.lang.reflect YES
7 Which of these package is used for
graphical user interface?
A java.applet
B java.awt YES
C java.awt.image
D java.io
8 Which of these keywords is used to
define interfaces in Java?
A interface YES
B Interface
C intf
D Intf
9 Which of these can be used to fully
abstract a class from its implementation?
A Objects
B Packages
C Interfaces YES
A Public YES
B Protected
C private
A import
B Import
C implements
D Implements YES
12 Which of the following is the correct way
of implementing an interface salary by
class manager?
interface calculate
{
void cal(int item);
}
class display implements calculate
{
int x;
public void cal(int item)
{
x = item * item;
}
}
class interfaces
{
public static void main(String args[])
{
display arr = new display;
arr.x = 0;
arr.cal(2);
System.out.print(arr.x);
}
}
A 0
B 2
C 4 YES
D None of the mentioned
15 What will be the output of the following
Java program?
interface calculate
{
void cal(int item);
}
class displayA implements calculate
{
int x;
public void cal(int item)
{
x = item * item;
}
}
class displayB implements calculate
{
int x;
public void cal(int item)
{
x = item / item;
}
}
class interfaces
{
public static void main(String args[])
{
displayA arr1 = new displayA;
displayB arr2 = new displayB;
arr1.x = 0;
arr2.x = 0;
arr1.cal(2);
arr2.cal(2);
System.out.print(arr1.x + " " +
arr2.x);
}
}
A 00
B 22
C 41 YES
D 14
16 Which of the following access specifiers
can be used for an interface?
A Protected YES
B Private
C Public
A public static
B private final
C public final
A Method definition
D Method name
20 What type of methods an interface
contain by default?
A abstract YES
B static
C final
D private
21 What will happen if we provide concrete
implementation of method in interface?
B Runtime Exception
A Compilation failure
B Runtime Exception
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
Graphic g;
g.drawString("A Simple
Applet",20,20);
}
A 20
B Default value
D Runtime Error
25 What will be the output of the following
Java program?
import java.lang.reflect.*;
class Additional_packages
{
public static void main(String args[])
{
try
{
Class c =
Class.forName("java.awt.Dimension");
Method methods[] =
c.getMethods();
for (int i = 0; i <
methods.length; i++)
System.out.println(methods[i]);
}
catch (Exception e)
{
System.out.print("Exception");
}
}
}
A try
B throw
C throws YES
D catch
27 Which of these class is related to all the
exceptions that are explicitly thrown?
A Error
B Exception
C Throwable YES
D Throw
28 Which of these keywords is used to
generate an exception explicitly?
A try
B finally
C throw YES
D catch
29 What exception thrown by parseInt()
method?
A ArithmeticException
B ClassNotFoundException
C NullPointerException
D NumberFormatException YES
30 Which of these handles the exception
when no catch is used?
B finally
C throw handler
A Error YES
B Exception
C RuntimeExecption
A Error
B Exception YES
C RuntimeExecption
A String
B RuntimeExceptions
C Throwable YES
D Cacheable
34 Which of the following should be true of
the object thrown by a thrown
statement?
A finally YES
B try
C catch
D throw
36 Which of the following handles the
exception when a catch is not used?
A finally
B throw handler
A throws YES
B throw
C try
D catch
38 Which of the following operators is used
to generate instance of an exception
which can be thrown using throw?
A thrown
B alloc
C malloc
D new YES
39 Which of the following is a super class of
all exception type classes?
A Catchable
B RuntimeExceptions
C String
D Throwable YES
40 Which of the following classes can catch
all exceptions which cannot be caught?
A RuntimeException
B Error YES
C Exception
D ParentException
41 Which of the following keywords is used
for throwing exception manually?
A finally
B try
C throw YES
D catch
class exception_handling
{
public static void main(String args[])
{
try
{
int i, sum;
sum = 10;
for (i = -1; i < 3 ;++i)
sum = (sum / i);
}
catch(ArithmeticException e)
{
System.out.print("0");
}
System.out.print(sum);
}
}
A 0
B 05
D Runtime Error
class exception_handling
{
public static void main(String args[])
{
try
{
int a, b;
b = 0;
a = 5 / b;
System.out.print("A");
}
catch(ArithmeticException e)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
}
}
A A
B B
C AC
D BC YES
class exception_handling
{
public static void main(String args[])
{
try
{
int a, b;
b = 0;
a = 5 / b;
System.out.print("A");
}
catch(ArithmeticException e)
{
System.out.print("B");
}
}
}
A A
B B YES
C Compilation Error
D Runtime Error
class exception_handling
{
public static void main(String args[])
{
try
{
System.out.print("Hello" + " " +
1 / 0);
}
catch(ArithmeticException e)
{
System.out.print("World");
}
}
}
A Hello
B World YES
C HelloWorld
D Hello World
A try
B finally
C throw YES
D catch
A try
B finally
C throw
D catch YES
A try YES
B finally
C throw
D catch
A try
B finally
C thrown YES
D catch
B Compilation Time
ANDHRA PRADESH
EXAMINATION CELL
S.
NO
1 Which of these class can generate an
array which can increase and decrease in
size automatically?
A ArrayList() YES
B DynamicList()
C LinkedList()
D MallocList()
2 What will be the output of the following
Java program?
import java.util.*;
class Arraylist
{
public static void main(String args[])
{
ArrayList obj = new ArrayList();
obj.add("A");
obj.add("B");
obj.add("C");
obj.add(1, "D");
System.out.println(obj);
}
}
A [A, B, C, D]
B [A, D, B, C] YES
C [A, D, C]
D [A, B, C]
3 Which of these method of ArrayList class
is used to obtain present size of an
object?
A size() YES
B length()
C index()
D capacity()
4 Which of the below does not implement
Map interface?
A HashMap
B Hashtable
C EnumMap
D Vector YES
5 What is the difference between TreeSet
and SortedSet?
A ArrayList
B HashSet YES
C LinkedList
D DynamicList
7 What will be the output of the following
Java program?
import java.util.*;
class Output
{
public static void main(String args[])
{
HashSet obj = new HashSet();
obj.add("A");
obj.add("B");
obj.add("C");
System.out.println(obj + " " +
obj.size());
}
}
A ABC 3
B [A, B, C] 3 YES
C ABC 2
D [A, B, C] 2
8 What will be the output of the following
Java program?
import java.util.*;
class Output
{
public static void main(String args[])
{
TreeSet t = new TreeSet();
t.add("3");
t.add("9");
t.add("1");
t.add("4");
t.add("8");
System.out.println(t);
}
}
A [1, 3, 5, 8, 9]
B [3, 4, 1, 8, 9]
C [9, 8, 4, 3, 1]
D [1, 3, 4, 8, 9] YES
9 Which of these object stores association
between keys and values?
A Hash table
B Map YES
C Array
D String
10 Which of these classes provide
implementation of map interface?
A ArrayList
B HashMap YES
C LinkedList
D DynamicList
11 Which of these method Map class is used
to obtain an element in the map having
specified key?
A search()
B get() YES
C set()
D look()
12 What will be the output of the following
Java program?
import java.util.*;
class Maps
{
public static void main(String args[])
{
HashMap obj = new HashMap();
obj.put("A", new Integer(1));
obj.put("B", new Integer(2));
obj.put("C", new Integer(3));
System.out.println(obj.keySet());
}
}
A [A, B, C] YES
B {A, B, C}
C {1, 2, 3}
D [1, 2, 3]
13 Which of these class object can be used
to form a dynamic array?
A ArrayList
B Map
C Vector
A Integer YES
B Float
C double
D long
16 Which of these statements is incorrect?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t =
Thread.currentThread();
System.out.println(t);
}
}
A Thread[5,main]
B Thread[main,5]
C Thread[main,0]
D Thread[main,5,main] YES
18 What is the priority of the thread in the
following Java Program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t =
Thread.currentThread();
System.out.println(t);
}
}
A 4
B 5 YES
C 0
D 1
19 What is the name of the thread in the
following Java Program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t =
Thread.currentThread();
System.out.println(t);
}
}
A main YES
B Thread
C System
A get()
B ThreadPriority()
C getPriority() YES
D getThreadPriority()
21 Which of these method of Thread class is
used to Suspend a thread for a period of
time?
A sleep() YES
B terminate()
C suspend()
D stop()
22 Which function of pre defined class
Thread is used to check weather current
thread being checked is still running?
A isAlive() YES
B Join()
C isRunning()
D Alive()
23 What is the name of the thread in output
in the following Java program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t =
Thread.currentThread();
System.out.println(t.getPriority());
}
}
A 0
B 1
C 4
D 5 YES
24 What is the name of the thread in output
in the following Java program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t =
Thread.currentThread();
System.out.println(t.isAlive());
}
}
A 0
B 1
C TRUE YES
D FALSE
25 Which of these method is used to
implement Runnable interface?
A stop()
B run() YES
C runThread()
D stopThread()
26 Which of these method is used to begin
the execution of a thread?
A run()
B start() YES
C runThread()
D startThread()
27 Which of these statement is incorrect?
System.out.println(t.getName());
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
A My Thread YES
B Thread[My Thread,5,main]
C Compilation Error
D Runtime Error
29 What will be the output of the following
Java code?
t.setPriority(Thread.MAX_PRIORITY);
System.out.println(t);
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
A Thread[New Thread,0,main]
B Thread[New Thread,1,main]
C Thread[New Thread,5,main]
A stop()
B sleep() YES
C join()
D call()
31 What is the default value of priority
variable MIN_PRIORITY AND
MAX_PRIORITY?
A 0 & 256
B 0&1
C 1 & 10 YES
D 1 & 256
32 Which of these method is used to
explicitly set the priority of a thread?
A set()
B make()
C setPriority() YES
D makePriority()
33 What is synchronization in reference to a
thread?
A Thread YES
B Process
C Thread and Process
A Process
C User Thread
D JVM Thread
36 What decides thread priority?
A Process
B Process scheduler
C Thread
B Thread(int priority)
D Thread(Runnable a, ThreadGroup t)
39 Which of the following will ensure the
thread will be in running state?
A yield()
B notify()
C wait() YES
D Thread.killThread()
40 Which of these keywords are used to
implement synchronization?
A synchronize
B syn
C synch
D synchronized YES
41 What is synchronization in reference to a
thread?
A java.lang
B java.util YES
C java.net
D java.awt
B A group of classes
C A group of interfaces
A set
B EventListner
C Comparator
D Collection YES
A Process based
B Thread based
A get()
B ThreadPriority()
C getPriority() YES
D getThreadPriority()
A sleep()
B isAlive()
C join() YES
D stop()
A java.io
B java.util
C java.lang YES
D java.net
EXAMINATION CELL
MODULE NO: 4
S.
NO
1 String in Java is a?
A class YES
B object
C variable
D character array
2 Which of these method of String class is used
to obtain character at specified index?
A char()
B Charat()
C charat()
D charAt() YES
3 Which of these keywords is used to refer to
member of base class from a subclass?
A upper
B super YES
C this
D none of the mentioned
4 Which defines a method called nextElement
that is used to get the next element in a data
structure that contains multiple elements?
A Bitset
B Vector
C Stack
D Enumeration YES
5 Consider the following two statements
int x = 25;
Integer y = new Integer(33);
What is the difference between these two
statements?
A Primitive data types
B primitive data type and an object of a wrapper YES
class
C Wrapper class
D None of the above
6 Where does the primitive data type values be
stored?
A Heap Memory
B Stack Memory YES
C Both A & B
D None of the above
7 What package is a part of the wrapper class
which is imported by default into all Java
programs?
A java.lang YES
B java.aw
C java.io
D java.util
8 Which of these method of String class can be
used to test to strings for equality?
A isequal()
B isequals()
C equal()
D equals() YES
9 Which of the following statements are
incorrect?
A String is a class
B Strings in java are mutable YES
C Every string is an object of class String
D Java defines a peer class of String, called
StringBuffer, which allows string to be altered
10 What will be the output of the following Java
program?
class string_demo
{
public static void main(String args[])
{
String obj = "I" + "like" + "Java";
System.out.println(obj);
}
}
A I
B like
C Java
D IlikeJava
11 What will be the output of the following Java
program?
class string_class
{
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.charAt(3));
}
}
A I YES
B L
C K
D E
12 What will be the output of the following Java
program?
class string_class
{
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.length());
}
}
A 9
B 10
C 11 YES
D 12
13 What will be the output of the following Java
program?
class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = obj;
obj2 = " world";
System.out.println(obj + " " + obj2);
}
}
A hello hello
B world world
C hello world YES
D world hello
14 What will be the output of the following Java
program?
class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = "hello";
System.out.println(obj.equals(obj1) + " "
+ obj.equals(obj2));
}
}
A false false
B true true
C true false
D false true YES
15 Where an object of a class get stored?
A Heap YES
B Stack
C Disk
D File
16 Java uses two stage system for program
execution. They are
A Compiler and instruction
B Compiler and interpreter YES
C Copy and compiler
D None
17 Garbage collection in Java is
A Unused package in a program automatically
gets deleted.
B Memory occupied by objects with no YES
reference is automatically reclaimed for
deletion.
C Java deletes all unused java files on the
system.
D The JVM cleans output of Java program.
18 In what memory area, variable temp and
variable card written in main () get stored?
class CreditCard{
int num;
}
}
A Heap, Heap
B Stack, stack YES
C Heap, Stack
D Stack, Heap
19 Which of the following has the highest
memory requirement?
A Heap
B Stack
C JVM YES
D Class
20 Where is a new object allocated memory?
A Young space
B Old space
C Young or Old space depending on space
availability
D JVM YES
21 If an error occurs during the transaction the
troubleshoot is ____________
A delete
B rollback YES
C commit
D update
22 The variable which represents the default time
zone of the MySQL server is _____________
A time_zone YES
B system_time_zone
C date_and_time
D system_time
23 What creates the appropriate DateFormat
object and adds a day to the Date object?
A 35. DateFormat df =
DateFormat.getDateFormat();
d.setTime( (60 * 60 * 24) + d.getTime());
A SimpleDateFormat YES
B DateFormat
C SimpleFormat
D DateConverter
34 How to convert a String to a Date object?
A SimpleDateFormat sdf = new YES
SimpleDateFormat("yyyy-mm-dd");
sdf.parse(new Date());
class P {
int x = 10;
}
class Q extends P {
int y = 20;
}
s1.id = 18;
System.out.println(s1.id+" "+s2.id);
}
}
A 99
B 18 9 YES
C 9 18
D 18 18
40 Find the output of the below Java program?
D None of these
C It throws CloneNotSupportException.
B Object YES
C int
D String
class Output
{
public static void main(String args[])
{
Integer i = new Integer(257);
float x = i.floatValue();
System.out.print(x);
}
}
A 0
B 1
C 257
D 57.0 YES
class Output
{
public static void main(String args[])
{
char a[] = {'a', '5', 'A', ' '};
System.out.print(Character.isDigit(a[0])
+ " ");
System.out.print(Character.isWhitespac
e(a[3]) + " ");
System.out.print(Character.isUpperCase
(a[2]));
}
}
C Bytevalue()
D Byte Bytevalue()
B Character YES
C String
D Integer
B Digits
C Float
D Number YES
A Integer YES
B Long
C Byte
D Double
A java.lang YES
B java.awt
C java.io
D java.util
ANDHRA PRADESH
EXAMINATION CELL
SUBJECT NAME: (NAME IN FULL): JAVA TECHNOLOGIES
MODULE NO: 5
S.
NO
1 Which of these is used to perform all
input & output operations in Java?
A streams YES
B Variables
C classes
D Methods
2 Which of these is a type of stream in
Java?
A Integer stream
B Short stream
C Byte stream YES
D Long stream
3 Which of these packages contain classes
and interfaces used for input & output
operations of a program?
A java.util
B java.lang
C java.io YES
D all of the mentioned
4 Which of these class is not a member
class of java.io package?
A String YES
B StringReader
C Writer
D File
5 Which of these interface is not a
member of java.io package?
A DataInput
B ObjectInput
C ObjectFilter YES
D FileFilter
6 Which of these class is not related to
input and output stream in terms of
functioning?
A File YES
B Writer
C InputStream
D Reader
7 Which of these is specified by a File
object?
A a file in disk
B directory path
C directory in disk YES
D none of the mentioned
8 Which of these is method for testing
whether the specified element is a file
or a directory?
A IsFile()
B isFile() YES
C Isfile()
D isfile()
9 What will be the output of the following
Java code?
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new
File("/java/system");
System.out.print(obj.getName());
}
}
A java
B system YES
C java/system
D /java/system
10 Which of these class is used to read
from byte array?
A InputStream
B BufferedInputStream
C ArrayInputStream
D ByteArrayInputStream. YES
11 Which of these classes are used by Byte
streams for input and output operation?
A InputStream YES
B InputOutputStream
C Reader
D All of the mentioned
12 Which exception is thrown by read()
method?
A IOException YES
B InterruptedException
C SystemException
D SystemInputException
13 Which of these is used to read a string
from the input stream?
A get()
B getLine()
C read()
D readLine() YES
14 Which of these class is used to read
characters and strings in Java from
console?
A BufferedReader YES
B StringReader
C BufferedStreamReader
D InputStreamReader
15 Which of these classes are used by
character streams for input and output
operations?
A InputStream
B Writer YES
C ReadStream
D InputOutputStream
16 Which of these class is used to read
from byte array?
A InputStream
B BufferedInputStream
C ArrayInputStream
D ByteArrayInputStream YES
17 What will be the output of the following
Java program if input given is
‘abcqfghqbcd’?
class Input_Output
{
public static void main(String args[])
throws IOException
{
char c;
BufferedReader obj = new
BufferedReader(new
InputStreamReader(System.in));
do
{
c = (char) obj.read();
System.out.print(c);
} while(c != 'q');
}
}
A abcqfgh
B abc
C abcq YES
D abcqfghq
18 What will be the output of the following
Java program?
class output
{
public static void main(String args[])
{
StringBuffer c = new
StringBuffer("Hello");
System.out.println(c.length());
}
}
A 4
B 5 YES
C 6
D 7
19 Which of these stream contains the
classes which can work on character
stream?
A InputStream
B OutputStream
C Character Stream YES
D All of the mentioned
20 Which of these class is used to read
characters in a file?
A FileReader YES
B FileWriter
C FileInputStream
D InputStreamReader
21 Which of these method of FileReader
class is used to read characters from a
file?
A read() YES
B scanf()
C get()
D getInteger()
22 Which of these class can be used to
implement the input stream that uses a
character array as the source?
A BufferedReader
B FileReader
C CharArrayReader YES
D FileArrayReader
23 Which of the following is not a segment
of memory in java?
A Stack Segment
B Heap Segment
C Code Segment
D Register Segment YES
24 What is JVM?
A Bootstrap
B Interpreter YES
C Extension
D Compiler
25 Which of these is a method to clear all
the data present in output buffers?
A clear()
B flush() YES
C fflush()
D close()
26 Which of these method(s) is/are used
for writing bytes to an outputstream?
A put()
B print() and write() YES
C printf()
D write() and read()
27 What will be the output of the following
Java program? (Note: inputoutput.java
is stored in the disk.)
import java.io.*;
class filesinputoutput
{
public static void main(String args[])
{
InputStream obj = new
FileInputStream("inputoutput.java");
System.out.print(obj.available());
}
}
A true
B false
C prints number of bytes in file YES
D prints number of characters in the file
28 Which of these classes are used by Byte
streams for input and output operation?
A InputStream YES
B InputOutputStream
C Reader
D All of the mentioned
29 Which of these class is implemented by
FilterInputStream class?
A InputStream
B BufferedInputStream
C FileInputStream YES
D BufferedFileInputStream
30 Which of these class contains the
methods print() & println()?
A System
B System.out
C BUfferedOutputStream
D PrintStream YES
31 Which of these method of class
StringBuffer is used to reverse sequence
of characters
A reverse() YES
B reverseall()
C Reverse()
D reverseAll()
32 Before we try to write applets, we must
make sure that Java is installed properly
and also ensure that either the java is
installed properly and also ensure that
either the java …………….. or a java-
enabled browser is available.
A viewer( )
B appletviewer( ) YES
C appletrunner( )
D browserviewer( )
33 Arrange the steps involved in developing
and testing the applet in correct order.
A True, False
B False, True YES
C True, True
D False, False
35 Applet class is a subclass of the panel
class, which is again a subclass of the
………………….. class.
A object
B component
C awt
D container YES
36 The ………………… method called the first
time an applet is loaded into the
memory of a computer.
A init( ) YES
B start( )
C stop( )
D destroy( )
37 The ……………………… method is called
every time the applet receives focus as a
result of scrolling in the active window.
A init( )
B start( ) YES
C stop( )
D destroy( )
38 Which of the following applet tags is
legal to embed an applet class named
Test into a webpage?
A <applet class=Test width=200
height=100></applet>
B <applet>
code=Test.class width=200 height=100>
</applet>
C <applet code=Test.class width=200 YES
height=100>
</applet>
D <applet
param=Test.class width=200
height=100>
</applet>
39 The …………………. class is an abstract
class that represents the display area of
the applet.
A display
B graphics YES
C text
D area
40 In java applet, we can display numerical
values by first converting them into
string and then using the …………………
method.
A paint( )
B drawstring( ) YES
C draw( )
D convert( )
41 Applets are designed to be embedded
within an __________.
A Javascript
B Css
C HTML YES
D SQL
B JDM
C JVM YES
D Java class
B java class
C Applet class
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("A Simple Applet",
20, 20);
}
}
A 20 YES
B 50
C 100
D System dependent
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("A Simple Applet",
20, 20);
}
}
B A Simple Applet 20 20
C Compilation Error
D Runtime Error
B volatile
C global YES
D No modifier is needed
B print()
C drawString() YES
D transient()
A display()
B paint() YES
C displayApplet()
D PrintApplet()
ANDHRA PRADESH
EXAMINATION CELL
MODULE NO: 6
S.
NO
1 Which of these methods is a part of
Abstract Window Toolkit (AWT) ?
A display()
B paint() YES
C drawString()
D transient()
2 Which of these operators can be used to
get run time information about an
object?
A getInfo
B Info
C instanceof YES
D getinfoof
3 Which of these package is used for text
formatting in Java programming
language?
A java.text YES
B java.awt
C java.awt.text
D java.io
4 Which of these packages contains all the
classes and methods required for even
handling in Java?
A java.applet
B java.awt
C java.event
D java.awt.event YES
5 What is an event in delegation event
model used by Java programming
language?
A An event is an object that describes a YES
state change in a source
B An event is an object that describes a
state change in processing
C An event is an object that describes any
change by the user and system
D An event is a class used for defining
object, to create events
6 Which of these methods are used to
register a keyboard event listener?
A KeyListener()
B addKistener()
C addKeyListener() YES
D eventKeyboardListener()
7 What is a listener in context to event
handling?
A A listener is a variable that is notified
when an event occurs
B A listener is a object that is notified YES
when an event occurs
C A listener is a method that is notified
when an event occurs
D None of the mentioned
8 Event class is defined in which of these
libraries?
A java.io
B java.lang
C java.net
D java.util YES
9 Which of these class is super class of all
the events?
A EventObject YES
B EventClass
C ActionEvent
D ItemEvent
10 Which of these events will be notified if
scroll bar is manipulated?
A ActionEvent
B ComponentEvent
C AdjustmentEvent YES
D WindowEvent
11 Which of these events will be generated
if we close an applet’s window?
A ActionEvent
B ComponentEvent
C AdjustmentEvent
D WindowEvent YES
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 YES
D Container
13 The Swing Component classes that are
used in Encapsulates a mutually
exclusive set of buttons?
A AbstractButton
B ButtonGroup YES
C JButton
D ImageIcon
14 Which package provides many event
classes and Listener interfaces for event
handling?
A java.awt
B java.awt.Graphics
C java.awt.event YES
D None of the above
15 Name the class used to represent a GUI
application window, which is optionally
resizable and can have a title bar, an
icon, and menus.
A Window
B Panel
C Dialog
D Frame YES
16 To use the ActionListener interface it
must be implemented by a class there
are several ways to do that find in the
following?
A Creating a new class
B Using the class the graphical component
C An anonymous inner class
D All mentioned above YES
17 Which is a component in AWT that can
contain another component like buttons,
text fields, labels etc.?
A Window
B Container YES
C Panel
D Frame
18 Which is used to store data and partial
results, as well as to perform dynamic
linking, return values for methods, and
dispatch exceptions?
A Window
B Panel
C Frame YES
D container
19 What are the different types of controls
in AWT?
A Labels
B Pushbuttons
C Checkboxes&Choice list
D All of these YES
20 Give the abbreviation of AWT?
A Applet Windowing Toolkit
B Abstract Windowing Toolkit YES
C Absolute Windowing Toolkit
D None of the above
21 Which class provides many methods for
graphics programming?
A java.awt
B java.Graphics
C java.awt.Graphics YES
D None of the above
22 By which method You can set or change
the text in a Label?
A setText() YES
B getText()
C Both A & B
D None of the above
23 Which class can be used to represent a
checkbox with a textual label that can
appear in a menu.
A MenuBar
B MenuItem
C CheckboxMenuItem YES
D Menu
24 The following specifies the advantages
of It is lightweight. It supports pluggable
look and feel. It follows MVC (Model
View Controller) architecture.
A Swing YES
B AWT
C Both A & B
D None of the above
25 Which are passive controls that do not
support any interaction with the user?
A Choice
B List
C Labels YES
D Checkbox
26 The following way is used to create a
frame is by creating the object of Frame
class?
A inheritance
B association
C Both A & B YES
D None of the above
27 Which of the following classes are
derived from the Component class.
A Container
B Window
C List
D MenuItem YES
28 Which is the container that doesn't
contain title bar and MenuBars but it
can have other components like button,
text field etc?
A Window
B Frame
C Panel YES
D Container
29 Which object can be constructed to
show any number of choices in the
visible window?
A Labels
B Choice
C List YES
D Checkbox
30 What are the different types of controls
in AWT?
A Labels, Pushbuttons, Checkboxes, Choice
lists, Lists, Scrollbars, Text components
B These controls are subclasses of
component
C Both A and B YES
D None
31 What are the component and container
class?
A Button
B Canvas
C Checkbox
D All of these. YES
B Button,Checkbox,Choice
C Scrollbar,Component,Button
42 The following
a) It is lightweight.
b) It supports pluggable look and feel.
c) It follows MVC (Model View
Controller) architecture
are the advantages of _____ .
A Swing YES
B AWT
C Both A & B
B String Handling
B KeyEvent
C WindowEvent
D AdjustmentEvent
B ContainerEvent
C FocusEvent
D InputEvent
B ContainerEvent
C FocusEvent YES
D InputEvent
B ComponentEvent YES
C ItemEvent
D InputEvent
B ContainerEvent
C ItemEvent YES
D InputEvent
A ComponentListener
B ContainerListener
C ActionListener YES
D InputListener
B keyReleased()
C keyTyped() YES
D keyEntered()