Unit-1
I. Each Question Carries 1 Mark.
1) Java is ______________language
a) Platform independent b) high level language c) Object oriented language d) low level language
2) Java is _________based language
a) Compiler &interpreter b) compiler c) Interpreter d) None
3) _____________is not a data type
a) Byte b) short c) integer d) long
4) Float variable occupies_________ bytes in java
a) 8 b) 2 c) 4 d) 6
5) The operator precedence in java
a) /, +, - b) +, -, / c) +, -, / d) None
6) The main method should not be declared as
a) Public static void main([] string args) b) Public static void main( string []args)
c) Public static void main( string args[]) d) None
7) ___is a key word in java
a) All b) Static c) Import d) Super
8) _________not a keyword in java
a) Caught b) Try c) Catch d) Throw
9) Memory de-allocation in java is done is using
a) Garbage collection b) free c) Delete d) None
10) In switch statement a case should always followed by a __________ Statement
a) Continue b) BREAK c) ;; d) None
11) Java is developed by _______
a) Microsoft b) sun micro systems c) Borland’s d) semen’s
12) JVM stands for __________
a) Java vision mechanism b) java virtual machine c) Java vertical model d) java virtual model
13) Which operator is used to perform bit wise inversion in java?
a)! b) ~ c) & d) |
14) A compiler translates a java code to________
a) A java program b) a byte code c) A class code d) a text code
15) JVM is an________for Byte code?
a) Interpreter b) Compiler c) Both a and b d) None
16) Java frees you from having to worry about many of the most common causes Of programming errors.
a) Robust b) Abstraction c) Multithreading d) None
17) Write Once-Run AnyWhere, Any Time, Forever.
a) Architecture Neutral b) Interpreted c) Multithreaded d) None
18) Which Mechanism binds together code and the data?
a) Encapsulation b) Polymorphism c) Inheritance d) None
19) What keywords allows main( ) to be called without having instantiate a particular Instance of a class?
a) Static b) Final c) Abstract d) None
20) The smallest integer type is.
a) Byte b) Short c) Int d) None
21) Java uses ______to represent characters?
a) Unicode b) Byte Code c) Decimal Code d) None
22) Conversion of int to byte called.
a) Narrowing Conversion b) Widening Conversion c) Typecasting d) None
23) : are called as _______________
a) Terinary operators b) immediate operators c) both d) None
24) A Bitwise operator allows you to perform ______ manipulation on data.
a) Bit b) arithmetical c) None
25) Which is not a feature of Java
a) Simple b) Robust c) Secure d) None
I. Answer – 1 Mark.
1. B 2. A 3. C 4. C 5. A 6. C 7. A
8. A 9. A 10. B 11. B 12. B 13. B 14.B
15.C 16. D 17. D 18. A 19. A 20. A 21. A
22. A 23. A 24. C 25. D
II. Each Question Carries 2 Mark.
1) class Hello
{ public static void main(String args[])
{
System.out.println(“Hello”);
}
}
a) Hello b) Compile error c) runtime error d) None
2) char ch = ‘A’;
char dy;
dy = ch++;
System.out.println(dy);
a) A b) B c) C d) D
3) byte b = 50;
b = b * 2;
System.out.println(b);
a) Error b) 100 c) 50 d) None
4) byte b = 50;
b = (byte) (b * 2);
System.out.println(b);
a)100 b) Error c) 50 d) None
5) Is this declaration correct
i) int months[] = new int [12]; ii) int [] months = new int[12];
a. Both are true b) only i is true c) only ii is true d) None
6) double d = 42.3;
System.out.println(“d mod 10 = “+ x % 10);
a) 2.3 b) 2 c) 0.3 d) None
7) int d = 42;
System.out.println(“d mod 10 = “+ x % 10);
a) 2 b) 4 c) 0 d) None
8) int a = 32;
a = a>>2;
What is the value of a ?
a) 8 b) 4 c) 16 d) 32
9) int a[] = {1,2,3,4,5,6,7,8,9};
System.out.println(a.length);
a) 9 b) 8 c) 10 d) None
10) Which of the following is not a valid comment in java
a) /* comments / b) /** comments hers*/
c) //comments here d) /*comments here*/
II. Answer – 2 Mark.
1. A 2. A 3. A 4. A 5. A 6. D 7. B
8. A 9. A 10. A
III. Each Question Carries 4 Mark.
1) class Luck
{
public static void main(String args[]) {
System.out.println(“Best of Luck ”); } }
a) Best of Luck b) Compile error c) runtime error d) None
2) char ch = ‘Z’;
char dy;
dy = ch--;
System.out.println(dy);
a) Z b) Y c) C d) D
3) byte b = 150;
b = (byte) (b * 2);
System.out.println(b);
a) 300 b) Error c) 150 d) None
4) class incdec
{
public static void main(String[]args)
{
int x1=5;
int y1;
y1=x1++;
System .out .println(“x1=”+x1 +“y1=”+y1);
}
}
a) x=5,y=6 b) x=5y=5 c) x=6,y=5 d) x=6,y=6
5) class assign
{
public static void main(String[] args)
{
byte b;
int i=127;
b=i;
System.out.println(b);
}
}
a) Compiler error b) 127 c) runtime error d) None
6) Which of the following is correct
a) 128>>>1 gives 64 b) 128<<1 gives 64 c) 128>>1 gives -64 d) 1128>>>1 gives -64
7) The short hand operator a*=n+1 means
a) a=a*(n+1) b) a=a+n+1 c) n=a+1 d) a +n=1
8) Switch(6)
{
case 5: System.out.println(“five”);
case 6: System.out.println(“six”);
default :System.out .println(“default”);
}
a) six default b) six c) default d)None
9) class abc
{
public static void main(string[]argd)
{
byte a,b,c;
a=10;
b=20;
c=a+b;
System.out.println(“sum of a and b is “+c);
}
}
output of the program
a) 30 b) no output c) compile error d) runtime error
10) class xyz
{
public static void main(String args[])
{
string s1=args[0];
string s2=args[1];
if the program is executed by giving java xyz 10 20________
id the output
a) 1020 b) 30 c) 102030 d) none
11) class xyz
{ static
{
system.out.println(“hello world”);
}
}
a) Executes successfully with a warning of main not found
b) Hello world
b) Gives error
c) Compiles successfully
12) class continur
{
public static void main(String[]args)
{
int n=5;
int I;
for(I=1;I<=n;I++)
{if(I%2==0)
continue;
system.out.println(i);
}
}
}
The output of the program
a) 1 3 5 b) 4 c) 5 d) error
13) Match the following
I ) long A) 64
II) int B) 32
III) short C) 16
IV) byte D) 8
a) I-A,II-B,III-C,IV-D b) I-B,II-C,III-A,IV-D c) I-A,II-D,III-B,IV-C d) None
14) String sum = “five”+ 5 + 5;
System.out.println(sum);
a) five55 b) five 10 c) 15 d) None
15) int x = 1;
switch(x)
{ case 0 : System.out.print("zero");
case 1 : System.out.print("one ");
case 2 : System.out.print("two ");
case 3 : System.out.print("three ");
default : System.out.print("Default ");
}
a) one, two, three, Default b) one
c) one, two, three d) zero,one, two, three, Default
III. Answer – 4 Mark.
1. A 2. B 3. B 4. C 5. A 6. C 7. A
8. A 9. C 10. A 11. B 12. A 13. A 14. A
15. A