TCS PA Java MCQs
1.class A{Final a;
System.out.println(a);
}
error in line 3
2.To find length of the string:
String a;
1.a.length
2.a.length()
3.class Box{.....}
Class solution
{
Box box[]={b1,b2,b3,b4,b5};
for(int i=0;i<box.length();i++)
error ( because we should use box.length)
4.Object includes ?
1. attributes
2.behaviour
3.both
4.None
5.____is also known as static variable.. ?
1) class variable
2) instance variable
3) local variable
4) all of above
6.Predict 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
7.Predict output of program
String s[] = {hybernate, java, object}
Arrays . sort(s);
for(String k in s)
{
System . out . println(k);
}
1) java hybernateobject
2) hybernatejava object
3) hybernateobject java
4) object java hybernate
8.Predict output of program
String str = "I like JAVA";
System .out .println(str . length());
1) 12
2) 11
3) 10
4) 9
9.Which operator gives result if no condition satisfies.?
1) IN
2) OR
3) NOT
4) AND
10.Which is not the correct declaration ?
1.int a_1
2.int 1_a
3.int A1
4.None
11.Tick the correct one-
1.Java is platform independent
2.Jvm is platform dependent
3. Jvm converts byte code into machine level code
12.Static int a=1;
Inc()
{
a++;
print(a)
}
Inc()
Inc()
1.1,1
2.1,2
3.2,3
13.What is the output of relational operator?
Boolean(true, false)
14.Which among the following falls under key elements of programming?
1. Good analytical skills
2. Declarative knowledge
3. imperative knowledge
4. Abstraction knowledge in programming
15.What is the extension of java code files?
1. .java
2. .class
3. Both 1 and 2
4. txt
16.Which is not OOPS concept?
1.Compilation
2.Polymorphism
3.Encapsulation
4.InheritanceAns:
17.Which component is used to compile, debug and execute java program?
1.JIT
2.JRE
3.JVM
4.JDK
18.What is the extension of compiled java classes?
1..java
2..txt
3..class
19.Which of these can not be used for a variable name in java?
1.Identifier & keyword
2.Keyword
3.Identifier
4. None of these
20.expression1 ? expression2 :expression3|what it will return?
1.Float
2.Integer
3.Boolean
21.Which of these is long data type literal?
1.0x99fffa
2.0x99fffL
3.99671246
22.Which of these is superclass of every class?
1.String class
2.Object class
3.Abstract class
4.ArrayList class
23.Which of these keywords can be used to prevent inheritance of a class?
1.Constant
2.Class
3.Super
4.Final
Comments
Post a Comment