After Mid Slide Set 1
After Mid Slide Set 1
After Mid Slide Set 1
(OOP)
15 TL-Sec I & II
Engr. Maria Shaikh
[email protected]
Method Overriding
If subclass (child class) has the same method as declared in the parent class,
it is known as method overriding in java.
In other words, If subclass provides the specific implementation of the
method that has been provided by one of its parent class, it is known as
method overriding.
When overriding a method, you might want to use the @Override annotation
that instructs the compiler that you intend to override a method in the
superclass .
Operators
Operators are special symbols that perform specific operations on
one, two, or three operands, and then return a result.
Description
Subtraction operator
Multiplication operator
Division operator
Remainder operator
// result is now 3
// result is now 2
// result is now 4
// result is now 2
Output
Output
Description
++
--
// result is now 1
// result is now 0
// result is now 1
// result is now -1
// false
// true
Output
Implementation of Prefix
public class PreDemo {
public static void main(String[] args) {
int a = 5;
int b = 3;
int d = a * ++b;
System.out.println(d);
}
}
// d is set to 20
Implementation of Postfix
public class PostDemo {
public static void main(String[] args) {
int a = 5;
int b = 3;
int c = a * b++;
// c is set to 15
System.out.println(c);
}
)
Output
equal to
not equal to
greater than
greater than or equal to
less than
less than or equal to
Engr. Maria Shaikh
Output
Output
END OF SLIDES