JAVA QUIZ 4

9
Created on By Sirjana GhimireAcharya

JAVA QUIZ 4

1 / 10

1. What will be the output the following method Java code

public class TestOverriding {
public static void main(String aga[]){
Test t =new Fest();
t.tests();
}
}
class Test{
private void tests(){
System.out.println("Test class : tests");
}
}
class Fest extends Test{
public void tests(){
System.out.println("Fest class : fests");
}
}

 

2 / 10

2. Which class can access all public and protected methods and fields of its super class?

3 / 10

3. Method,Field can be accessed from the same class to which they belong.

4 / 10

4. How do you create a method in Java?

5 / 10

5. Which of the following is true about inheritance in Java?

1) Private methods are final.
2) Protected members are accessible within a package and
inherited classes outside the package.
3) Protected methods are final.
4) We cannot override private methods.

6 / 10

6. Output of following Java program?

final class Complex {

private final double re;
private final double im;

public Complex(double re, double im) {
this.re = re;
this.im = im;
}

public String toString() {
return "(" + re + " + " + im + "i)";
}
}

class Main {
public static void main(String args[])
{
Complex c = new Complex(10, 15);
System.out.println("Complex number is " + c);
}
}

 

7 / 10

7. What will be the output of following piece of code? ? public class operatorExample { public static void main(String args[]) { int x=10; System.out.println(x++); } }

8 / 10

8. Which keyword is used to create a class in Java?

9 / 10

9. Which interface should be implemented for sorting on basis of many criteria’s?

10 / 10

10.Which method can be used to find the highest value of x and y?

Your score is

The average score is 48%

0%