Site icon DataFlair

Quiz on Object Creation in Java

quiz on object creation in java

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Mastering object creation in Java is a critical stepping stone on your path to becoming a proficient programmer. Just as a strong foundation is essential for a building, a solid understanding of object creation is fundamental to crafting robust and well-structured Java applications.

This interactive quiz is designed to be your engaging companion on this journey. By participating in this quiz, you’ll have the opportunity to test your knowledge of various object instantiation techniques in Java. Think you’ve got a handle on constructors, the mysterious `new` keyword, and how object references work?

This quiz will put your understanding to the test! More importantly, the quiz will serve as a valuable learning tool. By tackling the challenges it presents, you’ll not only identify areas where your knowledge might be shaky, but you’ll also solidify your grasp of these core concepts. So, take a deep breath, dive into the quiz, and embark on a rewarding journey to master object creation in Java! Let’s test your knowledge.

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

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:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

    Which of the following is not a way to create an Object in Java ?

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

     class Main {

    public static void main ( String args [ ] )

    {

    Main obj = new Main ();

    obj.print(“DataFlair”);

    }

    public void print( String a )

    {

    System.out.println(a);

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

     private class ClassName {

    private void method ( )

    {

    System.out.println(“Private class method”);

    }

    }

    class main {

    public static void main ( String args [ ] )

    {

    ClassName cls = new Classname();

    cls.method();

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

    Which of the following is the correct syntax to create an object using the new Keyword ?

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

     class Example {

    public void area ( int side)

    {

    return(side*side);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    Example e = new Example ( 5);

    System.out.println(e.area());

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

    class Function {

    public void method1()

    {

    System.out.println(“Parent class”);

    }

    }

    class Object extends Function {

    public void method2()

    {

    System.out.println(“Child class”);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    Function object = new Function();

    object.method1();

    Sample object = new Sample();

    object.method2();

    }

    }

    What is the reason for error in the program ?

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

    Which of the following is not an exception thrown by newinstance object creation ?

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

     class ObjectCreation {

    public void sum ( int a , int b )

    {

    System.out.println(a+b);

    }

    }

    class Objects {

    public void subtract( int a , int b )

    {

    System.out.println(a-b);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    ObjectCreation obj1 = new ObjectCreation();

    obj1.sum(10,5);

    Objects obj2 = new Objects();

    obj2.subtract(10,5);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

     class Inheritance {

    public void print()

    {

    System.out.println(“DataFlair”):

    }

    }

    class Sample extends Inheritance {

    Public void disp( )

    {

    System.out.println(“Webservices”);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    Sample s = new Sample ( ) ;

    s.print();

    s.disp();

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

    Which method should be implemented to clone an object ?

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

    class Sample {

    public void display ( )

    {

    System.out.println(“DataFlair”);

    }

    }

    Class main {

    public static void main ( String args [ ] )

    {

    Sample s = new Sample();

    s.display();

    public void message()

    {

    System.out.println(“webservices”);

    }

    Main m = new Main();

    message();

    }

    }

    Which of the given objects are deleted by the garbage collector in Java ?

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    class First {

    public void method()

    {

    System.out.println(“First class method is invoked”);

    }

    }

    class Second {

    public void function ( ) 

    {

    System.out.println(“Second class method is invoked”);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    First f = new First();

    f.method();

    f.function();

    }

    }

    What is the error in the program ?

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    Which of the functions creates a separate object using JVM when it is invoked ?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

     class Function {

    public void method() 

    {

    System.out.println(“Method invoked using object”);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    Function obj = new Function();

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    class Objects {

    public static void main ( String args [ ] )

    {

    public void method() 

    {

    System.out.println(“Object is not needed for same class method”);

    }

    }

    What is the output of the program ?

    Correct
    Incorrect

Summary:

So you’ve taken the Java Object Creation Quiz and put your skills to the test! This quiz covered essential concepts for creating objects in Java. By reviewing both your correct and incorrect answers, you can gain valuable insights into your strengths and weaknesses in this crucial domain. Remember, effective learning is an ongoing process.

Explore additional resources beyond the quiz to deepen your understanding. Consider online courses, tutorials, and practice problems to further solidify your grasp of object creation in Java.

Exit mobile version