0 of 25 questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 25 questions answered correctly
Your time:
Time has elapsed
If m and n are int type variables, what will be the result of the expression
‘m % n’ when m = -14 and n = -3?
Consider the following class definition.
Class Student extends String
{
}
What happens when we try to compile this class?
Which key word can protect a class in package from accessibility by the classes outside the package?
We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would achieve this?
The concept of multiple inheritance is implemented in Java by:
Which of the following statements are valid array declarations?
Which of the following are the wrapper classes?
The methods wait() and noify() are defined in
What does the following line of code do?
TextField text=new TextField(10);
Which of the following methods can be used to draw the outline of a square?
What all gets printed when the following program is compiled and run.
public class test {
public static void main(String args[]) {
inti, j=1;
i = (j>1)?2:1;
switch(i) {
case 0: System.out.println(0); break;
case 1: System.out.println(1);
case 2: System.out.println(2); break;
case 3: System.out.println(3); break;
}
}
}
What is the output for the below code?
public interface InfA {
protected String getName();
}
public class Test implements InfA{
public String getName(){
return “test-name”;
}
public static void main (String[] args){
Test t = new Test();
System.out.println(t.getName());
}
}
public class TestDogs
{
public static void main(String [] args)
{
Dog [][] theDogs = new Dog[3][];
System.out.println(theDogs[2][0].toString());
}
}
class Dog { }
What is the output for the below code ?
public class A {}
public class B implements Serializable {
private static A a = new A();
public static void main(String… args){
B b = new B();
try{
FileOutputStream fs = new
FileOutputStream(“b.ser”);
ObjectOutputStream os = new
ObjectOutputStream(fs);
os.writeObject(b);
os.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
Choose the correct option.
You have a class file name Test.class inside javaproject directory.
Test.java source code is :
import javutil.Properties;
class Test {
public static void main (String[] args){
Properties p = System.getProperties();
System.out.println(p.getProperty(“key1”));
}
}
you have issued below commands from command prompt.
cd javaproject
java -D key1=value1 Test
What is the output ?
Choose the correct option.
Which of the following is correct?
Is this code create new file name txt ?
try{
File f = new File(“txt”);
}catch(Exception e){
}catch(IOException io){
}
What will happen when you try to compile and run this code?
public class TGo implements Runnable{
public static void main(String argv[]){
TGo tg = new TGo();
Thread t = new Thread(tg);
t.start();
}
public void run() {
while(true) {
Thread.currentThread().sleep(1000);
System.out.println(“looping while”);
}
}
}
What will happen when you attempt to compile and run the following code ?
public class Test extends Thread{
public static void main(String argv[]){
Test t = new Test();
t.run();
t.start();
}
public void run(){
System.out.println(“run-test”);
}
}
Given the code
String s = new String(“abc”);
Which of the following calls are valid?
Which of the following methods can be used to remove a component from the display?
How do you create a Reader object from an InputStream object?
Which of the following can you perform using the File class?
What is the name of the method used to schedule a thread for execution?
Examine the following class definition:
public class Test {
public static void test() {
print();
}
public static void print() {
System.out.println(“Test”);
}
public void print() {
System.out.println(“Another Test”);
}
}