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.
Which of the following is not a way to create an Object in Java ?
Correct
Incorrect
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
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
Question 4 of 15
4. Question
Which of the following is the correct syntax to create an object using the new Keyword ?
Correct
Incorrect
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
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
Question 7 of 15
7. Question
Which of the following is not an exception thrown by newinstance object creation ?
Correct
Incorrect
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
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
Question 10 of 15
10. Question
Which method should be implemented to clone an object ?
Correct
Incorrect
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
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
Question 13 of 15
13. Question
Which of the functions creates a separate object using JVM when it is invoked ?
Correct
Incorrect
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
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.
Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google
DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.