Você está na página 1de 32

Started on Thursday, 22 September 2016, 8:09 AM

State Finished
Completed on Thursday, 22 September 2016, 8:52 AM
Time taken 43 mins 14 secs
Marks 45.00/50.00
Grade 9.00 out of 10.00 (90%)
Question 1
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of these keywords is used to prevent content of a variable from being modified?
Select one:

a. final

b. last

c. constant

d. static
Feedback

Your answer is correct.

Question 2
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class overload {
int x;
double y;
void add(int a , int b) {
x = a + b;
}
void add(double c , double d){
y = c + d;
}
overload() {
this.x = 0;
this.y = 0;
}
}
class Overload_methods {
public static void main(String args[])
{
overload obj = new overload();
int a = 2;
double b = 3.2;
obj.add(a, a);
obj.add(b, b);
System.out.println(obj.x + " " + obj.y);
}
}
Select one:

a. 6 6

b. 6.4 6.4

c. 6.4 6

d. 4 6.4
Feedback

Your answer is correct.

Question 3
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of the following statement is incorrect?


Select one:
a. Default constructor is called at the time of declaration of the object if a constructor has not been
defined

b. Constructor can be parameterized

c. finalize() method is called when an object goes out of scope and is no longer needed

d. finalize() method must be declared protected


Feedback

Your answer is correct.

Question 4
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the return type of Constructors?


Select one:

a. int

b. float

c. void

d. None of the mentioned


Feedback

Your answer is correct.

Question 5
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What a Java programmer calls a __, a C/C++ programmer calls a function?


Select one:

a. Method
b. Object
Feedback

Your answer is correct.

Question 6
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Which one of these lists contains only Java programming language keywords?
Select one:

a. class, if, void, long, Int, continue

b. goto, instanceof, native, finally, default, throws

c. try, virtual, throw, final, volatile, transient

d. strictfp, constant, super, implements, do

e. byte, break, assert, switch, include


Feedback

Your answer is incorrect.

Question 7
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which is a reserved word in the Java programming language?


Select one:

a. method

b. native

c. subclasses

d. reference
e. array
Feedback

Your answer is correct.

Question 8
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of the following statements are incorrect?


Select one:

a. public members of class can be accessed by any code in the program

b. private members of class can only be accessed by other members of the class

c. private members of class can be inherited by a sub class, and become protected members in sub

class

d. protected members of a class can be inherited by a sub class, and become private members of the
sub class
Feedback

Your answer is correct.

Question 9
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of these is correct about passing an argument by call-by-value process?


Select one:

a. Copy of argument is made into the formal parameter of the subroutine

b. Reference to original argument is passed to formal parameter of the subroutine

c. Copy of argument is made into the formal parameter of the subroutine and changes made on
parameters of subroutine have effect on original argument
d. Reference to original argument is passed to formal parameter of the subroutine and changes made
on parameters of subroutine have effect on original argument
Feedback

Your answer is correct.

Question 10
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class access{
public int x;
private int y;
void cal(int a, int b){
x = a + 1;
y = b;
}
void print() {
system.out.println(" " + y);
}
}
class access_specifier {
public static void main(String args[])
{
access obj = new access();
obj.cal(2, 3);
System.out.println(obj.x);
obj.print();
}
}
Select one:

a. 2 3

b. 3 3
c. Runtime Error

d. Compilation Error
Feedback

Your answer is correct.

Question 11
Correct

Mark 1.00 out of 1.00

Flag question

Question text

Which four options describe the correct default values for array elements of the types indicated?
1. int -> 0
2. String -> "null"
3. Dog -> null
4. char -> '\u0000'
5. float -> 0.0f
boolean -> true
Select one:

a. 1,2,3,4

b. 1,3,4,5

c. 2,4,5,6

d. 3,4,5,6

Feedback

Your answer is correct.


Question 12
Correct

Mark 1.00 out of 1.00

Flag question
Question text

Which of these can be overloaded?


Select one:

a. Methods

b. Constructors

c. Both a & b

d. None of the mentioned

Feedback

Your answer is correct.


Question 13
Incorrect

Mark 0.00 out of 1.00

Flag question

Question text

Which of these selection statements test only for equality?


Select one:

a. if

b. switch

c. if & switch

d. None of the mentioned

Feedback

Your answer is incorrect.


Question 14
Correct

Mark 1.00 out of 1.00


Flag question

Question text

What is the name of the thread in output of this program?


class multithreaded_programing {
public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println(t.getPriority());
}
}
Select one:

a. 0

b. 1

c. 4

d. 5

Feedback

Your answer is correct.


Question 15
Correct

Mark 1.00 out of 1.00

Flag question

Question text

Which will legally declare, construct, and initialize an array?


Select one:

a. int [] myList = {"1", "2", "3"};


b. int [] myList = (5, 8, 2);

c. int myList [] [] = {4,9,7,0};

d. int myList [] = {4, 3, 7};

Feedback

Your answer is correct.


Question 16
Correct

Mark 1.00 out of 1.00

Flag question

Question text

enum is a Keyword in Java, introduced from J2SE 5


Select one:

a. True

b. False

Feedback

Your answer is correct.


Question 17
Correct

Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class rightshift_operator {
public static void main(String args[])
{
int x;
x = 10;
x = x >> 1;
System.out.println(x);
}
}
Select one:

a. 10

b. 5

c. 2

d. 20

Feedback

Your answer is correct.


Question 18
Correct

Mark 1.00 out of 1.00

Flag question

Question text

Which are valid declarations of a char?


1. char c1 = 064770;
2. char c2 = 'face';
3. char c3 = 0xbeef;
4. char c4 = \u0022;
5. char c5 = '\iface';
6. char c6 = '\uface';
Select one:

a. 1,2,4

b. 1,3,6

c. 3,5
d. 5 Only

Feedback

Your answer is correct.


Question 19
Correct

Mark 1.00 out of 1.00

Flag question

Question text

Which of these method of class String is used to extract a single character from a String object?
Select one:

a. CHARAT()

b. chatat()

c. charAt()

d. ChatAt()

Feedback

Your answer is correct.


Question 20
Correct

Mark 1.00 out of 1.00

Flag question

Question text

Which of these statements is incorrect?


Select one:

a. Every class must contain a main() method


b. Applets do not require a main() method at all

c. There can be only one main() method in a program

d. main() method must be made public

Feedback

Your answer is correct.

Question 21
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

What is the output of this program?


class access{
public int x;
private int y;
void cal(int a, int b){
x = a + 1;
y = b;
}
}
class access_specifier {
public static void main(String args[])
{
access obj = new access();
obj.cal(2, 3);
System.out.println(obj.x + " " + obj.y);
}
}
Select one:

a. 3 3

b. 2 3

c. Runtime Error
d. Compilation Error
Feedback

Your answer is incorrect.

Question 22
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of the following is a valid declaration of an object of class Box?


Select one:

a. Box obj = new Box();

b. Box obj = new Box;

c. obj = new Box();

d. new Box obj;


Feedback

Your answer is correct.

Question 23
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

What is the output of following block of program?


boolean var = false;
if(var = true) {
System.out.println(“TRUE”);
} else {
System.out.println(“FALSE”);
}
Select one:
a. False

b. True
Feedback

Your answer is incorrect.

Question 24
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class multithreaded_programing {
public static void main(String args[]) {
Thread t = Thread.currentThread();
t.setName("New Thread");
System.out.println(t);
}
}
Select one:

a. Thread[5,main]

b. Thread[New Thread,5]

c. Thread[main,5,main]

d. Thread[New Thread,5,main]
Feedback

Your answer is correct.

Question 25
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which three are legal array declarations?
1. int [] myScores [];
2. char [] myChars;
3. int [6] myScores;
4. Dog myDogs [];
5. Dog myDogs [7];
Select one:

a. 1,2,4

b. 2,4,5

c. 2,3,4

d. All are correct


Feedback

Your answer is correct.

Question 26
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Can there be an abstract class with no abstract methods in it?


Select one:

a. Yes

b. No
Feedback

Your answer is correct.

Question 27
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of these are selection statements in Java?


Select one:

a. if()

b. for()

c. continue

d. break
Feedback

Your answer is correct.

Question 28
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of these cannot be declared static?


Select one:

a. class

b. object

c. variable

d. method
Feedback

Your answer is correct.

Question 29
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which keyword is used by method to refer to the object that invoked it?
Select one:

a. import
b. catch

c. abstract

d. this
Feedback

Your answer is correct.

Question 30
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of these statements are incorrect?


Select one:

a. The left shift operator, <<, shifts all of the bite in a value to the left specified number of times

b. The right shift operator, >>, shifts all of the bite in a value to the right specified number of times

c. The left shift operator can be used as an alternative to multiplying by 2

d. The right shift operator automatically fills the higher order bits with 0
Feedback

Your answer is correct.

Question 31
Correct

Mark 1.00 out of 1.00

Flag question

Question text

Which one of the following will declare an array and initialize it with five numbers?
Select one:

a. Array a = new Array(5);


b. int [] a = {23,22,21,20,19};

c. int a [] = new int[5];

d. int [5] array;

Feedback

Your answer is correct.


Question 32
Correct

Mark 1.00 out of 1.00

Flag question

Question text

Which is a valid keyword in java?


Select one:

a. interface

b. String

c. Float

d. Unsigned

Feedback

Your answer is correct.


Question 33
Correct

Mark 1.00 out of 1.00

Flag question

Question text
Which is the valid declarations within an interface definition?
Select one:

a. public double methoda();

b. public final double methoda();

c. static void methoda(double d1);

d. protected void methoda(double d1);

Feedback

Your answer is correct.


Question 34
Correct

Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class selection_statements {
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}
Select one:

a. 1

b. 2
c. 3

d. 4

Feedback

Your answer is correct.


Question 35
Correct

Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class main_class {
public static void main(String args[])
{
int x = 9;
if (x == 9) {
int x = 8;
System.out.println(x);
}
}
}
Select one:

a. 9

b. 8

c. Compilation error

d. Runtime error

Feedback

Your answer is correct.


Question 36
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Can an Interface have an inner class?


Select one:

a. Yes

b. No

Feedback

Your answer is correct.


Question 37
Correct

Mark 1.00 out of 1.00

Flag question

Question text

Which of the following package stores all the standard java classes?
Select one:

a. lang

b. java

c. util

d. java.packages

Feedback

Your answer is correct.


Question 38
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class bitwise_operator {
public static void main(String args[])
{
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d);
}
}
Select one:

a. 7 2

b. 7 7

c. 7 5

d. 5 2

Feedback

Your answer is correct.


Question 39
Correct

Mark 1.00 out of 1.00

Flag question

Question text
What is the output of this program?
class box {
int width;
int height;
int length;
int volume;
box() {
width = 5;
height = 5;
length = 6;
}
void volume() {
volume = width*height*length;
}
}
class constructor_output {
public static void main(String args[])
{
box obj = new box();
obj.volume();
System.out.println(obj.volume);
}
}
Select one:

a. 100

b. 150

c. 200

d. 250

Feedback

Your answer is correct.


Question 40
Correct

Mark 1.00 out of 1.00


Flag question

Question text

Which of these is not a bitwise operator?


Select one:

a. &

b. &=

c. |=

d. <=

Feedback

Your answer is correct.


Question 41
Correct
Mark 1.00 out of 1.00

Flag question

Question text

public interface Foo


{
int k = 4; /* Line 3 */
}
Which three piece of codes are equivalent to line 3?
1. final int k = 4;
2. public int k = 4;
3. static int k = 4;
4. abstract int k = 4;
5. volatile int k = 4;
6. protected int k = 4;
Select one:

a. 1,2 and 3
b. 2,3 and 4

c. 3,4 and 5

d. 4,5 and 6
Feedback

Your answer is correct.

Question 42
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the stored in the object obj in following lines of code?


box obj;
Select one:

a. Memory address of allocated memory of object

b. NULL

c. Any arbitrary pointer

d. Garbage
Feedback

Your answer is correct.

Question 43
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class overload {
int x;
int y;
void add(int a) {
x = a + 1;
}
void add(int a, int b){
x = a + 2;
}
}
class Overload_methods {
public static void main(String args[])
{
overload obj = new overload();
int a = 0;
obj.add(6);
System.out.println(obj.x);
}
}
Select one:

a. 5

b. 6

c. 7

d. 8
Feedback

Your answer is correct.

Question 44
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class bitwise_operator {
public static void main(String args[])
{
int var1 = 42;
int var2 = ~var1;
System.out.print(var1 + " " + var2);
}
}
Select one:

a. 42 42

b. 42 43

c. 42 -43

d. 42 43
Feedback

Your answer is correct.

Question 45
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Which of the following statements are incorrect?


Select one:

a. static methods can call other static methods only

b. static methods must only access static data

c. static methods can not refer to this or super in any way

d. when object of class is declared, each object contains its own copy of static variables
Feedback

Your answer is incorrect.

Question 46
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass
B?
Select one:

a. super(void);

b. superclass.();

c. super.A();

d. super();
Feedback

Your answer is correct.

Question 47
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class A {
int i;
void display() {
System.out.println(i);
}
}
class B extends A {
int j;
void display() {
System.out.println(j);
}
}
class inheritance_demo {
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
Select one:

a. 0

b. 1

c. 2

d. Compilation Error
Feedback

Your answer is correct.

Question 48
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Java support RMI. What does this RMI stands for?


Select one:

a. Remote Method Invocation

b. Random Memory Invocation


Feedback

Your answer is correct.

Question 49
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Which of the following statements are incorrect?


Select one:

a. public members of class can be accessed by any code in the program


b. private members of class can only be accessed by other members of the class

c. private members of class can be inherited by a sub class, and become protected members in sub

class

d. protected members of a class can be inherited by a sub class, and become private members of the
sub class
Feedback

Your answer is correct.

Question 50
Correct
Mark 1.00 out of 1.00

Flag question

Question text

What is the output of this program?


class output {
public static void main(String args[])
{
String c = "Hello i love java";
int start = 2;
int end = 9;
char s[]=new char[end-start];
c.getChars(start,end,s,0);
System.out.println(s);
}
}
Select one:

a. Hello, i love java

b. i love ja

c. lo i lo

d. llo i l
Feedback

Your answer is correct.

Você também pode gostar