0% found this document useful (0 votes)
78 views1 page

Automatically Inserts A Call To The No-Argument Constructor of The Superclass

This document contains information about Java programming concepts: 1) It explains how to print statements and return values from methods using if/else statements. 2) It discusses object-oriented programming concepts like subclasses, superclasses, and overriding methods. 3) It provides details about method modifiers, return types, parameters, and implementing interfaces in Java classes.

Uploaded by

thisnotforforum
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views1 page

Automatically Inserts A Call To The No-Argument Constructor of The Superclass

This document contains information about Java programming concepts: 1) It explains how to print statements and return values from methods using if/else statements. 2) It discusses object-oriented programming concepts like subclasses, superclasses, and overriding methods. 3) It provides details about method modifiers, return types, parameters, and implementing interfaces in Java classes.

Uploaded by

thisnotforforum
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

System.out.println(foundIt ?

"Found it" : "Didn't find it"); //if foundIt = true then print Found it else Didnt find it Return - to end a method or return a value in a function Subclasses inherit all the fields and methods of its superclass Super.* to refer to superclass Use final to indicate that a method cannot be overwritten
Note: If a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass.

Methods Modifier Return type Method name Parameters Method body Many methods use void to signify that no value is returned Public int getVolume() { //body here } Constants are declared with final and should be used with static Interfaces - Implements after extends - An interface defines a protocol of communication between two objects. - An interface declaration contains signatures, but no implementations, for a set of methods, and might also contain constant definitions. - A class that implements an interface must implement all the methods declared in the interface. - An interface name can be used anywhere a type can be used. Casting Object obj = new MountainBike(); then obj is both an Object and a Mountainbike (until such time as obj is assigned another object that is not a Mountainbike). This is called implicit casting. If, on the other hand, we write MountainBike myBike = obj; we would get a compile-time error because obj is not known to the compiler to be a MountainBike. However, we can tell the compiler that we promise to assign a MountainBike to obj by explicit casting: MountainBike myBike = (MountainBike)obj;
if (obj instanceof MountainBike) { MountainBike myBike = (MountainBike)obj; }

To check if obj is an MountainBike

You might also like