java 15-10-2023

java 15-10-2023

Professional Development

10 Qs

quiz-placeholder

Similar activities

Java Fundamentals

Java Fundamentals

Professional Development

11 Qs

Java SE: Programming I

Java SE: Programming I

Professional Development

10 Qs

2.13.2022 | Introduction to Java Review

2.13.2022 | Introduction to Java Review

Professional Development

8 Qs

Java Programming RBVRRIT

Java Programming RBVRRIT

University - Professional Development

10 Qs

6. Method

6. Method

Professional Development

10 Qs

Inheritance

Inheritance

Professional Development

15 Qs

JavaDemo1

JavaDemo1

Professional Development

15 Qs

ROUND 3

ROUND 3

Professional Development

15 Qs

java 15-10-2023

java 15-10-2023

Assessment

Quiz

Computers

Professional Development

Hard

Created by

DEVAKI AMIR

Used 2+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

public class Test

{

    public Test()

    {

        System.out.printf("1");

        new Test(10);

        System.out.printf("5");

    }

    public Test(int temp)

    {

        System.out.printf("2");

        new Test(10, 20);

        System.out.printf("4");

    }

    public Test(int data, int temp)

    {

        System.out.printf("3");

         

    }

     

    public static void main(String[] args)

    {

        Test obj = new Test();

         

    }

     

}

12345

Compilation error

15

Runtime error 

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

public class Outer

{

    private int data = 10;

      

    class Inner

    {

        private int data = 20;

        private int getData()

        {

            return data;

        }

        public void main(String[] args)

        {

            Inner inner = new Inner();

            System.out.println(inner.getData());

              

        }

    }

    private int getData()

    {

        return data;

    }

    public static void main(String[] args)

    {

        Outer outer = new Outer();

        Outer.Inner inner = outer.new Inner();

        System.out.printf("%d", outer.getData());

        inner.main(args);

    }

}

2010

1020

Compilation Error

None of these

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

class Derived 

{

    public void getDetails()

    {

        System.out.printf("Derived class ");

    }

}

  

public class Test extends Derived

{

    public void getDetails()

    {

        System.out.printf("Test class ");

        super.getDetails();

    }

    public static void main(String[] args)

    {

        Derived obj = new Test();

        obj.getDetails();

    }

}

Test class Derived class

Derived class Test class

Compilation error

Runtime error

4.

FILL IN THE BLANK QUESTION

2 mins • 1 pt

Predict the Output of the following code.
class Clidder 

{

    private final void flipper() 

    {

        System.out.println("Clidder");

    }

}

  

public class Clidlet extends Clidder 

{

    public final void flipper() 

    {

        System.out.println("Clidlet");

    }

    public static void main(String[] args) 

    {

        new Clidlet().flipper();

    }

}

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

class Grandparent 

{

    public void Print() 

    {

        System.out.println("Grandparent's Print()"); 

    } 

}

  

class Parent extends Grandparent 

{

    public void Print() 

    {

        System.out.println("Parent's Print()"); 

    } 

}

  

class Child extends Parent 

{

    public void Print()   

    {

        super.super.Print();

        System.out.println("Child's Print()"); 

    } 

}

  

public class Main 

{

    public static void main(String[] args) 

    {

        Child c = new Child();

        c.Print(); 

    }

}

Child's Print()

Parent's Print()

Grandparent's Print()

Compiler Error

Answer explanation

Error in in super.super.Print()
It is not allowed to do super.super. We can only access Grandparent’s members using Parent

6.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

public class Test

{

    private String function()

    {

        return ("GFG");

    }

    public final static String function(int data)

    {

        return ("GeeksforGeeks");

    }

    public static void main(String[] args)

    {

        Test obj = new Test();

        System.out.println(obj.function());   

    }

}

Compilation error 

Runtime error 

GFG 

None of these

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

class Main {

 public static void main(String args[]){

    final int i;

    i = 20;

    i = 30;

    System.out.println(i);

 }

}

20

Compiler Error

Garbage value

30

Answer explanation

i is assigned a value twice. Final variables can be assigned values only one. Following is the compiler error “Main.java:5: error: variable i might already have been assigned”

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?