1 . Given Answer class behaves like some a File it has a Vector, a color, some boolean variable.What is the correct declaration?
- import
- public
- private
- Vector
- Serializable
- File
- Color
- extends
- boolean
- implements
2 . Some design issues: The following description applies to a class: given someclassname behaves as somesuperclassname and it has some fields etc it is accessed in other files. No other class can behave as this class.What is the right syntax declaration of this class (without {)?
- extends
- public
- int
- class
- someclassname
- somesuperclass
- implements
- File
- extends
- Class
- final
3 . Which of the following is correct?
- The native keyword indicates that the method is implemented in another language like C/C++
- The only statements that can appear before an import statement in a Java file are comments
- The method definitions inside interfaces are public and abstract. They cannot be private or protected
- A class constructor may have public or protected keyword before them, nothing else
4 . What will be the output?
public class test { public static void main(String args[]) { String str1="abc"; String str2="def"; String str3=str1.concat(str2); str1.concat(str2); System.out.println(str1); } }
Choose the one below:
- abc
- def
- abcabc
- abcdef
- defabc
- abcdefdef
5 . What will be the output?
class test { public static void main(String args[]) { char ch; String test2 = "abcd"; String test = new String("abcd"); if(test.equals(test2)) { if(test == test2) ch = test.charAt(0); else ch = test.charAt(1); } else { if(test == test2) ch = test.charAt(2); else ch = test.charAt(3); } System.out.println(ch); } }
Choose the one below:
- ‘a’
- ‘b’
- ‘c’
- ‘d’
6 . To make a variable defined in a class accessible only to methods defined in the classes in same package, which of the following keyword should be used?
- By using the keyword package before the variable
- By using the keyword private before the variable
- By using the keyword protected before the variable
- By using the keyword public before the variable
- The variable should not be preceded by any of the above mentioned keywords
7 . Which Listener interface must be implemented by a class responsible for handling mouse clicks on buttons?
8 . Which of the following will output -4.0?
- System.out.println(Math.floor(-4.7));
- System.out.println(Math.round(-4.7));
- System.out.println(Math.ceil(-4.7));
- System.out.println(Math.Min(-4.7));
9 . What will be the output?
System.out.println(4 | 3);
Choose the one below:
- 6
- 0
- 1
- 7
10 . What will be the output?
class Background implements Runnable { int i=0; public int run() { while(true) { i++; System.out.println("i="+i); } } }
Choose the one below:
- It will compile and the run method will print out the increasing value of i
- It will compile and calling start will print out the increasing value of i
- The code will cause an error at compile time
- Compilation will cause an error because while cannot take a parameter of true
11 . What will be the output?
public class TechnoSample { public static void main(String argv[]) { TechnoSample sample = new TechnoSample(); sample.amethod(); } public void amethod() { int oi= 012; System.out.println(oi); } } // Oct
Choose the one below:
- 12
- 012
- 10
- 10.0
12 . You need to create a class that will store a unique object elements. You do not need to sort these elements but they must be unique. What interface might be most suitable to meet this need?
- Set
- List
- Map
- Vector
13 . You are concerned about that your program may attempt to use more memory than is available. To avoid this situation you want to ensure that the Java Virtual Machine will run its garbage collection just before you start a complex routine. What can you do to be certain that garbage collection will run when you want?
- You cannot be certain when garbage collection will run
- Use the Runtime.gc() method to force garbage collection
- Ensure that all the variables you require to be garbage collected are set to null
- Use the System.gc() method to force garbage collection
14 . Which of the following most closely describes a bitset collection?
- A class that contains groups of unique sequences of bits
- A method for flipping individual bits in instance of a primitive type
- An array of boolean primitives that indicate zeros or ones
- A collection for storing bits as on-off information, like a vector of bits
15 . You have these files in the same directory. What will happen when you attempt to compile and run Class1.java if you have not already compiled Base.java?
//Base.java package Base; class Base { protected void amethod() { System.out.println("amethod"); } } // Base
package Class1; public class Class1 extends Base { public static void main(String argv[]) { Base b = new Base(); b.amethod(); } } // Class1
Choose the one below:
- Compile Error: Methods in Base not found
- Compile Error: Unable to access protected method in base class
- Compilation followed by the output “amethod”
- Compile error: Superclass Class1.Base of class Class1.Class1 not found
16 . What will be the output?
class TechnoSample { public static void main(String args[]) { short[] s = {1, -1, 3, 4}; for (int i = 0; i switch(s[i]) { case 2-1: System.out.print("v "); break; case 'd'-'a': System.out.print("w "); break; case 0: System.out.print("x "); break; case ~0: System.out.print("y "); break; case 4&5: System.out.print("z "); break; default: System.out.print("Default "); } } } }
Choose the one below:
- Prints: v w x y
- Prints: v w x y z Default
- Prints: v y w z
- Prints: Default Default Default Default
- Runtime Exception
- Compiler Error
- None of the Above
17 . What will be the output?
class TechnoSample { public static void main (String args[]) { int i = 0; int j = 0; label1: while (i++<5) { label2: for (;;) { label3: do { System.out.print(i + j); switch (i+j++) { case 0: continue label3; case 1: continue label2; case 2: continue label1; case 3: break; case 4: break label3; case 5: break label2; case 6: break label1; default: break label1; } } while (++j<5); } } } }
Choose the one below:
- Prints: 12457
- Prints: 02357
- Prints: 02356
- Prints: 1357
- Prints: 1356
- Runtime Exception
- Compiler Error
- None of the Above
18 . What will be the output?
class A { void m1() {throw new ArithmeticException();} void m2() {throw new ClassCastException();} void m3() {throw new IllegalArgumentException();} void m4() {throw new IndexOutOfBoundsException();} void m5() {throw new NullPointerException();} void m6() {throw new SecurityException();} }
Choose the one below:
- Compiler error at line 2
- Compiler error at line 3
- Compiler error at line 4
- Compiler error at line 5
- Compiler error at line 6
- Compiler error at line 7
- None of the Above
19 . What will be the output?
class Level1Exception extends Exception {} class Level2Exception extends Level1Exception {} class Level3Exception extends Level2Exception {} class Purple { public static void main(String args[]) { int a,b,c,d,f,g,x; a = b = c = d = f = g = 0; x = 3; try { try { switch (x) { case 1: throw new Level1Exception(); case 2: throw new Level2Exception(); case 3: throw new Level3Exception(); } a++; } catch (Level2Exception e) {b++;} finally{c++;} } catch (Level1Exception e) { d++;} catch (Exception e) {f++;} finally {g++;} System.out.print(a+","+b+","+c+","+d+","+f+","+g); } }
Choose the one below:
- Prints: 1,1,1,0,0,1
- Prints: 0,1,1,0,0,1
- Prints: 0,1,0,0,0,0
- Prints: 0,1,0,0,0,1
- Prints: 0,0,1,0,0,1
- Compiler Error
- Run Time Error
- None of the Above
20 . What will be the output?
class A { public static void main (String args[]) { int h = 0, i = 0, j = 0, k = 0; label1: for (;;) { h++; label2: do { i++; k = h + i + j; switch (k) { default: break label1; case 1: continue label1; case 2: break; case 3: break label2; case 4: continue label2; case 5: continue label1; } } while (++j<5); } System.out.println(h + "," + i + "," + j); } }
Choose the one below:
- Prints: 1,2,3
- Prints: 1,3,2
- Prints: 2,2,2
- Prints: 2,4,1
- Prints: 2,4,2
- Runtime Exception
- Compiler Error
- None of the Above
21 . Which of the follow are true statements?
- A nested class is any class that is declared within the body of another class or interface
- A nested class can not be declared within the body of an interface declaration
- A top level class is a class this is not a nested class
- An inner class is a nested class that is not static
- A nested class can not be declared static
- A named class is any class that is not anonymous
- None of the above
22 . The only access control modifiers supported by Java are?
public protected private
Choose the one below:
- True
- False
23 . Which of the following are True?
- () is a unary operator
- () is a function operator
- int x = 10 + +11; is a invalid statment
- int x = (char)(int)(10); will give compiler error
24 . Which of the following statements are False?
- Checked exceptions can not be caught using catch() in the same function
- New exception can be thrown with in a catch block
- No exception can be thrown from a finally block
- for loop executes its block statments atleast once
- Unhandled exceptions are handled by JVM and the program will coninue
25 . What will be the output?
public class Q1 extends Thread { public void run() { System.out.println("Before start method"); this.stop(); System.out.println("After stop method"); } public static void main(String[] args) { Q1 a = new Q1(); a.start(); } }
Choose the one below:
- Compilation error at line 7
- Runtime exception at line 7
- Prints “Before start method” and “After stop method”
- Prints “Before start method” only
26 . What will be the output?
class Test { void show() { System.out.println("non-static method in Test"); } } public class Q3 extends Test { static void show() { System.out.println("Overridden non-static method in Q3"); } public static void main(String[] args) { Q3 a = new Q3(); } }
Choose the one below:
- Compilation error at line 3
- Compilation error at line 10
- No compilation error, but runtime exception at line 3
- No compilation error, but runtime exception at line 10
27 . What will be the output?
if( new Boolean("true") == new Boolean("true")) System.out.println("True"); else System.out.println("False");
Choose the one below:
- Compilation error
- No compilation error, but runtime exception
- Prints “True”
- Prints “False”
28 . Which of the following statements are True?
- Constructors cannot have a visibility modifier
- Constructors can be marked public and protected, but not private
- Constructors can only have a primitive return type
- Constructors are not inherited
29 . Which of the following will compile without error?
- char c=’1′;
System.out.println(c>>1); - Integer i=Integer(“1”);
System.out.println(i>>1); - int i=1;
System.out.println(i<<<1); - int i=1;
System.out.println(i<<1);
30 . You are given a class hierarchy with an instance of the class Dog. The class Dog is a child of mammal and the class Mammal is a child of the class Vertebrate. The class Vertebrate has a method called move which prints out the string “move”. The class mammal overrides this method and prints out the string “walks”. The class Dog overrides this method and prints out the string “walks on paws”. Given an instance of the class Dog. how can you access the ancestor method move in Vertebrate so it prints out the string “move”?
- d.super().super().move();
- d.parent().parent().move();
- d.move();
- none of the above
31 . Which of the following statements are True?
- An inner class may be defined as static
- There are NO circumstances where an inner class may be defined as private
- A programmer may only provide one constructor for an anonymous class
- An inner class may extend another class
32 . Under what circumstances might you use the yield method of the Thread class?
- To call from the currently running thread to allow another thread of the same or higher priority to run
- To call on a waiting thread to allow it to run
- To allow a thread of higher priority to run
- To call from the currently running thread with a parameter designating which thread should be allowed to run
33 . What will be the output?
public class Rand { public static void main(String argv[]) { int iRand; iRand = Math.random(); System.out.println(iRand); } } // Rand
Choose the one below:
- Compile time error referring to a cast problem
- A random number between 1 and 10
- A random number between 0 and 1
- A compile time error about random being an unrecognised method
34 . It is possible for two classes to be the super class of each other. True Or False?
- True
- False
35 . Given classes A, B & C where B extends A and C extends B, and where all classes implement the instance method ‘void print()’. How can the print() method in A be called from an instance method in C?
- print();
- super.print();
- super.super.print();
- this.super.print();
- A.this.print();
- ((A)this).print();
- It is not possible
36 . Which of these statements are valid when occuring by themselves?
- while() break;
- do { break; } while (true);
- if (true) { break; }
- switch (1) { default: break; }
- for (;true;) break;
37 . All public methods in the Thread class are static and therefore only affect the current thread. True Or False?
- True
- False
38 . Which of the following statements regarding threads are true?
- void run(void) method is one of the methods in the Runnable interface
- yield() causes the current thread to move into the ready state
- some of the public methods in the Thread class are static
- notify() takes one argument, the object to which it needs to notify and notifyAll() takes no arguments
- every object has a lock which controls which thread has access to the objects synchronized code
- wait, notify & notifyAll methods must always be called from inside synchronized code
- wait, notify & notifyAll methods are part of Thread class only
39 . What will be the output?
Double a = new Double(Double.NaN); Double b = new Double(Double.NaN); if( Double.NaN == Double.NaN ) System.out.println("True"); else System.out.println("False"); if( a.equals(b) ) System.out.println("True"); else System.out.println("False");
Choose the one below:
- True
True - True
False - False
True - False
False
40 . What will be the output?
public class Q11 { static String str1 = "main method with String[] args"; static String str2 = "main method with int[] args"; public static void main(String[] args) { System.out.println(str1); } public static void main(int[] args) { System.out.println(str2); } }
Choose the one below:
- Duplicate method main(), compilation error at line 6
- Duplicate method main(), compilation error at line 11
- Prints “main method with main String[] args”
- Prints “main method with main int[] args”
41 . What will be the output?
int i = 16; int j = 17; System.out.println("i >> 1 = " + (i >> 1)); System.out.println("j >> 1 = " + (j >> 1));
Choose the one below:
- Prints i >> 1 = 8
j >> 1 = 8 - Prints i >> 1 = 7
j >> 1 = 7 - Prints i >> 1 = 8
j >> 1 = 9 - Prints i >> 1 = 7
j >> 1 = 8
42 . What will be the output?
int i = 45678; int j = ~i; System.out.println(j);
Choose the one below:
- Compilation error at line 2. ~ operator applicable to boolean values only
- Prints 45677
- Prints -45677
- Prints -45679
43 . What will be the output?
void infiniteLoop() { byte b = 1; while ( ++b > 0 ) ; System.out.println("Welcome to Java"); }
Choose the one below:
- The loop never ends(infiniteLoop)
- Prints “Welcome to Java”
- Compilation error at line 5. ++ operator should not be used for byte type variables
- Prints nothing
44 . Which of the following are syntactically correct?
- String[] sa1,sa2;
- Integer iwSize[] = new Integer[]{new Integer(1)};
- short s[] = new short[10];
- int i[10];
45 . What will be the output?
class A {} class B extends A {} public class C { public static void main(String[] args) { A[] arrA; B[] arrB; arrA = new A[10]; arrB = new B[20]; arrA = arrB; // (1) arrB = (B[]) arrA; // (2) arrA = new A[10]; arrB = (B[]) arrA; // (3) } }
Choose the one below:
- (The code will fail to compile owing to the line labeled (1)
- The code will throw a java.lang.ClassCastException at the line labelel (2), when run
- The code will throw a java.lang.ClassCastException at the line labelel (3), when run
- The code will compile and run without problems, even if the (B[]) cast in the lines labeled (2) & (3) were removed
- The code will compile and run without problems, but would not do so if the (B[]) cast in the lines (2) & (3) were removed
46 . What will be the output?
public class Boxes{ String sValue; Boxes(String sValue){ this.sValue=sValue; } public String getValue(){ return sValue; } public boolean equals(Object o){ String s = (String) o; if (sValue.equals(s) ){ return true; }else{ return false; } } public int hashCode(){ return sValue.hashCode(); } }
Choose the one below:
- The hashCode method is correctly implemented
- This class will not compile as String has no hashCode method
- The hashCode method is not icorrectly implemented
- This class will not compile because the compareTo method is not implemented
47 . Which of the following are methods of the Collection interface?
- iterator
- isEmpty
- toArray
- setText
48 . What can cause a thread to stop executing?
- The program exits via a call to System.exit(0);
- Another thread is given a higher priority
- A call to the thread’s stop method
- A call to the halt method of the Thread class
49 . What will be the output?
public class TechnoExample { int xyz = 22; ... public void static main(String junkArgs[]) { ... } }
Choose the one below:
- this.xyz is accessible from the main method with any access specifier for xyz
- this.xyz is accessible from the main method if the declaration of xyz is private
- this.xyz is accessible from the main method if the declaration of xyz is public
- this.xyz is accessible from the main method without any changes to the existing code
50 . Which of the following statements are true?
- Creating a Thread using the Runnable interface does not require direct access to the Thread class
- Using the Thread class does not require any additional import statements
- yield is a static method of the Thread class
- yield is a static method of the Object class
Answers
1 :public class Answer extends File implements Serializable.
2 :public final class someclassname extends somesuperclassname.
3 : 1 & 3 is correct.
Explanation:
Please note that 2 is not correct. A package statement may appear before an import statement. A class constructor may be declared private also. Hence 4 is incorrect.
4 : 1 is correct.
5 : 2 is correct.
Explanation:
Both Strings test and test2 contain “abcd” . They are however located at different memory addresses. Hence test == test2 returns false, and test.equals(test2) returns true.
6 : 5 is correct.
Explanation:
A data member that does not have public/protected/private is accessible to all methods in the same package.
7 :ActionListener.
8 : 3 is correct.
Explanation:
Options 1 and 2 will produce -5 and option 4 will not compile because the Min method requires 2 parameters.
9 : 4 is correct.
Explanation:
The | is known as the Or operator, you could think of it as the either/or operator. Turning the numbers into binary gives
4 = 100
3 = 011
For each position, if either number contains a 1 the result will contain a result in that position. As every position contains a 1 the result will be
111, Which is decimal 7.
10 : 3 is correct.
Explanation:
The error is caused because run should have a void not an int return type.
Any class that is implements an interface must create a method to match all of the methods in the interface.The Runnable interface has one method called run that has a void return type.The sun compiler gives the error
Method redefined with different return type: int run() was defined as void run();
11 : 3 is correct.
Explanation:
Prefixing a number with a zero indicates that it is in Octal format. Thus when printed out it gets converted to base ten. 012 in octal means the first column from the right has a value of 2 and the next along has a value of one times eight.In decimal that adds up to 10.
12 : 1 is correct.
Explanation:
The Set interface ensures that its elements are unique, but does not order the elements. In reality you probably wouldn’t create your own class using the Set interface.You would be more likely to use one of the JDK classes that use the Set interface such as ArraySet.
13 : 1 is correct.
Explanation:
Although there is a Runtime.gc(), this only suggests that the Java Virtual Machine does its garbage collection. You can never be certain when the garbage collector will run.This uncertainty can cause consternation for C++ programmers who wish to run finalize methods with the same intent as they use destructor methods.
14 : 4 is correct.
Explanation:
The reference to unique sequence of bits was an attempt to mislead because of the use of the word Set in the name bitset. Normally something called a set implies uniqueness of the members, but not in this context.
15 : 4 is correct.
Explanation:
Using the package statement has an effect similar to placing a source file into a different directory. Because the files are in different packages they cannot see each other.The stuff about File1 not having been compiled was just to mislead, java has the equivalent of an “automake”, whereby if it was not for the package statements the other file would have been automatically compiled.
16 : 3 is correct.
Explanation:
The legal types for the switch expression are byte, short, char, and int. The constant case expressions can be any expression that is assignable to the type of the switch expression. ‘d’-‘a’=3. ~0=-1. 4&5=4.
17 : 1 is correct.
Explanation:
Since each iteration of the loop prints the value of the switch expression, it should be possible to figure out what is going on here.If more information is needed, then change the print statement so that the values of i and j are printed separately in columns.
18 : 7 is correct.
Explanation:
Methods m1(), m2(), m3(), m4(), m5(), and m6() throw subclasses of RuntimeException. Any exception that is a direct subclass of RuntimeException should not be caught and should not be declared in the throws clause of a method.
19 : 2 is correct.
Explanation:
The nested catch block is able to catch a Level2Exception or any subclass of it causing b to be incremented. Both of the finally blocks are then executed.
20 : 2 is correct.
Explanation:
The case 2 statement is processed on the first iteration followed by case 4 and then the default case. Case 2 causes the switch statement to complete.Case 4 processes the continue label2 statement which causes control to transfer to the boolean expression of the do-loop. The default case causes control to transfer out of the outer for-loop.
21 : 1,3,4 & 6 is correct.
Explanation:
Every class declared within the body of another class or interface is known as a nested class. If the nested class does not have a name then it is an anonymous class. If the nested class has a name then it is not anonymous.If the nested class has a name and is not declared inside of a block then it is a member class. If the member class is not static then it is an inner class. If the class is not nested then it is a top level class.Chapter 8 of the Java Language Specification defines class declarations. Section 8.1.2 of the JLS defines inner classes. Section 8.5 of the JLS defines member classes. Section 15.9.5 of the JLS defines anonymous class declarations.
22 : 2 is correct.
Explanation:
There is another access control modifier, which is the total lack of a modifier. Some authors refer to this as friendly access. Other authors refer to it as package access.
23 : 1 is correct.
24 : 1,3,4 & 5 is correct.
25 : 4 is correct.
Explanation:
After the execution of stop() method, thread won’t execute any more statements.
26 : 2 is correct.
Explanation:
You can’t override an non-static method with static method.
27 : 4 is correct.
28 : 4 is correct.
Explanation:
Constructors can be marked public, private or protected. Constructors do not have a return type.
29 : 1 & 4 is correct.
Explanation:
Be aware that Integer (not the upper case I) is a wrapper class and thus cannot be treated like a primitive. The fact that option 1 will compile may be a surprise, but although the char type is normally used to store character types,it is actually an unsigned integer type. The reason option 3 does not compile is that Java has a >>> operator but not a <<> operator but not a <<< operator.
30 : 4 is correct.
Explanation:
You may access methods of a direct parent class through the use of super but classes further up the hierarchy are not visible.
31 : 1 & 4 is correct.
Explanation:
A static inner class is also sometimes known as a top level nested class. There is some debate if such a class should be called an inner class.How could a programmer provide a constructor for an anonymous class?. Remember a constructor is a method with no return type and the same name as the class. Inner classes may be defined as private.
32 : 1 is correct.
Explanation:
Option 3 looks plausible but there is no guarantee that the thread that grabs the cpu time will be of a higher priority. It will depend on the threading algorithm of the Java Virtual Machine and the underlying operating system.
33 : 1 is correct.
Explanation:
This is a bit of a sneaky one as the Math.random method returns a pseudo random number between 0 and 1, and thus option 3 is a plausible Answer.However the number returned is a double and so the compiler will complain that a cast is needed to convert a double to an int.
34 : 2 is correct.
Explanation:
Please see the Java Language Specification
35 : 7 is correct.
Explanation:
It is not possible to invoke the print() method in A from an instance method in class C. The method in C needs to call a method in a super class two levels up. The super.super.print() strategy will not work, since super is a keyword, not anattribute. If the member to be accessed had been an instance variable, the solution would be to cast the ‘this’ reference to the class of the desired member and use the resulting reference to access the variable. Variable access is determinedby the declared type of the reference, where as the method to execute is determined by the actual type of the object denoted by the reference.
36 : 2,4 & 5 is correct.
Explanation:
The condition expression in a while header is not optional. It is not possible to break out of an if statement. Notice that if the ‘if’ statement had been placed within a labeled block, a switch statement or a loop construct, the usage of breakwould be valid.
37 : 1 is correct.
Explanation:
Please see Java Language Specification.
38 : 2,5 & 6 is correct.
Explanation:
void run() is the only method specified in Runnable interface. All the methods in the class Thread are public. notify() and notifyAll() doesn’t take any argument. wait(), notify() & notifyAll() are all part of class Object and implicitlyinherited by all the classes in Java. For detailed explanations, please see the Threads part of Java Language Specification.
39 : 3 is correct.
Explanation:
Please see the Java Language Specification.
40 : 3 is correct.
Explanation:
Here the main method was just overloaded, so it won’t give any compilation error.
41 : 1 is correct.
Explanation:
16 >> 1 is 8 and 17 >> 1 also 8.
42 : 4 is correct.
Explanation:
Java allows you to use ~ operator for integer type variables. The simple way to calculate is ~i = (- i) – 1.
43 : 2 is correct.
Explanation:
Here the variable ‘b’ will go upto 127. After that overflow will occur, so ‘b’ will be set to -ve value, the loop ends and prints “Welcome to Java”.
44 : 1,2 & 3 is correct.
Explanation:
(From Marcus Green’s Question of the day)
45 : 3 is correct.
Explanation:
The line labeled (1) will be allowed during compilation, since assignment is done from a subclass reference to a superclass reference. The line labeled (2) convinces the compiler that arrA will refer to an object that can bereferenced by arrB, and this will work when run, since arrA will refer to an object of type B[]. The line labeled (3) also convinces the compiler that arrA will refer to an object that can be referenced by arrB.This will not work when run, since arrA will refer to an object of type A[].
46 : 1 is correct.
Explanation:
The String class has its own implementation of the hashCode method. If it did not it would have inherited the hashCode method from Object which simply returns the memory address of the class instance.
47 : 1,2 & 3 is correct.
48 : 1,2 & 3 is correct.
Explanation:
Note that this question asks what can cause a thread to stop executing, not what will cause a thread to stop executing. Java threads are somewhat platform dependent and you should becarefull when making assumptions about Thread priorities. On some platforms you may find that a Thread with higher priorities gets to “hog” the processor.
49 : 4 is correct.
Explanation:
This one is a trick question that needs some assumption. Since main() is static only static members of the class are accessible within main(). Here xyz is not static. Hence this.xyz is not accessible from main() under any circumstances(with any access specified). “This” is entirely different from “this”. But no information has been given in the question about “This”. So you have to assume that there is a class instance called “This” and you are accessing the xyz variablebound to that instance.
50 : 2 & 3 is correct.
Explanation:
Creating a class with runnable still requires access to the Thread class. The class implementing Runnable is passed as a constructor parameter to an instance of Thread.