JavaCore Test 8

Which operator is used to perform bitwise inversion in Java.

Is this True or False. In Java a final class must be sub-classed before it can be used.

Using up to four characters, write the Java representation of integer literal 3 in hexadecimal.

Which of the following are true.

After the following code fragment, what is the value in fname?

String str;
int fname;
str = "Foolish boy.";
fname = str.indexOf("fool");

How many bytes are used to represent the primitive data type int in Java.

Select the one correct answer. The smallest number that can be represented using short primitive type in Java is -

Is this true or false. Map interface is derived from the Collection interface.

What is the result of compiling and running the following class.

class Test 
{
public void methodA(int i)
{
System.out.println(i);

}
public int methodA(int i)
{
System.out.println(i+1);
return i+1;
}
public static void main(String args[])
{
Test X = new Test();
X.methodA(5);
}
}

What gets printed when the following program is compiled and run.

public class test {
public static void main(String args[]) {
byte x = 3;
x = (byte)~x;
System.out.println(x);
}
}

Which of the following are true.
a. A static method may be invoked before even a single instance of the class is constructed.
b. A static method cannot access non-static methods of the class.
c. Abstract modifier can appear before a class or a method but not before a variable.
d. final modifier can appear before a class or a variable but not before a method.
e. Synchronized modifier may appear before a method or a variable but not before a class.


Name the access modifier which when used with a method, makes it available to all the classes in the same package and to all the subclasses of the class.

What is the value of "number" after the following code fragment execution?

int number = 0;
int number2 = 12
while (number < number2)
{
number = number + 1;
}

What is the legal range of values for a variable declared as a byte.

Given the following declarations, which of the assignments given in the options below would compile.

int i = 5;
boolean t = true;
float f = 2.3F;
double d = 2.3;

a. t = (boolean) i;
b. f = d;
c. d = i;
d. i = 5;
e. f = 2.8;


What gets displayed on the screen when the following program is compiled and run.

public class test {
public static void main(String args[]) {
int x,y;
x = 3 & 5;
y = 3 | 5;
System.out.println(x + " " + y);
}
}

Name the access modifier which when used with a method, makes it available to all the classes in the same package and to all the subclasses of the class.

Given the following code snippet;

int salaries[];
int index = 0;
salaries = new int salaries[4];
while (index < 4)
{
salaries[index] = 10000;
index++;
}

What is the value of salaries [3]?

The width in bits of double primitive type in Java is --.

What gets printed when the following program is compiled and run.

public class incr {
public static void main(String args[]) {
int i , j;
i = j = 3;
int n = 2 * ++i;
int m = 2 * j++;
System.out.println(i + " " + j + " " + n + " " + m);
}
}

Schreibe einen Kommentar