JAVA QUIZ 3

16
Created on By Sirjana GhimireAcharya

JAVA QUIZ 3

1 / 10

1. Which data type is used to create a variable that should store text?

2 / 10

2. What is the output of the following code snippetĀ  ?

public class TestOverriding {
public static void main(String aga[]){
Super superRef =new Sub();
Sub subRef = new Sub();
Super suRef=new Super();

superRef.tests();
subRef.tests();
suRef.tests();
}
}
class Super{
public static void tests(){
System.out.println("Super static");
}
}
class Sub extends Super{
public static void tests(){
System.out.println("Sub static");
}
}

3 / 10

3. Which method can be used to return a string in upper case letters?

4 / 10

4. In ConcurrentHashMap - once thread locks one segment for updation it doesn't block it for retrieval hence another thread will scan the same segment, however, it'll be ready to read the data before locking?

5 / 10

5. whether the following will compile

import java.io.IOException

class Animal {
public void eat() throws IOException {
}
}
class Dog extends Animal {
public void eat() throws IOException {
}
}

6 / 10

6. Output of following Java Program?

class Base {
public void show() {
System.out.println("Base::show() called");
}
}

class Derived extends Base {
public void show() {
System.out.println("Derived::show() called");
}
}

public class Main {
public static void main(String[] args) {
Base b = new Derived();;
b.show();
}
}

7 / 10

7. Which of the following is a difference between StringBuffer and StringBuilder class?

8 / 10

8.To declare an array in Java, define the variable type with:

9 / 10

9. Array indexes start with:

10 / 10

10. In ConcurrentHashMap - once thread locks one segment for updation it doesn't allow the other thread to perform updations in the same segment till lock isn't released on the segment

Your score is

The average score is 67%

0%