T Y - B SC-V - Computer - JAVA-I
T Y - B SC-V - Computer - JAVA-I
Question Bank
---------------------------------------------------------------------------------------------------------------------
5 A. .Obj
B. Source Code
C. Bytecode
D. .Exe
6 Single line comment starts with _________ in Java.
7 A. /**
B. //
C. /*
D. None of these
8 How to compile java code in command prompt?
A. javac filename.java
B. java filename.java
C. javac filename
D. java filename
9 How to run java program in command prompt?
10 A. javac filename.java
B. java filename.java
C. javac filename
D. java filename
11 Java is case sensitive?
A. True
B. False
C. Depends On Complier
D. May be true or false
12 Default, public , protected, private are?
A. Access Modifier
B. Non-access Modifiers
C. Both A and B
D. It's variable
13 Java was designed by _________________.
A. Microsoft
B. Mozilla Corporation
C. Sun Microsystems
D. Amazon Inc.
14 Java is a ________ programming language
A. high-level
B. Middle-level
C. Low-level
D. None of the above
15 Which of the following are correct advantage of java?
A. Java is Simple
B. Java is Secure
C. Java is Portable
D. All of the above
16 Basic aim of java was to solve the problem of connecting many household machines
together.
A. Integer
B. Boolean
C. Characters
D. Double
20 Which of these is returned by "greater than", "less than" and "equal to" operators?
A. Integers
B. Floating - point numbers
C. Boolean
D. None of the mentioned
21 Which of these have highest precedence?
A. ()
B. ++
C. *
D. >>
22 Java array is a collection of ________.
A. Operator
B. Variable
C. index
D. Pointer
24 At time of array initialization which is necessary to specify?
A. Row
B. Column
C. Row and Column
D. None of the above
25 Java Array can allocate __________.
A. Dynamic Memory
B. Static Memory
C. Both A and B
D. None of the above
26 Which of the following is an incorrect array declaration?
A. -1
B. 0
C. 1
D. infinite
28 Which of the following is used to declare,construct, and initlaize an array?
A. sizeof(array)
B. array.len
C. array.length
D. array.sizeof()
30 In java, array elements are stored in ________ memory locations.
A. Random
B. Sequential
C. Sequential & Random
D. Binary search
class Main
A. 10 20 30 40 50
B. Compiler Error
C. 10 20 30 40
D. None of the above
int n = 6;
n = arr[arr[n] / 2];
System.out.print(n);
A. 3
B. 0
C. 6
D. 1
A. Array.sort()
B. Arrays.sort()
C. Collection.sort()
D. System.sort()
A. interface
B. Interface
C. intf
D. Intf
A. Public
B. private
C. Protected
D. All of the mentioned
A. Method definition
B. Method declaration
C. Method declaration and definition
D. Method name
38 Package in Java is a mechanism to encapsulate a ______________.
A. Classes
B. Sub Packages
C. Interfaces
D. All of the above
39 Which of these keywords is used to define packages in Java?
A. pkg
B. Pkg
C. package
D. Package
40An _______________ statement can be used to access the classes and interface of a different
package from the current package.
A. instanceOf
B. import
C. extends
D. implement
41Which of the following packages is used to includes classes to create user interface like Button
and Checkbox?
A. java.lang
B. java.net
C. java.awt
D. java.io
42 Which of the following is the correct way of importing an entire package "pkg"?
A. import pkg.
B. Import pkg.
C. import pkg.*
D. Import pkg.*
44 Which component is responsible for converting bytecode into machine specific code?
a) JVM
b) JDK
c) JIT
d) JRE
B. int b = Math.abs(5.0);
C. int c = Math.abs(5.5F);
D. int d = Math.abs(5L);
50 Which Scanner class method is used to read integer value from the user?
1. next()
2. nextInteger()
3. nextInt()
4. readInt()
51 Which Scanner class method is used to read string value from the user?
1. next()
2. nextString()
3. nextLine()
4. Both 1 and 3
52 Which is the correct syntax to declare Scanner class object?
A) Same
B) Different
C) none
D) Both A and B
54 The purpose of a Java constructor is ___.
A) Inheritance
B) Encapsulation
C) Polymorphism
D) None
56 What is the return type of a method that does not return any value?
a) int
b) float
c) void
d) double
57 What is the process of defining more than one method in a class differentiated by method
signature?
a) Function overriding
b) Function overloading
c) Function doubling
d) None of the mentioned
58 Which method can be defined only once in a program?
a) main method
b) finalize method
c) static method
d) private method
60 Which of the following option leads to the portability and security of Java?
A) Return type
B) Method name
C) Argument List
D) All the above
62 What is meant by the classes and objects that dependents on each other?
a. Tight Coupling
b. Cohesion
c. Loose Coupling
d. None of the above
63 Given
int values[ ] = {1,2,3,4,5,6,7,8,9,10};
for(int i=0;i< Y; ++i)
System.out.println(values[i]);
a. 10
b. 11
c. 15
d. None of the above
64 Which of the following is not a primitive data type?
a) Boolean
b) byte
c) string
d) double
65 Which of the following operators take (s) only integer operands?
a)%
b) ++ (post-increment)
c) ++(pre-increment)
d)none of these
66 Which of the following doesn’t have a superclass?
a)System
b) Object
c) Lang
d) Exception
67 Constant that cannot be changed are declared using the keyword
a) final
b) static
c) absatract
d) immutable
68 Which of the following can be used to copy data from one array to another?
a) System.clone
b) java.lang.toCopy
c) System.arraycopy
d)java.lang.clone
69 Which of the following keywords is used to declare exceptions that can possibly occur?
a) handle
b) throws
c) checked
d) manage
71 public class MyClass{
public static void main(String args[]){
System.out.println(“In first main()”);
}
public static void main(char args[]){
System.out.println(‘a’);
}
}
A) The code will not compile and will give “Duplicate main() method declaration” error
B) The code will compile correctly but will give a runtime exception
C) The code will compile correctly and will print “In first main()” (without quotes) when it
is run
D) The code will compile correctly and will print “a” (without quotes) when it is run
72 Consider the statement “x=(a>b)?a:b”, then the value of x is 19 if a=19 and b=12
A) true
B) not supported
C) false
A.alloc B.malloc
A.public B.private
C.friendly D.transient
77 A package is a collection of
82 For what values respectively of the variables gender and age would the Java expression
gender == 1 && age >= 65 become true?
A. abc
B. abcabc
C. null
A. JAVA
B.java
C. true
D. false
85 String in Java is a?
a) class
b) object
c) variable
d) character array
86 Which of these method of String class is used to obtain character at specified index?
a) char()
b) Charat()
c) charat()
d) charAt()
87 Which of these keywords is used to refer to member of base class from a subclass?
a) upper
b) super
c) this
d) none of the mentioned
88 Which of these method of String class can be used to test to strings for equality?
a) isequal()
b) isequals()
c) equal()
d) equals()
90 Which of these class is used to read characters and strings in Java from console?
a) BufferedReader
b) StringReader
c) BufferedStreamReader
d) InputStreamReader
91
1. class output
2. {
3. public static void main(String args[])
4. {
5. StringBuffer c = new StringBuffer("Hello");
6. StringBuffer c1 = new StringBuffer(" World");
7. c.append(c1);
8. System.out.println(c);
9. }
10. }
a)Hello
b)World
c)Helloworld
d) Hello World
92
1. class output
2. {
3. public static void main(String args[])
4. {
5. StringBuffer s1 = new StringBuffer("Hello");
6. s1.setCharAt(1,x);
7. System.out.println(s1);
8. }
9. }
a)xello
b)xxxxx
c)Hxllo
d) Hexlo
b) getDeclaredMethods
c) getMethods
d) getFields
a) getDeclaredFields
b) getDeclaredMethods
c) getMethods
d) getFields
a) Class.forName(“className”)
b) Class.name(“className”)
c) className.getClass()
d) className.getClassName()
c) Class object
d) Exception is thrown
A )next()
B) nextString()
C) nextLine()
D) Both A and C
100 Which is the correct syntax to declare Scanner class object?