0% found this document useful (0 votes)
3 views

Cheats Sheet All Topics

The document outlines key concepts of Object-Oriented Programming (OOP) including inheritance, encapsulation, polymorphism, and abstraction. It explains Java-specific features such as data types, control structures, and error types, while also detailing the use of functions, constructors, and access specifiers. Additionally, it covers the differences between class and instance variables, as well as the concept of wrapper classes and their parsing functions.

Uploaded by

nowduri.sk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Cheats Sheet All Topics

The document outlines key concepts of Object-Oriented Programming (OOP) including inheritance, encapsulation, polymorphism, and abstraction. It explains Java-specific features such as data types, control structures, and error types, while also detailing the use of functions, constructors, and access specifiers. Additionally, it covers the differences between class and instance variables, as well as the concept of wrapper classes and their parsing functions.

Uploaded by

nowduri.sk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

IMPORTANT POINTS

• Inheritance is OOP feature of one class inheriting the properites of another


class
• Encapsulation is OOP feature of putting together the data
member(variables) and member functions(functions/methods) into a
single unit called class
• Polymorphism is OOP feature where single action can be performed in
multiple ways
• Abstraction is OOP feature where only the necessary details are taken into
consideration and unnecessary ones are ignored.
• Function overloading is implementation of Polymorphism
• The default package is lang package
• The lang package consists of String class , Math class and all Wrapper
classes
• Object is also called INSTANCE of the class
• Class is CALLED BLUEPRINT OF THE CLASS
• Class is encapsulation of attributes and behavior.
• Combining attributes and behavior in one single unit called class is the
process of Encapsulation.
• Reusability of code implement INHERITANCE OOP FEATURE
• Function overloading implements the OOP feature of Polymorphism.
• The 4 OOP features are Abstraction , Encapsulation, Inheritance and
Polymorphism
• The process of wrapping the necessary/required attributes and its
behaviors is called Abstraction.
• A class is called Object Factory because once a class is defined multiple
objects can be defined.
• Dynamic binding is one of JAVA programming features NOT OOP FEATURE
• Java is also known as MULTITHREADED programming language ( Feature of
Java)
• Java literals are constant values like 10 , 4.51, “hello” , ‘X’ .
• SYMBOLIC CONSTANTS ARE VARIABLES DECLARED WITH final KEYWORD
• Example : final int a = 10; the value of this variable will remain fixed to
10 through out the program.
• Back slash literals OR Escape sequences are backslash symbol followed by
letter or letters to represent the output in a certain way
\n is for printing on new line
\t for printing tab space
\” is for printing opening double quotes
\’ for printing opening single quotes \a is for audible bell
• Square root of negative number is RUNTIME ERROR
• Unary operators ++ , -- , + , -
• Binary operators are mathematical operators, relational and logical
operators.
• 2 features of Java a) Java is platform independent
b) Java is case sensitive
c) It is an OOP language.

• System.out.println(“hello “ + 8 +9); prints hello89


• System.out.println(“hello” + (8+9); prints hello17 (if round bracket is kept
+ becomes an addition operator)
• System.out.print(6+4 + “hello”); prints 10hello (if the arithmetic operation
is before the printing statement, the + is treated as addition operator)
• Java uses both Interpreter and compiler
• Compiler in the first stage and produces Byte code which makes Java
platform independent
• Interpreter in the second stage and produces machine level code(0 and 1)
• Source code is the program we write.
• BYTE CODE IS SAVED WITH .CLASS EXTENSION

• 3 decision constructs if else , switch case and ternary operator


• If else test expression can use any kind of operators
• Switch case test variable can ONLY be any INTEGER datatype, String or
char datatype.
• Second difference is switch case works only for equality operation
• If else can be used for any kind of testing expression
• Ternary operator is represent by ?:
• FALL THROUGH IN SWITCH CASE IS A LOGICAL ERROR.
• FALL THROUGH OCCURS WHEN BREAK IS MISSING
• DANGLING IF ELSE OCCURS IF THERE ARE MORE NUMBER OF ifs THEN
MORE NUMBER OF elses. IT IS ALSO LOGICAL ERROR.

• 3 looping constructs for , while and do while


• for and while are called entry controlled loop
• do while is called exit controlled loop since the test expression is written
after the body of the loop
• for is used when number of iterations are known
• while and do while are used when number of iterations are unknown.

• break stops the iteration whereas continue skips the current iteration
• break , continue and return are called JUMP statements/keywords

• Parameters at the function/method line are called formal parameters


• Parameters in the function call statement are called actual parameters
• Number of Actual and formal paramters must be same.
• Only ONE value can be returned at a time.
• void means the function does not return any value.
• Function Signature = Function name + parameter list(number and
datatype of parameters)
• Function Prototype = Function Signature + return type
• Functions which DO NOT CHANGE THE STATE OF THE OBJECT IS CALLED
PURE FUNCTIONS
• Methods which CHANGE THE STATE OF THE OBJECT are called IMPURE
FUNCTIONS
• Methods can be called in two ways 1) call by value 2) Call by reference
• PRIMITIVE DATATYPE VALUES ARE PASSED IN CALL BY VALUE
• Call by value is when you send values to other functions
• Call by reference means when you send an object/ memory address
to other functions.
• Any number of user defined functions can be written in a program
• Many functions with same name is called function overloading.

• Class variables are global variables which are declared with static keyword
• Class variables are a common copy to all the objects.
• Instance variable are global variables where each object has its own copy.

• 3 access specifiers or modifiers or visibility modifiers


• Public allows accessibitity throughout.
• Protected allows accessibility within the same package.
• Private allows within the same class.
• Access specifiers support OOP feature of encapsulation

• Wrapper classes are defined in lang package


• They contain parse functions
• Wrapper class is used to convert a primitive type to an object and object back to
primitive type.
Wrapper class Parse functions
Byte parseByte( )
Short parseShort( )
Integer parseInt( )
Long parseLong( )
Float parseFloat( )
Double parseDouble( )
Boolean ----------------
Character ---------------------
String str = “321”;
int a = Integer.parseInt(str);
Sopln(a) ; // Prints the value of a which is in integer format.

• toString( ) belongs to wrapper classes


String str = Integer.toString(2022);
Sopln(str) ; // converts the numeric value 2022 to String value .
Sopln(str. charAt( 1 ) ) ;

• Boxing or Autoboxing is defined as – a process of converting a primitive


data type into an object of its corresponding wrapper class.
• Unboxing is defined as converting an object to its corresponding primitive
datatype

• UNBOXING is defined as an automatic conversion of an object of a wrapper


class to its corresponding primitive data type.
• Constructors are methods with same name as class names
• When user defined constructors are not written, then compiler provided
its own constructor function called DEFAULT CONSTRUCTOR
• Default constructors are non parameterized constructors
• The use of constructor functions are they are used to initialize global
variable.
• Constructors can also be overloaded.
• They are called at the time of OBJECT CREATION statement
• Constructor functions DO NOT HAVE RETURN TYPE not even void.
• Difference between constructors functions and user defined functions is
user define function have different names other than class names
User defined functions have return type , it no return type then void is
written.
• Class , arrays String are examples of USER defined datatypes
• There are 8 primitive datatypes
(byte,short,int,long,float,double,char,boolean)

• Binary search requires 2 constraints/requirements to be satisfied


1) elements should be in sorted order 2) lower and upper limit should be
know beforehand
• Difference between compareTo() and equals() is compareTo() returns
integer value as output. equals() returns boolean value as output.
• replace() and substring() are examples of overloaded functions.

• Array memory space can be calculated by number of element * datatype


of elements
• EXAMPLE : int a [] = new int[50] ; 50 * 4 bytes = 200 bytes will be
occupied
• The default value of boolean datatype is false.
• 3 types of errors syntax , logical and runtime errors.
• Infinite loops and square root of negative numbers are runtime errors
• 2 types of JAVA programs are 1)standalone applications 2) web based
applications
• Null loops are loops which DON’T HAVE ANY STATEMENTS IN THE BODY
OF LOOP.
• NULL LOOPS ARE CALLED TIME DELAY LOOPS.

• for ( ; ; ) IS VALID for loop.


• In for loop , MULTIPLE INITILIZATIONS AND UPDATE EXPRESSIONS ARE
POSSIBLE
• EXAMPLE : for ( int i = 1 , j = 2 ; i < = 10 ; i ++ , j = j+2)

IMPLICIT TYPE CONVERSION IS ALSO CALLED COERSION


EXPLICIT TYPE CONVERSION IS ALSO CALLED TYPE CASTING
Class variable are global variables declared with static keyword
• Scope of variables: The part of the program where the variable is available.
Argument variables : Variables that appear in the function call statement.
ACTUAL PARAMETERS ARE ARGUMENT VARIABLES.
• Instance variables / default variables : Variables that are non-static i.e
variables that are declared WITHOUT static keyword These values of these
variables ARE NOT SHARED BETWEEN THE OBJECTS. EACH OBJECT HAS THEIR
OWN COPY OF THE VARIABLE.
• These variables are bounded to the object.
• BOTH CLASS AND INSTANCE VARIABLES ARE DECLARED AS PART OF THE
CLASS I.E OUTSIDE THE FUNCTION/METHOD.

You might also like