Core Java Programming

Ace your homework & exams now with Quizwiz!

How are fields initialized by default in Java?

Fields can be initialized or not. An uninitialized field is implicitly initialized to "zero" value: null, 0, false, etc. depending on the field's type. private String name; //implicitly =null private Buddy friend = null; //explicitly =null

What is a JAR?

A JAR is a package file. A JAR contains Java classes and all dependent resources such as images, sound, and data. And a manifest file that describes its contents.

What are the differences between the constructors and methods?

A constructor is used to initialize the state of an object. A method is used to expose the behavior of an object. A constructor must not have a return type. A method must have a return type. The Java compiler provides a default constructor if you don't have any constructor in a class. The method is not provided by the compiler in any case. The constructor name must be same as the class name. The method name may or may not be same as class name.

What is a deadlock?

A lock occurs when multiple processes try to access the same resource at the same time. One process loses out and must wait for the other to finish. A deadlock occurs when the waiting process is still holding on to another resource that the first needs before it can finish.

What is a JVM?

Java Virtual Machine is a virtual machine that enables the computer to run the Java program. JVM acts like a run-time engine which calls the main method present in the Java code. The Java code is compiled by JVM to be a Bytecode which is machine independent and close to the native code.

What is method overloading?

Method overloading is the polymorphism technique which allows us to create multiple methods with the same name but different signature. We can achieve method overloading in two ways. Changing the number of arguments Changing the return type Method overloading increases the readability of the program. Method overloading is performed to figure out the program quickly.

Can we make constructors static?

Since Constructors are invoked only when the object is created, there is no sense to make the constructors static. However, if you try to do so, the compiler will show the compiler error.

What is an object?

The Object is the real-time entity having some state and behavior. In Java, Object is an instance of the class having the instance variables as the state of the object and the methods as the behavior of the object. The object of a class can be created by using the new keyword.

What is the output of the following Java program? for(int i=0; 0; i++) { System.out.println("Hello Javatpoint"); }

The above code will give the compile-time error because the for loop demands a boolean value in the second part and we are providing an integer value, i.e., 0.

What gives Java its 'write once and run anywhere' nature?

The bytecode. Java compiler converts the Java programs into the class file (Byte Code) which is the intermediate language between source code and machine code. This bytecode is not platform specific and can be executed on any computer.

What is the constructor?

The constructor can be defined as the special type of method that is used to initialize the state of an object. It is invoked when the class is instantiated, and the memory is allocated for the object. Every time, an object is created using the new keyword, the default constructor of the class is called. The name of the constructor must be similar to the class name. The constructor must not have an explicit return type.

Can we declare a constructor as final?

The constructor can never be declared as final because it is never inherited. Constructors are not ordinary methods; therefore, there is no sense to declare constructors as final. However, if you try to do so, The compiler will throw an error.

What is the difference between the final method and abstract method?

The main difference between the final method and abstract method is that the abstract method cannot be final as we need to override them in the subclass to give its definition.

Which class is the superclass for all the classes?

The object class is the superclass of all other classes in Java. Because all objects in Java are inherited from Object class

What are the restrictions that are applied to the Java static methods?

The static method can not use non-static data member or call the non-static method directly. this and super cannot be used in static context as they are non-static.

What is the difference between a heap and a stack?

Heap memory is used to allocate memory at runtime such as for the creation of an object Stack memory is used for static memory allocation such as local variables. It contains primitive values that are specific to a method and references to objects that are in a heap, referred from the method.

What are the differences between this and super keyword?

The super keyword always points to the parent class contexts whereas this keyword always points to the current class context. The super keyword is primarily used for initializing the base class variables within the derived class constructor whereas this keyword primarily used to differentiate between local and instance variables when passed in the class constructor.

What is this keyword in java?

The this keyword is a reference variable that refers to the current object

What is the output of the following Java program? class Test { int test_a, test_b; Test(int a, int b) { test_a = a; test_b = b; } public static void main (String args[]) { Test test = new Test(); System.out.println(test.test_a+" "+test.test_b); } }

There is a compiler error in the program because there is a call to the default constructor in the main method which is not present in the class. However, there is only one parameterized constructor in the class Test. Therefore, no default constructor is invoked by the constructor implicitly.

What is a final method?

if we change any method to a final method, we can't override it. Example: class Bike{ final void run(){System.out.println("running");} } class Honda extends Bike{ void run(){System.out.println("running safely with 100kmph");} public static void main(String args[]){ Honda honda= new Honda(); honda.run(); } } Output:Compile Time Error

What is an interface?

interface is a class with all methods declared abstract and no fields A class can implement one or more interfaces

What is type promotion?

one data type can be promoted to another implicitly if no exact matching is found the byte can be promoted to short, int, long, float or double. The short datatype can be promoted to int, long, float or double. The char datatype can be promoted to int, long, float or double and so on Example: class OverloadingCalculation1{ void sum(int a,long b){System.out.println(a+b);} void sum(int a,int b,int c){System.out.println(a+b+c);} public static void main(String args[]){ OverloadingCalculation1 obj=new OverloadingCalculation1(); obj.sum(20,20);//now second int literal will be promoted to long obj.sum(20,20,20); } }

What are the main uses of the super keyword?

super can be used to refer to the immediate parent class instance variable. super can be used to invoke the immediate parent class method. super() can be used to invoke immediate parent class constructor.

What are the advantages of passing 'this' into a method instead of the current class object itself?

this is a final variable. Therefore, this cannot be assigned to any new value whereas the current class object might not be final and can be changed

What is null in Java?

used to indicate that the variable does not refer to any object

What is a race condition?

when more than one thread tries to access a shared resource (modify, write) at the same time

Does constructor return any value?

yes, The constructor implicitly returns the current instance of the class (You can't use an explicit return type with the constructor).

What does the following class output? class Student3{ int id; String name; void display(){System.out.println(id+" "+name);} public static void main(String args[]){ Student3 s1=new Student3(); Student3 s2=new Student3(); s1.display(); s2.display(); } }

0 null 0 null In the above class, you are not creating any constructor, so compiler provides you a default constructor. Here 0 and null values are provided by default constructor.

Difference between method Overloading and Overriding?

1) Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its superclass. 2) Method overloading occurs within the class. Method overriding occurs in two classes that have IS-A relationship between them. 3) In Method overloading the parameters must be different. In Method overriding the parameters must be the same.

What is the output of the following Java program? System.out.println(10 * 20 + "Javatpoint"); System.out.println("Javatpoint" + 10 * 20);

200Javatpoint Javatpoint200 In the first case, The numbers 10 and 20 will be multiplied first and then the result 200 is treated as the string and concatenated with the string Javatpoint to produce the output 200Javatpoint. In the second case, The numbers 10 and 20 will be multiplied first to be 200 because the precedence of the multiplication is higher than addition. The result 200 will be treated as the string and concatenated with the string Javatpointto produce the output as Javatpoint200

What is the output of the following Java program? System.out.println(10 + 20 + "Javatpoint"); System.out.println("Javatpoint" + 10 + 20);

30Javatpoint Javatpoint1020 In the first case, 10 and 20 are treated as numbers and added to be 30. Now, their sum 30 is treated as the string and concatenated with the string Javatpoint. Therefore, the output will be 30Javatpoint. In the second case, the string Javatpoint is concatenated with 10 to be the string Javatpoint10 which will then be concatenated with 20 to be Javatpoint1020.

What is a static block?

A static block in Java is a block of code that is executed at the time of loading a class for use in a Java application. It starts with a 'static {' and it is used for initializing static Class members in general — and is also known as a 'Static Initializer'. The most powerful use of a static block can be realized while performing operations that are required to be executed only once for a Class in an application lifecycle. // filename: Main.java class Test { static int i; int j; // start of static block static { i = 10; System.out.println("static block called "); } // end of static block } class Main { public static void main(String args[]) { // Although we don't have an object of Test, static block is // called because i is being accessed in following statement. System.out.println(Test.i); } }

what is a static method?

A static method belongs to the class rather than the object. There is no need to create the object to call the static methods. A static method can access and change the value of the static variable.

What is the difference between aggregation and composition?

Aggregation implies a relationship where the child can exist independently of the parent. ... Example: A motorcycle class can have an engine. An engine can exist without a motorcycle Composition implies a relationship where the child cannot exist independent of the parent. Example: A class contains students. A student cannot exist without a class. There exists composition between class and students.

What will be the initial value of an object reference which is defined as an instance variable?

All object references are initialized to null in Java

Can we make the abstract methods static in Java?

An abstract method is defined only so that it can be overridden in a subclass. Static methods can not be overridden so there would be a compile time error

What is the output of the following program? public class Animal { void consume(int a) { System.out.println(a+" consumed!!"); } static void consume(int a) { System.out.println("consumed static "+a); } public static void main (String args[]) { Animal a = new Animal(); a.consume(10); Animal.consume(20); } }

Animal.java:7: error: method consume(int) is already defined in class Animal static void consume(int a) ^ Animal.java:15: error: non-static method consume(int) cannot be referenced from a static context Animal.consume(20);

What is the output of the following Java program? class Base { void method(int a) { System.out.println("Base class method called with integer a = "+a); } void method(double d) { System.out.println("Base class method called with double d ="+d); } } class Derived extends Base { @Override void method(double d) { System.out.println("Derived class method called with double d ="+d); } } public class Main { public static void main(String[] args) { new Derived().method(10); } }

Base class method called with integer a = 10 The method() is overloaded in class Base whereas it is derived in class Derived with the double type as the parameter. In the method call, the integer is passed.

Why is the main method static?

Because the object is not required to call the static method. If we make the main method non-static, JVM will have to create its object first and then call main() method which will lead to the extra memory allocation

What is CLASSPATH and ClassLoader

ClassLoader is the part of JVM responsible for loading classes CLASSPATH is the list of places where classes can be found ClassLoader uses CLASSPATH to find classes

What is a constructor?

Constructor is a special method that first creates (implicit) then initializes and returns (also implicit) a new object. Constructor's name == class name. 'new' keyword is used to invoke a constructor

How many types of constructors are used in Java?

Default Constructor: default constructor is the one which does not accept any value. The default constructor is mainly used to initialize the instance variable with the default values. It can also be used for performing some useful task on object creation. A default constructor is invoked implicitly by the compiler if there is no constructor defined in the class. Parameterized Constructor: The parameterized constructor is the one which can initialize the instance variables with the given values. In other words, we can say that the constructors which can accept the arguments are called parameterized constructors.

What is the output of the following Java program? class Base { public void baseMethod() { System.out.println("BaseMethod called ..."); } } class Derived extends Base { public void baseMethod() { System.out.println("Derived method called ..."); } } public class Test { public static void main (String args[]) { Base b = new Derived(); b.baseMethod(); } }

Derived method called ...

What is the output of the following Java program? class Base { protected final void getInfo() { System.out.println("method of Base class"); } } public class Derived extends Base { protected final void getInfo() { System.out.println("method of Derived class"); } public static void main(String[] args) { Base obj = new Base(); obj.getInfo(); } }

Derived.java:11: error: getInfo() in Derived cannot override getInfo() in Base protected final void getInfo() ^ overridden method is final 1 error Explanation The getDetails() method is final; therefore it can not be overridden in the subclass.

With is access to objects with multiple threads handled?

Each Java object has a lock (mutex) and a monitor (cond.variable) Object's lock can be free or owned by at most one thread a)Any thread can acquire a free lock (synchronized keyword) b)If a thread tries to acquire a lock owned by another thread it's blocked until the lock becomes available c)If a lock becomes free and there are many threads waiting for it, then only one thread will become the owner, choice is random

what does invoked implicitly and invoked explicitly mean?

Explicit means done by the programmer. Implicit means done by the JVM or the tool , not the Programmer

What is method overriding?

If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding. It is used for runtime polymorphism and to implement the interface methods. Rules for Method overriding The method must have the same name as in the parent class. The method must have the same signature as in the parent class. (a method signature is the method name and the number, type and order of its parameters) Two classes must have an IS-A relationship between them.

What is a final class?

If we make any class final, we can't inherit it into any of the subclasses. final class Bike{} class Honda1 extends Bike{ void run(){System.out.println("running safely with 100kmph");} public static void main(String args[]){ Honda1 honda= new Honda1(); honda.run(); } } Output:Compile Time Error

What are the different types in Java?

In Java there is TWO kind of types: • Objects - or references to objects, including arrays, "zero " value is called null • Primitive types: int 32 bit, from -2147483648 to 2147483647 boolean true or false char 16 bit, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535 double 64 bit float 32 bit byte 8 bit, from -128 to 127 short 16 bit, from -32768 to 32767 long 64 bit, from -9223372036854775808 to 9223372036854775807

Why is method overloading not possible by changing just the return type in java?

In Java, method overloading is not possible by changing the return type of the program due to avoid the ambiguity class Adder{ static int add(int a,int b){return a+b;} static double add(int a,int b){return a+b;} } class TestOverloading3{ public static void main(String[] args){ System.out.println(Adder.add(11,11));//ambiguity }} Compile Time Error: method add(int, int) is already defined in class Adder

What is inheritance?

Inheritance is a mechanism by which one object acquires all the properties and behavior of another object of another class. It is used for Code Reusability and Method Overriding. The idea behind inheritance in Java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class

What does the following program output? class JBT { JBT() { this("JBT"); System.out.println("Inside Constructor without parameter"); } JBT(String str) { System.out .println("Inside Constructor with String parameter as " + str); } public static void main(String[] args) { JBT obj = new JBT(); } }

Inside Constructor with String parameter as JBT Inside Constructor without parameter

What is object-oriented paradigm?

It is a programming concept based on objects having data and methods defined in the class to which it belongs

What is aggregation?

It is a relationship between two classes with a one way association. For example you could have a class for an Address and a class for a Person. The person class can contain an Address since every person has an Address. But an Address does not need to contain a person public class Address { String city,state,country; public Address(String city, String state, String country) { this.city = city; this.state = state; this.country = country; } } public class Emp { int id; String name; Address address; public Emp(int id, String name,Address address) { this.id = id; this.name = name; this.address=address; } void display(){ System.out.println(id+" "+name); System.out.println(address.city+" "+address.state+" "+address.country); } public static void main(String[] args) { Address address1=new Address("gzb","UP","india"); Address address2=new Address("gno","UP","india"); Emp e=new Emp(111,"varun",address1); Emp e2=new Emp(112,"arun",address2); e.display(); e2.display(); } }

What is composition?

Its when you have a reference of a class inside another class that can't exist without it. Example: A class contains students. A student cannot exist without a class. There exists composition between class and students.

What is the difference between JDK, JRE, and JVM?

JVM is an acronym for Java Virtual Machine; it is an abstract machine which provides the runtime environment in which Java bytecode can be executed JRE stands for Java Runtime Environment. It is the implementation of JVM. It is used to provide the runtime environment. JDK is an acronym for Java Development Kit. It is a software development environment which is used to develop Java applications. It contains JRE + development tools.

Why does Java not support pointers?

Java doesn't user pointers for security reasons because pointers refer to an address in memory which can be accessed and modified outside of the application

How is Java compiled and executed?

Java is an interpreted language that is executed from bytecode. Bytecode is the machine code for JVM. To be executed (interpreted) Java class have to be compiled first • Compiled class is made of bytecode, stored in file with .class extension A compiled class can be loaded and executed by JVM

What are some key features of Java?

Java uses compiler and interpreter both. Java source code is converted into bytecode at compilation time. The interpreter executes this bytecode at runtime and produces output. Java is interpreted that is why it is platform independent Java is a strongly typed programming language because every variable must be declared with a data type

What is JIT compiler?

Just-In-Time compiler. It is used to improve the performance of a JVM

What is multi threading in Java?

Multithreading is a Java feature that allows concurrent execution of two or more parts of a program for maximum utilization of CPU Example: // the Thread class class MultithreadingDemo extends Thread { public void run() { try { // Displaying the thread that is running System.out.println ("Thread " + Thread.currentThread().getId() + " is running"); } catch (Exception e) { // Throwing an exception System.out.println ("Exception is caught"); } } } // Main Class public class Multithread { public static void main(String[] args) { int n = 8; // Number of threads for (int i=0; i<8; i++) { MultithreadingDemo object = new MultithreadingDemo(); object.start(); } } } Output : Thread 8 is running Thread 9 is running Thread 10 is running Thread 11 is running Thread 12 is running Thread 13 is running Thread 14 is running Thread 15 is running

Is constructor inherited?

No, The constructor is not inherited.

Can you use this() and super() both in a constructor?

No, because this() and super() must be the first statement in the class constructor. Example: public class Test{ Test() { super(); this(); System.out.println("Test class object is created"); } public static void main(String []args){ Test t = new Test(); } } Output: Test.java:5: error: call to this must be first statement in constructor

Can you make a constructor final?

No, the constructor can't be final.

Can we override the static methods?

No, we can't override static methods because it isn't associated with an instance of a class

Can we declare an interface as final?

No, we cannot declare an interface as final because the interface must be implemented by some class to provide its definition. Therefore, there is no sense to make an interface final. However, if you try to do so, the compiler will show an error.

Can we override private methods?

No, we cannot override the private methods because the scope of private methods is limited to the class and we cannot access them outside of the class

Can we override a static method?

No, you can't override the static method because they are the part of the class, not the object

What is a NullPointerException?

NullPointerException is thrown when an application attempts to use an object reference that has the null value Object obj = null; obj.toString(); // This statement will throw a NullPointerException

What is the difference between an object-oriented programming language and object-based programming language?

Object-oriented languages follow all the concepts of OOPs whereas, the object-based language doesn't follow all the concepts of OOPs like inheritance and polymorphism. Object-oriented languages do not have the inbuilt objects whereas Object-based languages have the inbuilt objects, for example, JavaScript has window object. Examples of object-oriented programming are Java whereas the examples of object-based languages are JavaScript

Can you clone an object in Java?

Only if you implement the Cloneable interface. A class implements the Cloneable interface to indicate to the Object.clone() method that it is legal for that method to make a field-for-field copy of instances of that class. Example: public class DogName implements Cloneable { private String dname; public DogName(String dname) { this.dname = dname; } public String getName() { return dname; } // Overriding clone() method of Object class public Object clone()throws CloneNotSupportedException{ return (DogName)super.clone(); } public static void main(String[] args) { DogName obj1 = new DogName("Tommy"); try { DogName obj2 = (DogName) obj1.clone(); System.out.println(obj2.getName()); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } }

What is the output of the following Java program? class Main { public static void main(String args[]){ final int i; i = 20; System.out.println(i); } }

Output: 20 Explanation Since i is the blank final variable. It can be initialized only once. We have initialized it to 20. Therefore, 20 will be printed.

What is the output of the following class? class Bike9{ final int speedlimit=90;//final variable void run(){ speedlimit=400; } public static void main(String args[]){ Bike9 obj=new Bike9(); obj.run(); } }//end of class

Output:Compile Time Error In Java, the final variable is used to restrict the user from updating it. If we initialize the final variable, we can't change its value. In other words, we can say that the final variable once assigned to a value, can never be changed after that. The final variable which is not assigned to any value can only be assigned through the class constructor.

What is the output of the following Java program? class OverloadingCalculation3{ void sum(int a,long b){System.out.println("a method invoked");} void sum(long a,int b){System.out.println("b method invoked");} public static void main(String args[]){ OverloadingCalculation3 obj=new OverloadingCalculation3(); obj.sum(20,20);//now ambiguity } }

OverloadingCalculation3.java:7: error: reference to sum is ambiguous obj.sum(20,20);//now ambiguity ^ both method sum(int,long) in OverloadingCalculation3 and method sum(long,int) in OverloadingCalculation3 match There are two methods defined with the same name, i.e., sum. The first method accepts the integer and long type whereas the second method accepts long and the integer type. The parameter passed that are a = 20, b = 20. We can not tell that which method will be called as there is no clear differentiation mentioned between integer literal and long literal. This is the case of ambiguity. Therefore, the compiler will throw an error.

What are the advantages of Packages in Java?

Package namespaces avoid naming conflicts It is good practice to bundle related classes into modules. It makes software systems easier to maintain Lets you abstract away how it is implemented

What is the output of the following Java program? class Person { public Person() { System.out.println("Person class constructor called"); } } public class Employee extends Person { public Employee() { System.out.println("Employee class constructor called"); } public static void main (String args[]) { Employee e = new Employee(); } }

Person class constructor called Employee class constructor called The super() is implicitly invoked by the compiler if no super() or this() is included explicitly within the derived class constructor. Therefore, in this case, The Person class constructor is called first and then the Employee class constructor is called.

What if the static modifier is removed from the signature of the main method?

Program compiles. However, at runtime, It throws an error "NoSuchMethodError."

What is the protected access specifier?

Protected can be accessed by the class of the same package, or by the sub-class of this class, or within the same class

What are the various access specifiers in Java?

Public The classes, methods, or variables which are defined as public, can be accessed by any class or method. Protected Protected can be accessed by the class of the same package, or by the sub-class of this class, or within the same class. Default Default are accessible within the package only. By default, all the classes, methods, and variables are of default scope. Private The private class, methods, or variables defined as private can be accessed within the class only.

What are static methods and variables?

They are part of the class and not the object For example, In the class simulating the collection of the students in a college, the name of the college is the common attribute to all the students. Therefore, the college name will be defined as static.

Why is multiple inheritance not supported in java?

To reduce the complexity and simplify the language, multiple inheritance is not supported in java. Consider a scenario where A, B, and C are three classes. The C class inherits A and B classes. If A and B classes have the same method and you call it from child class object, there will be ambiguity to call the method of A or B class. Since the compile-time errors are better than runtime errors, Java renders compile-time error if you inherit 2 classes. So whether you have the same method or different, there will be a compile time error. class A{ void msg(){System.out.println("Hello");} } class B{ void msg(){System.out.println("Welcome");} } class C extends A,B{//suppose if it were Public Static void main(String args[]){ C obj=new C(); obj.msg();//Now which msg() method would be invoked? } }

How are objects destroyed or deleted from memory in Java?

When there is no more reference to an object it is automatically destroyed with garbage collection

Can we execute a program without main() method?

Yes, one of the ways to execute the program without the main method is using static block

Can we overload the constructors?

Yes, the constructors can be overloaded by changing the number of arguments accepted by the constructor or by changing the data type of the parameters. Consider the following example.

Can we change the scope of the overridden method in the subclass?

Yes, we can change the scope of the overridden method in the subclass. However, we must notice that we cannot decrease the accessibility of the method. The following point must be taken care of while changing the accessibility of the method. The private can be changed to protected, public, or default. The protected can be changed to public or default. The default can be changed to public. The public will always remain public.

An abstract method is defined only so that it can be overridden in a subclass. However, static methods can not be overridden

Yes, we can declare static variables and methods in an abstract method. As we know that there is no requirement to make the object to access the static context, therefore, we can access the static context declared inside the abstract class by using the name of the abstract class. Consider the following example. abstract class Test { static int i = 102; static void TestMethod() { System.out.println("hi !! I am good !!"); } } public class TestClass extends Test { public static void main (String args[]) { Test.TestMethod(); System.out.println("i = "+Test.i); } } output hi !! I am good !! i = 102

Can we overload the main() method?

Yes, we can have any number of main methods in a Java program by using method overloading

What is the output of the following Java program? public class Test { Test(int a, int b) { System.out.println("a = "+a+" b = "+b); } Test(int a, float b) { System.out.println("a = "+a+" b = "+b); } public static void main (String args[]) { byte a = 10; byte b = 15; Test test = new Test(a,b); } }

a = 10 b = 15 Here, the data type of the variables a and b, i.e., byte gets promoted to int, and the first parameterized constructor with the two integer parameters is called.

What is a method signature?

a method signature is the method name and the number, type and order of its parameters

What is true about abstract methods

abstract method is a method with no body. public abstract void goSlowly( ); //no body!!! Abstract methods can not be invoked! car.goSlowly(); //compile-time error! Class containing abstract methods must be declared abstract: public abstract class Car{ //italics for abstracts, like in UML public abstract void goSlowly( ); //no body!! } Abstract classes can not be instantiated: new Car(); //compile-time error! Class without abstract methods can also be declared abstract Abstract classes can have all kinds of members (fields, etc.) Constructors and fields cannot be declared abstract

What is the output of the following program? Explain what is happening class Animal{ Animal(){System.out.println("animal is created");} } class Dog extends Animal{ Dog(){ System.out.println("dog is created"); } } class TestSuper4{ public static void main(String args[]){ Dog d=new Dog(); } }

animal is created dog is created The super keyword in Java is a reference variable that is used to refer to the immediate parent class object. Whenever you create the instance of the subclass, an instance of the parent class is created implicitly which is referred by super reference variable. The super() is called in the class constructor implicitly by the compiler if there is no super or this.


Related study sets

Chapter 8 Chemical Equations and Reactions

View Set

Principles on Investigation Revel Chapter 1, 2, 3, 4, 5, 19, 6, 7, 8, 9

View Set

Chapter 6 Values, Ethics, and Advocacy

View Set

PEDS Chapter 38 (hospitalized child)

View Set

question 3 exam Functional Dependencies

View Set