Class And Object In Java Quiz

10 Questions | Total Attempts: 200

Please wait...
Java Quizzes & Trivia

Java is a class-based, object-based programming language that is designed to create desktop and mobile apps. Along with that, it is also used for big data processing and system embedding. Know the java equations and array better in this test about java language.


Questions and Answers
  • 1. 
    Which of the following is true about private constructor?
    • A. 

       Private constructor makes sure only one instance of a class exists at any time

    • B. 

      Private constructor makes sure multiple instances of a class exist at any time

    • C. 

      Private constructor ensures the instantiation of a class with ease

    • D. 

      Private constructor facilitates creation of objects in other classes

  • 2. 
    What will be the behavior of Java script if this() and super() used in the same method?  
    • A. 

      Runtime error

    • B. 

      Runtime error

    • C. 

      Throws exception

    • D. 

      Runs successfully

  • 3. 
    In Java, which of these operators is used to place memory to array variable?  
    • A. 

      Malloc

    • B. 

      Alloc

    • C. 

      New

    • D. 

      New malloc

  • 4. 
    What is true about protected constructor?
    • A. 

      It can be called directly

    • B. 

      It can only be called using super()  

    • C. 

      It can be used outside package  

    • D. 

      It can be instantiated even if the child is in a completely different package

  • 5. 
    Abstract class cannot have a constructor.
    • A. 

      True

    • B. 

      False

  • 6. 
    If the constructor has a return type, what will be its behavior?
    • A. 

      Compilation error

    • B. 

       Runtime error

    • C. 

      Compilation and runs successfully

    • D. 

      Only String return type is allowed

  • 7. 
    Which one of the following is not a correct array declaration?  
    • A. 

      Int arr[] = int [5] new

    • B. 

      Int [] arr = new int[5]

    • C. 

      Int arr[] = new int[5]

    • D. 

      Int arr[] = new int[5]

  • 8. 
    Which of these class can be used to make an object whose character sequence is mutable?
    • A. 

      String()

    • B. 

      String() & StringBuffer()

    • C. 

      StringBuffer()

    • D. 

      None of the mentioned

  • 9. 
    If one has to extract a single character from a String object, which of these method of class String can be used?
    • A. 

      CHARAT()

    • B. 

      Chatat()

    • C. 

      CharAt()

    • D. 

      ChatAt()

    • E. 

      Option 5

  • 10. 
    Which of these is an incorrect statement?
    • A. 

      String objects are immutable, they can never be changed  

    • B. 

      String object usually point to another reference of a string variable

    • C. 

      StringBuffer class can be used to store string in a buffer to be used later

    • D. 

      None of the mentioned

Back to Top Back to top