0% found this document useful (0 votes)
5 views7 pages

Java Notes.

The document provides notes on various Java programming concepts including math, random number generation, user input, string methods, control structures like loops and switch cases, constructors, inheritance, method overriding, abstract classes, interfaces, and packages. It highlights key syntax and usage patterns such as the ternary operator, logical operators, and the use of 'this' and 'super'. Additionally, it explains how to implement multiple interfaces and the organization of classes within packages.

Uploaded by

Omkar Bichu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Java Notes.

The document provides notes on various Java programming concepts including math, random number generation, user input, string methods, control structures like loops and switch cases, constructors, inheritance, method overriding, abstract classes, interfaces, and packages. It highlights key syntax and usage patterns such as the ternary operator, logical operators, and the use of 'this' and 'super'. Additionally, it explains how to implement multiple interfaces and the organization of classes within packages.

Uploaded by

Omkar Bichu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Notes

Math

Random

User input / scanner


Printf alternative to println use \n f or new line

String Methods
**- in if condition you can directly put a boolean variable in it and the assumption will be
boolVar == true >>> if(boolVar) then... or for false you can use not operator with it

Use the [Link](““) method when comparing values f rom arrays especially
Substring

Ternary operator
Switch case

Logical operators

Loops
While
For

Arrays

Constructors
For constructors initialize with class name and no need to use anything else like def ining a method
Constructor overloading is basically having dif f erent constructors initialized with a dif f erent number of
parameters
Similar to method overloading
**
this. - it ref ers to the class you are in
super. - it ref ers to the parent class
—> calling super in the child class works like a parameter or if you want teh methods then you do
[Link]()

Static
When calling a static attribute within a class then dont use this. Operator just call the variable name

Inheritance
Use key word extends while making child class
Types
Generally : multilevel or heirarchal or hybrid of both

Method overriding : basically if a method is defined in a parent class it could be redefined for certain children in
their class as something dif f erent

Abstract Classes and methods


You cant call an abstract class standalone but you can use it as an extension to other objects with its properties
For abstract methods these methods need to be initialized when creating a new class extending the current
class
— public abstract class shape {} —> class
— abstract double area() ; —> method

Interf ace
Map/blueprint f or the class
What all do you need f or the class is going to be def ined there
Use keyword implements instead of extends
Implement multiple interf aces this is how multiple inheritance is done

Packages
Define

Use

Fo importing everything in a package you can use for eg: import Tools.*
You have to make all classes in one folder of name of package
Default is if in same folder then no need to use package name you can directly call

You might also like