TCS PROCTORED EXAM
JAVA
PREVIOUS EXAM’S MCQS
100% COMMON
[Link] A
Final a;
[Link](a);
….
Ans : error in line 3
[Link] find length of the string:
String a;
[Link]
[Link]()
Ans : [Link]();
[Link] Box{
…..
Class solution {
Box box[]={b1,b2,b3,b4,b5};
For(int i=0;i<[Link]();i++)
Ans : error ( because we should use [Link])
[Link] includes ?
1. attributes
[Link]
[Link]
[Link]
Ans : 3
5.____is also known as static variable.. ?
1) class variable
2) instance variable
3) local variable
4) all of above
Ans :1
[Link] output of program
char ch=127;
ch++;
System . out . println(ch+" = "+(int)ch);
1) compilation error
2) ? = 128
3) garbage value =- 128
4) none of above
Ans :3
[Link] output of program
String s[] = {hybernate, java, object}
Arrays . sort(s);
for(String k in s)
{
System . out . println(k);
}
1) java hybernate object
2) hybernate java object
3) hybernate object java
4) object java hybernate
Ans:2
[Link] output of program
String str = "I like JAVA";
System . out . println(str . length());
1) 12
2) 11
3) 10
4) 9
Ans : 2
[Link] operator gives result if no condition
satisfies.?
1) IN
2) OR
3) NOT
4) AND
Ans :3
[Link] is not the correct declaration ?
[Link] a_1
[Link] 1_a
[Link] A1
[Link]
Ans: 2
[Link] the correct one-
[Link] is platform independent
[Link] is platform dependent
[Link] converts byte code into machine
level code
Ans: tick all of these
[Link] int a=1;
Inc()
{
a++;
Print(a)
}
Inc()
Inc()
1.1,1
2.1,2
3.2,3
4.2,2
Ans: 3
[Link] is the output of relational
operator?
Ans: Boolean(true, false)
[Link] among the following falls under key
elements of programming?
[Link] analytical skills
[Link] knowledge
3. imperative knowledge
[Link] knowledge in programming
Ans: 1, 2, 3, 4
[Link] is the extension of java code files?
1..java
2..class
[Link] 1 and 2
4..txt
Ans: 1
[Link] is not OOPS concept?
[Link]
[Link]
[Link]
[Link]
Ans: 1
[Link] component is used to compile, debug
and execute java program?
[Link]
[Link]
[Link]
[Link]
Ans: 4
[Link] is the extension of compiled
java classes?
1..java
2..txt
3..class
Ans: 3
[Link] of these can not be used for a variable
name in java?
[Link] & keyword
[Link]
[Link]
[Link] of these
Ans: 2
20.expression1 ? expression2
:expression3|what it will return?
[Link]
[Link]
[Link]
Ans:3
[Link] of these is long data type
literal?
1.0x99fffa
2.0x99fffL
3.99671246
Ans: 2
[Link] of these is superclass of every
class?
[Link] class
[Link] class
[Link] class
[Link] class
Ans: 2
[Link] of these keywords can be used to
prevent inheritance of a class?
[Link]
[Link]
[Link]
[Link]
Ans: 4
BONUS QUESTION
1. what is the output?
public static void main(String[] args)
{
int var1=1;
if (var1)
{
[Link]("Inside If Condition");
}
}
a)Inside If Condition
b)does not print anything
c)Compilation Error
d)Run Time Error
Ans: c (var1 is int not boolean)(var1==1)
[Link] is the output?
public static void main(String[] args)
{
int var1;
if (var1==0)
{
[Link]("Inside If Condition");
}
}
a) Inside If Condition
b) does not print anything
c) Compilation Error
d) Run Time Error
Ans: c (var1 need to be initialized)
[Link] modifier can be used to prevent any method or
attribute to be not visible to external classes?
a. Private
b. Public
c. Protected
d. Default
Ans: a
[Link] modifier can be used to restrict a
method or attribute to be invisible outside its
package?
a. Private
b. Public
c. Protected
d. Default (No modifier)
Ans: d
[Link] package name containing more than one
word is used, the words must be separated by
a. comma
b. dot
c. hyphen
d. underscore
Ans: b
[Link] the classes in a package can be
simultaneously imported by using
__*__ wildcard
7. Which of the following statement declares an int
array of size 10?
a)int[10] array
b)int array[10]
c)int[] array = new int[10](answer)
d)int[10] array = new int[10]
e)int[] array = new int[10]{}
Ans: c or int[] array = new int[]{1,2,3}