Beruflich Dokumente
Kultur Dokumente
class $$ //2
_ += _$_[$]; //6
out.println(_); //7
A. 1
B. 2
C. 3
D. 4
E. 5
F. 6
G. 7
Ans:
Reason:
A. True
B. False
Ans:
Reason:
27 Given the following class, which of these are valid ways of referring to the
class from
package com.enthu;
// ....
// lot of code...
A. Base
Ans:
Reason:
28. Select the option(s) that is/are the best choice for the following:
Ans:
Reason:
class.
public class.
Final class.
Abstract class.
Ans:
Reason:
A. static int sa ;
C. abstract int t ;
D. void format( ) ;
Ans:
Reason:
A. num
B. int123
C. 2Next
D. _interface
E. a$_123
Ans:
Reason:
A. int a = b = c = 100;
B. int a, b, c; a = b = c = 100;
C. int a, b, c=100;
D. int a=100, b, c;
E. int a= 100 = b = c;
Ans:
Reason:
33 Which of the following data types comes under floating data types ?
A double
B int
C long
D byte
E float
Ans:
Reason:
34. Which of the following options contain correct code to declare and
initialize
a bit a = 0;
b integer a2 = 7;
c long a3 = 0x10C;
d short a4 = 0512;
e double a5 = 10;
f byte a7 = -0;
g long a8 = 123456789;
Ans:
Reason:
35. Select the options that, when inserted at // INSERT CODE HERE, will make
the following
System.out.println(ctr % 20);
a ctr += 1;
b ctr =+ 1;
c ++ctr;
d ctr = 1;
Ans:
Reason:
int a = 10;
int b = 20;
System.out.println(c);
a 218
b 232
c 246
d Compilation error
Ans:
Reason:
37 Character data type cannot store following value.
A String
B Digit
C Letter
D Special Character
Ans:
Reason:
38. Given the following contents of the Java source code file MyClass.java,
select the best option
package com.ejavaguru;
import java.util.Date;
class Student {}
class Course {}
Course classes.
c Both of the classes Student and Course are defined in the package
com.ejavaguru.
d Only the class Student is defined in the package com.ejavaguru. The class
Ans:
Reason:
class EJavaGuru {
public static void main(String[] args) {
what is the output of the previous class, if it is executed using the command:
a one:two:three
b EJavaGuru:one:two
c java:EJavaGuru:one
d two:three:four
Ans:
Reason:
40. Which of the following options, when inserted at //INSERT CODE HERE, will
print
Out EJavaGuru?
System.out.println("EJavaGuru");
Reason:
without errors?
int i;
// 1
B. InitTest() { si += 10; }
D. { i = 1000; }
Ans:
Reason:
42 Given:
}
}
sq.side = 10;
Ans:
Reason:
A byte
B long
C int
D short
Ans:
Reason:
package objective1;
// 1
public class StaticImports{
public StaticImports(){
out.println(MAX_VALUE);
Ans:
Reason:
A. goto
B. unsigned
C. _xyz
D. $_abc
E. iLikeVeryVeryVeryVeryVeryLongIdentifiersThatDontMakeAnySenseAtAll
(65 characters)
Ans:
Reason:
B. NULL
C. String
D. throws
E. long
F. strictfp
Ans:
Reason:
47 What does the zeroth element of the string array passed to the standard
main method contain?
Ans:
Reason:
int a;
int b;
public TestClass(){
int c;
c = a;
a++;
b += c;
{ new TestClass(); }
A. The code will fail to compile because the constructor is trying to access
static
members.
B. The code will fail to compile because the constructor is trying to use static
member
C. The code will fail to compile because the constructor is trying to use
member
D. The code will fail to compile because the constructor is trying to use local
variable
Ans:
Reason:
A. class
B. $value$
C. angstrom
D. 2much
E. zer@
Ans:
Reason:
boolean b = false;
int i = 90;
d Compilation error
Ans:
Reason:
51. Examine the following code and select the correct options:
System.out.println(returnVal); // line 7
} // line 8
} // line 9
true;
false);
Ans:
Reason:
52. If the functionality of the operators = and > were to be swapped in Java
(for the
code on line numbers 4, 5, and 6), what would be the result of the following
code?
a true
true
false
b 10.0
false
false
c false
false
false
d Compilation error
Ans:
Reason:
int a;
int b = 0;
static int c;
int d;
int e = 0;
// Line 1
A. a++;
B. b++;
C. c++;
D. d++
E. e++;
Ans:
Reason:
54 Which of the following is illegal ?
A. char c = 320;
B. float f = 320;
C. double d = 320;
D. byte b = 320;
Ans:
Reason:
A. "x"
B. 'x'
C. 10.2F
D. Object
E. false
Ans:
Reason:
56. What are the valid components of a Java source file (choose all that
apply):
a package statement
b import statements
c methods
d variables
e Java compiler
Ans:
Reason:
57. The following numbered list of Java class components is not in any
particular
order. Select the correct order of their occurrence in a Java class (choose all
that apply):
1 comments
2 import statement
3 package statement
4 methods
5 class declaration
6 variables
a 1, 3, 2, 5, 6, 4
b 3, 1, 2, 5, 4, 6
c 3, 2, 1, 4, 5, 6
d 3, 2, 1, 5, 6, 4
Ans:
Reason:
short x = 10;
x = x*5;
System.out.print(x);
A.50
B.10
C.Compilation Error
D.None of these
Ans:
Reason:
int t = 5;
A. int
B. long
C. only double
D. double or float
E. float
Ans:
Reason:
60 What will the following program print?
unsigned byte b = 0;
b--;
System.out.println(b);
A. 0
B. -1
C. 255
D. -128
Ans:
Reason:
int i1 = 1, i2 = 2, i3 = 3;
int i4 = i1 + (i2=i3 );
System.out.println(i4);
A. True
B. False
Ans:
Reason:
62 Consider the following code:
class Test{
What will be the output when it is run using the following command:
C. goodgoodgood
D. good bye
Ans:
Reason:
class A
long y = 1_3;//3
System.out.println(x+ +y);
}}
a)Compiler error at //1
d) 13 13
Ans:
Reason:
64 What will be the result of attempting to compile and run the following
class?
int i, j, k;
i = j = k = 9;
System.out.println(i);
A. The code will not compile because unlike in c++, operator '=' cannot be
chained
i.e. a = b = c = d is invalid.
B. The code will not compile as 'j' is being used before getting initialized.
C. The code will compile correctly and will display '9' when run.
D. The code will not compile as 'j' and 'i' are being used before getting
initialized.
Ans:
Reason:
65. Guess the output
return ++i;
int k = m1(args.length);
k += 3 + ++k;
System.out.println(k);
B. 6
c. 5
d. 7
Ans:
Reason:
A. !
B. ~
C. &
D. %
E. $
Ans:
Reason:
67. Guess the output
class main_class {
int x = 9;
if (x == 9) {
int x = 8;
System.out.println(x);
a) 9
b) 8
c) Compilation error
d) Runtime error
Ans:
Reason:
a) 0x99fffL
b) ABCDEFG
c) 0x99fffa
d) 99671246
Ans:
Reason:
69 What will be the output of this program?
class booloperators {
B 1
true
false
Ans:
Reason:
a) Infinite
b) Only 1
c) System Dependent
Ans:
Reason: