JAVA QB-1,2,3
JAVA QB-1,2,3
(a) B
(b) C
(c) C++
(d) D
(a) Dynamic
(b) Object-oriented
(c) Architecture Neutral
(d) Use of pointers
4. In java control statements break, continue, return, try-catch-finally and assert belongs
to?
(a) Transfer statements
(a) .obj
(d) Sourcecode
(c).Exe
(d) Bytecode
(a) java
(b) javac
(c) jar
<br>
(d) javadoc
(b) Colon
(c) Semicolon
(a) main
(b) file
(a) switch
(b) while
(c) public
(d) void
(a) J++
(b) C++
(c) OAK
(d) TEAK
(a) IBM
(b) Microsoft
(c) Oracle
15. Which provides runtime environment for java byte code to be executed?
(a) JDK
(b) JVM
(c) JRE
(d) JAVAC
17. Which of the following is used to interpret and execute Java Applet Classes hosted by
HTML.
(a) appletscreen
(b) appletwatcher
(c) appletshow
(d) appletviewer
(a) javadoc
(b) javahelp
(c) javamanual
(d) none of these
(a) /*
(b) /**
(c) //
(d) None of these
(a) array
(b) method
(c) subclasses
(d) native
(b) JDK
(c) JBM
(d) JRE
(a) byte
(b) while
(c) float
(d) double
(c) JVM provides security to the computer by giving controlled access to Files and Memory
on a computer
31. What type of Java Programs can be run inside a Java supported Web Browser?
(a) AWT
(b) Applets
(c) Struts
(d) Stand alone
<br>
(b) Efficient
(a) 25-05-1995
(b) 29-05-1995
(c) 28-05-1995
(d) 27-05-1995
(b) An Array
(c) A class
(d) Method
35. Which symbol is used to contain the values of automatically initialized arrays?
(a) Braces
(b) Comma
(c) Brackets
(d) Parentheses
36. Java does not define which type modifier?
(a) Auto
(b) Extern
(c) Register
(b) Small code size easy to carry occupying less disk space
(c) Generating suitable Byte Code for each machine by the Compiler
(d) Ability to run the Byte on different machines producing the same behaviour and output
(b) JIT Compiler assists the actual JAVAC compiler to compile fast
(c) JIT Compilertakes chunks of Byte Code as input and produces Executable code on that
particular machine.
(d) None of the above
(b) False
(a) All method names should start with a Lower Case letter.
(b) For all class names the first letter should be in Upper Case
(c) Name of the program file should exactly match the class name.
45. All Java components require names. Names used for classes, variables, and methods are
called?
(a) identifiers
(b) Variables
(c) JRE is an implementation of the Java Virtual Machine which executes Java programs.
(d) None of the above
49. What is the Java distribution type used to build Web Apps in Java?
(a) Java SE
(b) Java EE
(c) Java ME
(a) Ahead of time compiler compiles java files as and when you type and save.
(b) Ahead of time compiler turns byte code to executable code line by line based on
requirement
(c) Ahead of time compiler is a replacement for JIT compiler to translate all byte code to a
single executable file or code to run the program fast and efficient.
(d) None of the above
<br>
(b) byte
(c) short
(d) long
(a) 6
(b) 7
(c) 8
(d) 9
(a) 16 bit
(b) 32 bit
(c) 64 bit
(a) byte, 1
(b) int, 4
(c) short, 8
(d) byte, 8
(c) The type or variety of data being handled for reading and writing
(d) None of the above
58. Which of these literals can be contained in a data type float variable?
(a) 1.7e-308
(b) 3.4e-038
(c) 1.7e+308
(d) 3.4e-050
(a) Boolean
(b) Character
(c) Arrays
(d) Integer
61. Which of the following data types comes under floating data types ?
(a) int
(b) long
(c) byte
(d) double
62. In Java byte, short, int and long all of these are
(a) signed
(b) unsigned
(b) 64 and 64
(c) 32 and 32
(d) 64 and 32
(a) Two type are compatible and size of destination type is equal of source type.
(b) Two type are compatible and size of destination type is larger than source type.
(c) Two type are compatible and size of destination type is shorter than source type.
(d) Allof the above
65. What is the type of variable 'b' and 'd' in the following Java snippet?
int a[], b;
int[c, d;
(b) Letter
(c) String
(b) False
(c) NULL
(d) garbage
68. An expression involving byte, int, and literal numbers is promoted to which of these?
(a) int
(b) lonf
(c) byte
(d) float
<br>
69. Which of these coding types is used for data type characters in Java?
(a) ASCII
(b) ISO-LATIN-1
(c) UNICODE
(c) 0 & 1
Unit-2
1. Which of the following can be operands of arithmetic operators?
(a) Characters
(b) Boolean
(c) Numeric
(b) Boolean
(c) Character
(c) Modulo Division (%), Increment/Decrement (++/--) Unary Minus (-), Unary Plus (+)
(a) +=,-=
(b) *=,I=
(c) \%=
(b) 1
(c) 2
(d) -1
7. int ++ a = 100;
System.out.println(+ta);
(a) 100
(c) Displays error as ++a is not enclosed in double quotes in printin statement
(d) None of these
int a = 20 b= 10
(a) 10
(c) 12
(b) 11
9. With x=0 which of the following are legal lines of Java code for changing the value of x to 1?
1. x++;
2.
x=X+1
3. x +=1
4. X = 1
(a) 1 \&4
<br>
(b) 3 & 2
(c) 1, 2 &3
(d) 1, 2, 3, &
(a) 1
(b) 2
(c) 3
(d) 4
11. Decrement operator, â'n", decreases the value of variable by what number?
(a) 1
(b) 2
(c) 3
(d) 4
(a) Assignment operators run faster than their equivalent long forms.
(b) Assignment operators can be used only with numeric and character data type.
(c) Assignment operators are more efficiently implemented by Java run-time system than their
equivalent long forms.
System.out.printin(a);
(a) -5
(b) 9
(c) 10
14. Select from among the following character escape code which is not available in Java.
(a) \t
(b) \v
(c) \r
(d) \a
15. When the operator after the variable name, the first assignment of the value of the
++ is placed
variable takes place and then the value of the variable is incremented, this operation is also called
(a) pre-increment
<br>
(b) post-increment
16. When the operators are having the same priority, they are evaluated from expression. in the
order they appear in the
(a) left to right
(a) ++
(b) *
(c) >>
(d) ()
18. What should be expressionl evaluate to in using ternary operator as in this line?
(b) Boolean
(b) >>=
(c) <<
(d) <<=
(a) The right shift operator automatically fills the higher order bits with 0
class operators
{public static void main(String args[])X
int var1=5;
<br>
int var3;
(a) 10
(b) 11
(c) 12
(d) 56
class Main
{public static void main(String args[]) {
int x = 8;
+
System.out.println(++x* 3 +" " x); }}
(a) 24 8
(b) 24 9
(c) 27 8
(d) 27 9
24. Which of these operators can skip evaluating right hand operand?
(a)!
(b) |
(c) &
(d) &&
(a) ?:
(b) +=
(c) &
(d) \&\&
class bool_operator
{public static void main(String args[])
{
boolean a = true;
boolean b= !true:
booleanc =a|b;
booleand =a\& b;
booleanc=d? b: c;
System.out.println (d + 6 ^ 66 + e)
28. Which of the following loops will execute the body of loop even when condition controlling the
loop is initially false?
(a) for
(b) while
(c) do-while
29. Which of these jump statements can skip processing the remainder of the code in its body for a
particular iteration?
(a) return
(b) break
(c) continue
(d) exit
(b) two case constants in the same switch can have identical values
<br>
(b) Break halts the execution and forces the control out of the loop
(c) Break forces the control out of the loop and starts the execution of next iteration
(d) Break halts the execution of the loop for certain time frame
32. What will be the output of the program?
class Bitwise
{public static void main(Stringll args)
x =
int 11& 9;
=
int y x^3;
System.out.printin(y | 12); }
}
(a) (0
(b) 7
(c) 8
(d) 14
class Main
{
public static void main(Stringl] args)
{
int x=20; String sup= (x< 15)? "s": (x< 22)? "t": "h";
System.out.printin(sup);
(a) s
(b) t
(c) h
(d)Compilation fails
34. Which of the following will produce an answer that is closest in value to a double, d, while not
being greater than d?
(a) (int)Math.min(d);
(b) (int)Math.abs(d);
<br>
(c) (int)Math.max(d);
(d) (int)Math.floor(d);
(a) -2
(b) 2
(c) -4
(d) 4
class Main
{public static void main(String args[])
double var1= 2
{ + 4;
}}
(a) 01
(b) 10
(c) 1.5 1
class Main
{
public static void main(Stringl] args)
void start()
longl] a2 = fix(al);
}{}
a3[1] = 7;
return a3;
<br>
(a) 12 i2
(b) 15 15
(c) 375375
(d) 345375
class Relational_operator
{public static void main(String args[l)
{int var=5;
int var2 = 6:
System.out.print(var1> var2);
(a) 0
(b) 1
(c) TRUE
(d) FALSE
class ternary_operator
{public static void main(String args[])
-x
{int x =3 int y = int z; }
z= X> y ?x: y;
System.out.print(z);
(a) 0
(b) 1
(c) 3
(d) -4
class Output
System.out.println(y):
else
System.out.println(++y);
<br>
(a) 1
(b) 2
(b) everywhere
(c) members to the same package
42. Which concept of Java is a way of converting real world objects in terms of class?
(a) Abstraction
(b) Inheritance
(c) Polymorphism
(d) Encapsulation
43. For Cat and Animal class, correct way of inheritance in java is
44. Which component is used to compile, debug and execute java program?
(a) JDK
(b) JVM
(c) JRE
(d) JIT
46. Which concept of Java is achieved by combining methods and attribute into a class?
(a) Inheritance
(b) Abstraction
(c) Encapsulation
(d) Polymorphism
<br>
47. What is it called if an object has its own lifecycle and there is no owner?
(a) Aggregation
(b) Composition
(c) Encapsulation
(d) Association
(c) &
B
BothA
(a) Classes
(c) Interfaces
(a) JDK
(b) JVM
(c) JRE
(d) JIT
53. What is it called where child object gets killed if parent object is killed?
(a) Aggregation
(b)Composition
(c) Encapsulation
<br>
(d) Association
(a) JDK
(c) JRE
(b) JVM
(d) JIT
(a) Inheritance
(b) Encapsulation
(c) Composition
56. How can we identify if a compilation unit is a class or an interface from a .class file?
58. Which of the below is invalid identifier with the main method?
(a) final
(b) static
(c) private
(d) public
(a) True
(b) False
60. Which of the following is not a component of Java Integrated Development Environment (|DE)?
Unit-3
1. Which of these packages contain all the collection classes?
(a) java.net
(b) java.awt
(c) java.lang
(d) java.util
(a) Array
(b) Stack
(c) Maps
(d) Queue
3. Which of these interface declares core method that all collections will have?
(a) set
(b) Collection
(c) Comparator
(d) EventListner
4. Suppose that you would like to create an instance of a new Map that has an iteration order that is
the same as the iteration order of an existing instance of a Map. Which concrete implementation of
the Map interface should be used for the new instance?
(a) HashMap
(b) TreeMap
(c) LinkedHashMap
(a) java.lang.String
(c) java.lang.Character
() java.lang.StringBuffer
6. Which of these interfaces is not part of the Collection framework in Java?
(a) Set
(c) SortedMap
(b) List
(d) SortedList
<br>
(a) clear()
(b) reset()
(c) delete()
(d) refresh()
(c) A
group of interfaces
(a) Set
(b) List
(c) Comparator
(d) Collection
(a) Set
(b) List
(c) SortedMap
(d) SortedList
11. Which collection class allows you to grow or shrink its size and provides indexed access to its
elements, but whose methods are not synchronized?
(a) java.util.List
(b) java.util.ArrayList
(c) java.util.HashSet
(b) java.util.Coliection
(c) java.util.Map
(d) java.util.Set
<br>
13. Which of these interfaces is not part of the collection framework in Java?
(a) Set
(b) List
(c) Group
(d) Collection
(a) Set
(b) List
(c) Map
(a) Set
(c) Array
(b) List
(d) Collection
16. Which of these is Basic interface that all other interface inherits?
(a) Set
(c) Array
(b) List
(d) Collection
17. Which of these is an incorrect form of using method max() to obtain maximum element?
(a) max(List c)
(b) max(Collection c)
18. Which of these methods sets every element of a List to a specified object?
(a) set()
(b) fil()
(c) add()
(d) Complete()
(a) Java.util.List
(b) Java.util.Map
(c) Java.util.Collection
<br>
(d) Java.util.HashTable
20. Which collection class allows you to associate its elements with key values, and allows youto
retrieve objects in FIFO
(first-in, first-out) sequence?
(a) java.util.ArrayList
(b) java.util.HashMap
(c) java.util.TreeMap
(d) java.util.LinkedHashMap
21. Which collection class allows you to access its elements by associating a key with an element's
value, and provides synchronization?
(a) java.util.TreeSet
(b) java.util.Hashtable
(c) java.util.SortedMap
(d) java.util.TreeMap
(a) Array
(b) Arrays
(c) ArrayList
(a) rand()
(b) randomize()
(c) shuffle()
(d) ambigous()
(a) CopyList()
(b)SetList()
(c) ConvertList()
(d) singletonList()
<br>
(a) Enum
(b) Pointer
(c) Structure
(d) None
(a) Class
(c) NULL
(b) Object
(d) Superclass
(b) implements
(a) Vector
(b) Arraylist
(c) Hashtable
(a) class
(b)object
(c) variable
(a) char()
(b) Charat()
(c) charat()
<br>
(d) charAt()
33. What is the stored in the object obj in following lines of Java code? bOx obj;
(a) NULL
(b)Garbage
(c) Any arbitrary pointer
(c) The Test1 hashCode() method is less efficient than the Test2 hashCode() method.
(d) The Test1 hash Code() method is more efficient than the Test2 hashCode() method.
35. HashMap allows
(a) EMPTY_MAP
(c) EMPTY_SET
(a) sets
(b) maps
(c) lists
(b) unmodifiable Collection() method is available only for List and Set
<br>
41. What is the output of the below Java program with two classes?
//Testing1.java
publicclass Example {} public class Testing1( public static void main(Stringl[] args) {
(a) No Output
42. What is the output of the below Java program using toString() method? class College { public
String toString() return "College Object";
class Testing18
{public
static void main(String[] args)
{College col = new College();
class Cricket
int runs;
}
class Testing19
{
public static void main(Stringl] args)
=
cl.runs 250;
Cricket c2;
c2 = cl;
c2.runs=300;
System.out.printin("Runs= " + cl.runs);
(a) Runs= 0
class WordPress
int posts;
class Testing20
WordPress wp2 =
wp1;
wpl = null:
System.out.println("Posts=" + wp2.posts);
(a) Posts=NULL
(b) Posts=0
(c) Posts=25
45. Which implementation of Iterator can traverse a collection back and forth?
(a) Iterator
(b) Listiterator
(c) Setlterator
(d) Maplterator
import java.util.*;
class Array
{public static void main(String args[])
{
int array[l =
new int [5];
array[5-i] =i;
Arrays.fil(array, 1, 4, 8);
= 0;
for (int i
i< 5; i++)
System.out.print(array[i]);
(a) 12885
(b) 12845
(c) 58881
(d) 54881
(a) inherit
(b) implement
class string_clasS
= LIKE JAVA";
String obj "|
System.out.println(obj.length(0);
}
(a) 9
(b) 10
(c) 11
(d) 12
(a) toCompare
(b) compare
<br>
(c) compareTo
(a) List
(b) Collection
(c) AbstractList
(d) AbstractCollection
(a) It can extend exactly one class and can implement multiple interfaces.
(b) It can extend exactly one class or implement exactly one interface.
(c) It can extend exactly one class and implement exactly one interface.
(d) It can implement multiple interfaces regardless of whether it also extends a class.
Boo(String s) {)
Boo() )
{{ Bar()
void zoo()
which one create an anonymous inner class from within class Bar?
(a) Boof f= new Bar() ();
(c) It does not have access to nonstatic members of the enclosing class.
(d) You must have a reference to an instance of the enclosing class in order to instantiate it.
57. The inner class can access private members of the outer class
(a) True
(b) False
58. What will be the output of the program? public class HorseTest
{
publicstatic void main (String[] args) { class Horse { public String name; /* Line 7*1 public
Horse(String s) }
name= S;
}/* class Horse ends */
System.out.println(h.name);
{
public boolean equals(Object obj)
return true;
{
}}/* Line 11 */
System.out.println(o.equals("Fred"));
<br>
{return 45;
{
public int getNum()
{return 38;
public static void main (String[) args)
(b) 45 57
(c) 57 22
(d) 45 38