Java Mid 1
Java Mid 1
001. ................are not machine instructions and therefore, Java interpreter generates machine code A
that can be directly executed by the machine that is running the Java program.
A byte code B Java mid code
C Compiled code D Compiled Instructions
002. How many times does the following code segment executeint x=1, y=10, z=1; do { y; x++; y-=2; D
y=z;z++; } while (y>1 && z<10);
A 10 B 5
C 3 D 1
003. A compiler converts the java program into an intermediate language representation B
called____________.
A byte B byte code
C Byte class D Byte java
004. Command to execute compiled java program is --------- A
A java B javac
C run D javaw
005. The command javac is used to --------------- C
A debug a java program B interpret a java program
C compile a java program D execute a java program
006. Which of these jump statements can skip processing the remainder of the code in its body for a B
particular iteration?
A break B continue
C return D exit
007. Which feature of OOP encourages the code reusability? D
A encapsulation B abstraction
C polymorphism D inheritance
008. Who is known as father of Java Programming Language? A
A James Gosling B M. P Java
C Charel Babbage D Blais Pascal
009. Which of these are selection statements in Java? A
A if() B for()
C continue D break
010. Which operator is used to invert all the digits in a binary representation of a number? A
A ' B <<<
C >>> D ^
011. Which of the following can be operands of arithmetic operators? D
A Numeric B Boolean
C Characters D Both Numeric & Characters
012. Which right shift operator preserves the sign of the value? B
A << B >>
C <<= D >>=
013. Which of these operators can skip evaluating right hand operand? B
A & B &&
C | D !
014. Which provides runtime environment for java byte code to be executed? B
A JDK B JVM
C JRE D JAVAC
015. In java control statements break, continue, return, try-catch-finally and assert belongs to ---------- C
-----?
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 1/14
4/28/22, 11:51 AM R2022054
C 1, 2, 3 & 4 D 3&2
028. Which of the following is used with the switch statement? C
A Continue B Exit
C break D do
029. Which of the following is not a valid jump statement? B
A break B goto
C continue D return
030. Evaluate the following Java expression, if x=3, y=5, and z=10: ++z + y - y + z + x++ A
A 24 B 23
C 20 D 25
031. Which of these statements are incorrect? D
A The left shift operator,<<, shifts all of the B The right shift operator,>>, shifts all of
bits in a value to the left specified the bits in a value to the right
numberof times specifiednumber of times
C The left shift operatorcan be used as an D The right shift operatorautomatically fills
alternative to multiplying by 2 the higher order bits with 0
032. What is the output of this program? classOutput { publicstaticvoidmain(String args[]) { intx , y; C
x = 10; x++; --x; y = x++; System.out.println(x + " " + y); } } (
A 11 11 B 10 10
C 11 10 D 10 11
033. Which of the following is not a valid flow control statement? A
A exit() B break
C continue D return
034. What is the output of this program? classincrement { publicstaticvoidmain(String args[]) { intg = B
3; System.out.print(++g * 8); } }
A 25 B 32
C 24 D 33
035. Which of the following is not a Java features? A
A Use of pointers B Dynamic
C Architecture Neutral D Object-oriented
036. _____ is used to find and fix bugs in the Java programs D
A JVM B JRE
C JDK D JDB
037. Single line comment starts with _________ in Java. D
A /** B **
C /* D //
038. What is the output of Compilation of Java Program? B
A .cla file B .class file
C .jc file D .javax file
039. Byte code is the result of? A
A Compiling a Java file B Compiling a Class file
C Interpreting a Java File D Interpreting a Class file
040. A valid Identifier or name in Java language can start with which character? C
A a-z, A-Z B $, _
C A and B D 0-9
041. Which of these have highest precedence? A
A () B ++
C * D >>
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 3/14
4/28/22, 11:51 AM R2022054
A = B ?:
C () , [] D %
056. Which concept of Java is achieved by combining methods and attribute into a class? C
A Inheritance B Polymorphism
C Encapsulation D Abstraction
057. Which variables are created when an object is created with the use of the keyword 'new ' and B
destroyed when the object is destroyed?
A Local variables B Instance variables
C Class Variables D Static variables
058. What is stored in the object obj in following lines of Java code? box obj; D
A Memory address of allocated memory of B Any arbitrary pointer
object
C Garbage D NULL
059. Which of the following are legal lines of Java code? 1. int w = (int)888.8; 2. byte x = D
(byte)100L; 3. long y = (byte)100; 4. byte z = (byte)100L;
A 1 and 2 B 2 and 3
C 3 and 4 D All statements are correct
060. Which statement transfer execution to different parts of your code based on the value of an B
expression?
A If B Switch
C Nested-if D if-else-if
061. How many times does the following code segment execute int x=1, y=10, z=1; do{y; x++; y-=2; A
y=z; z++} while (y>1 && z<10);
A 1 B 10
C 5 D infinite
062. Which one is a valid declaration of a boolean? C
A boolean b1 = 1; B boolean b2 = false;
C boolean b3 = false; D boolean b4 = true;
063. An expression involving byte, int, and literal numbers is promoted to which of these? (M) A
A int B long
C byte D float
064. What is the return type of a method that does not return any value? D
A int B float
C double D void
065. Which of these is not a correct statement? D
A A recursive method must have a base case B Recursion always uses stack
C Recursive methods are faster that D Recursion is managed by Java Runtime
programmers written loop to call the environment
function repeatedly using a stack
066. Which of the following is a method having same name as that of its class? A
A constructor B finalize
C delete D class
067. All classes in Java are inherited from which class? D
A java.lang.class B java.class.inherited
C java.class.object D java.lang.Object
068. Which class cannot be sub classed? A
A final class B object class
C abstract class D child class
069. What is the process of defining a method in terms of itself, that calls itself? C
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 5/14
4/28/22, 11:51 AM R2022054
A Polymorphism B Abstraction
C Recursion D Encapsulation
070. Which of this keyword can be used in a subclass to call the constructor of superclass? A
A super B this
C extent D extends
071. When does method overloading is determined? B
A At run time B At compile time
C At coding time D At execution time
072. Which of these statement is incorrect? C
A Applets do not require a main() method at B There can be only one main() method in a
all program
C Every class must contain a main() method D main() method must be made public
073. If super class and subclass have same variable name, which keyword should be used to use super A
class?
A super B this
C upper D classname
074. Which of these is correct way of calling a constructor having no parameters, of superclass A by D
subclass B?
A super(void); B superclass.();
C super.A(); D super();
075. What is false about constructor? B
A Constructors cannot be synchronized in B Constructor can have a return type
Java
C Java does not provide default copy D this and super can be used in a constructor
constructor
076. Which of the following statements are incorrect? C
A default constructor is called at the time of B constructor can be parameterized
object declaration
C finalize() method is called when a object D finalize() method must be declared
goes out of scope and is no longer needed protected
077. Which of the following is used for implementing inheritance through class? C
A inherited B using
C extends D implements
078. What would be the behavior, if this() and super() used in a method? D
A Runtime error B Throws exception
C Runs successfully D compile time error
079. Which of this statement is incorrect? C
A If a function is defined public it can be B main() method must be made public
accessed by object of other class by
inheritance
C All object of a class are allotted memory D All object of a class are allotted memory
for the methods defined in the class for the all the variables defined in the
class
080. Which method can be defined only once in a program? A
A main method B finalize method
C static method D private method
081. Which keyword is used by the method to refer to the object that invoked it? B
A import B this
C catch D abstract
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 6/14
4/28/22, 11:51 AM R2022054
A final B last
C constant D static
096. Method signature consists of------------------- C
A Method Name, Return Type and Number B Access Modifier, Method Name and
of Arguments Types of Arguments
C Method Name, Number of Arguments, D Return Type, Access Modifier and Order
Types of Arguments and Order of of Arguments
Arguments
097. Which of these cannot be declared static? B
A class B object
C variable D method
098. Which polymorphism feature is related to parent and child class relationship in java? C
A Method overloading B Constructor overloading
C Method overriding D overloading
099. Which of the following statements are incorrect? D
A static methods can call other static B static methods must only access static
methods only data
C static methods can not refer to this or D when object of class is declared, each
super in any way object contains its own copy of static
variables
100. Which of this keyword can be used in a subclass to call the constructor of superclass? B
A super B this
C extent D extends
101. Which of the following statement is true? D
A All nested classes can declare static B Non-static member classes must have
member classes either default or public accessibility
C Methods in all nested classes can be D Static member classes can contain non-
declared static static methods
102. Which option is false about the final keyword? A
A Afinalclass cannot extend other classes. B Afinalmethod can be inherited.
C Afinalclass cannot be extended. D Afinalmethod cannot be overridden in its
subclasses
103. Which among the following is false, for member function of a class ? C
A All member functions must be defined B Member functions can be defined inside
or outside the class body
C Member functions need not be declared D Member functions can be made friend to
inside the class definition another class using friend keyword
104. Size of a class is ------------- A
A Classes doesnt have any size B Size of the largest size of variable
C Sum of the size of all the variables along D Sum of the size of all the variables
with inherited variables in the class declared inside the class
105. What is the scope of a class nested inside another class? C
A Global scope B Private scope
C Depends on access specifier and D Protected scope
inheritance used
106. The variables declared in a class for the use of all methods of the class are called----- C
A reference variables B objects
C instance variables D global variables
107. ------------ method cant be overridden B
A super B final
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 8/14
4/28/22, 11:51 AM R2022054
C static D private
108. Which of these is correct way of calling a constructor having no parameters, of superclass A by D
subclass B?
A super(void); B superclass.();
C super.A(); D super();
109. The subclass constructor uses the ________ keyword to invoke the constructor of the superclass. B
A Final B super
C static D public
110. Overloading of constructors in Java means adding more than ___ constructors with the different A
argument list.
A 1 B 2
C 3 D 8
111. A constructor can call another overloaded constructor using the ___ keyword in Java. D
A super B local
C con D this
112. In Java, add a ___ to a constructor to convert it into a method. C
A if statement B static
C return type D semicolon
113. If two methods have same name but different parameter list then it is called____ A
A Method overriding B Method overloading
C Operator overloading D Method renaming
114. In Java, local variables are stored in __ memory and instance variables are stored in ___ C
memory.
A Stack, Stack B Heap, Heap
C Stack, Heap D Heap, Stack
115. Which of the following is true about the anonymous inner class? D
A It has only methods B Objects can 't be created
C It has a fixed class name D It has no class name
116. ______________ constructor is created when object of particular class is created. B
A Parameterized B Default
C Copy D no
117. The is an object reference operator and returns true if the object on the left-hand side is an B
instance of the class given on the right-hand side.
A dot operator(.) B instance of
C bitwise D conditional
118. Which symbol is used to contain the values of automatically initialized arrays? B
A Brackets B Braces
C Parentheses D Comma
119. Which will legally declare, construct and initialize an array? A
A int myList [] = {4, 3, 7}; B int [] myList = {"1", "2", "3"};
C int [] myList = (5, 8, 2); D int myList [] [] = {4,9,7,0};
120. What is the type of variable b and d in the following Java snippet? int a[], b; int []c, d; C
A b and d are int B b and d are arrays of type int
C b is int variable; d is int array D d is int variable; b is int array
121. If an index of an element is N, what is its actual position in the array? B
A N-1 B N+1
C N D N+2
122. An array elements are always stored in ________ memory locations. A
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 9/14
4/28/22, 11:51 AM R2022054
A Sequential B Random
C Sequential and Random D Binary search
123. Which of these operators is used to allocate memory to array variable in Java? D
A alloc B malloc
C new malloc D new
124. We cannot create a subclass of _________ class. B
A Abstract B final
C static D public
125. Given a method in a protected class, what access modifier do you use to restrict access to that C
method to only the other members of the same class?
A final B static
C private D protected
126. In Java, main() method returns a value of type------- A
A void B int
C real D string
127. What is the default value of a char data type elements of an array in Java? C
A 'A ' B '\0 '
C '\0 ' or null D null
128. How to copy contents of array? A
A System.arrayCopy() B Array.copy()
C Arrays.copy() D Collection.copy()
129. What will be the output of the following Java code? int arr[] = new int [5]; System.out.print(arr); D
A 0 B value stored in arr[0].
C 00000 D Garbage value
130. Multidimensional arrays are actually C
A Arrays of element B Arrays of variable
C Arrays of arrays D Arrays of variable
131. What is the default value of float or double data type elements of an array in Java? B
A 0 B 0.0
C 1 D 1.0
132. Which of these is an incorrect array declaration? D
A int arr[] = new int[5] ; B int [] arr = new int[5] ;
C int arr[]; D arr = new int[5];
133. Which of these is an incorrect array declaration? D
A int arr[] = new int[5] B int [] arr = new int[5]
C int arr[] = new int[5] D int arr[] = int [5] new
134. What is the default value of byte, short, int or long data type elements of an array in Java? C
A -1 B 1
C 0 D Garbage value
135. Where is an array stored in memory? A
A heap space B stack space
C heap space and stack space D first generation memory
136. A one dimensional array of one-dimensional array is called ------------- A
A two-dimensional array B three dimensional array
C multi array D multi-dimensional array
137. What is a dynamic array? D
A An array which is reallocated everytime B The memory to the array is allocated at
whenever new elements have to be added runtime
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 10/14
4/28/22, 11:51 AM R2022054
A All the objects should be of same class B All the objects should have different data
C All the objects should be of same program D All the objects should be of different class
classes
152. If array of objects is declared as given below, which is the limitation on objects? Class_name D
arrayName[size];
A The objects will have same data B The objects can never be initialized
C The objects will have same values D The objects will not be initialized
individually
153. Which is the condition that must be followed if the array of objects is declared without A
initialization, only with size of array?
A The class must have a default or zero B The class should not have any member
argument constructor function
C The class must have no constructors D The class should have separate
constructor for each object
154. Base class is also known as---------- A
A super class B child class
C sub class D derived class
155. In inheritance, the old class is known as-------- B
A start class B base class
C derived class D sub class
156. When more than one child classes have the same parent then it is called as-------- D
A single inheritance B multi level inheritance
C class inheritance D hierarchical inheritance
157. Which of the following is used for implementing inheritance through class? C
A inherited B using
C extends D implements
158. Can an object be a subclass of another object? C
A Yes---as long as single inheritance is B Only when one has been defined in terms
followed of the other
C No---inheritance is only between classes. D Yes---when one object is used in the
constructor of another.
159. Does a subclass inherit both member variables and methods? D
A No--only member variables are inherited. B No--only methods are inherited.
C Yes--but only one or the other are D Yes--both are inherited.
inherited.
160. All classes in Java are inherited from which class? D
A javlang.class B javclass.inherited
C javclass.object D javlang.Object
161. A class member declared protected becomes member of subclass of which type? C
A public member B private member
C protected member D static member
162. What type of inheritance does Java have? A
A single inheritance B double inheritance
C multiple inheritance D class inheritance
163. Which among the following is true? A
A Java doesnt support multiple inheritance B Java supports all types of inheritance
C Java supports multiple inheritance D Java doesnt support inheritance
164. Which of this keyword must be used to inherit a class? D
A super B this
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 12/14
4/28/22, 11:51 AM R2022054
C extent D extends
165. How many types of inheritance can be used at a time in a single program? A
A Any type, any number of times B Any 4 types
C Any three types D Any two types
166. Which type of inheritance is illustrated by the following code? class student{ public: int marks; C
}; class topper: public student { public: char grade; }; class average{ public: int makrs_needed;
}; class section: public average{ public: char name[10]; }; class overall: public average{ public:
int students; };
A Single level B Multilevel and single level
C Hierarchical D Hierarchical and single level
167. A class member declared protected becomes a member of subclass of which type? B
A public member B private member
C protected member D static member
168. Which of these is correct way of inheriting class A by class B? C
A class B + class A {} B class B inherits class A {}
C class B extends A {} D class B extends class A {}
169. Which of the following is NOT an advantage to using inheritance? D
A Code that is shared between classes needs B Similar classes can be made to behave
to be written only once consistently.
C Enhancements to a base class will D One big superclass can be used instead of
automatically be applied to derived many little classes.
classes.
170. When a class extends a class, which extends another class then this is called --------- inheritance C
A single level B two level
C multi level D many level
171. .. helps to extend the functionality of an existing by adding more methods to the subclass. A
A Inheritance B Mutual Exclusion
C Package D Interface
172. When more than one child class have the same parent class then it is called ----- B
A single inheritance B hierarchical inheritance
C multiple inheritance D multilevel inheritance
173. Which feature of OOP encourages code reusability? C
A polymorphism B abstraction
C inheritance D encapsulation
174. A class that cannot be sub classed is called a ------------ D
A child class B parent class
C base class D final class
175. When you pass an array to a method, the method receives ------------ A
A The reference of the array. B A copy of the array.
C A copy of the first element. D The length of the array
176. In object oriented programming new classes can be defined by extending existing classes. This is D
an example of:
A Encapsulation B Interface
C Composition D Inheritance
177. Object oriented inheritance models the--------------- A
A "is a kind of" relationship B "has a" relationship
C "want to be" relationship D inheritance does not describe any kind of
relationship between classes
178. super keyword in Java is used for? B
file:///C:/PHD/JNTUK ONLINE/ONLINE EXAMS/jntuonlinecrack/banksdecrypted/R2022054/R2022054.html 13/14
4/28/22, 11:51 AM R2022054