Computer Applications cheat sheet

8 chapters. In each, the formulas come first, then the key facts.

8 chapters · 129 key facts

  1. 1Start hereRevision of Class IX ConceptsObject-Oriented Programming and Java Basics · 20 key factsRead
  2. 2Conditionals and LoopsObject-Oriented Programming and Java Basics · 20 key factsRead
  3. 3Class as the Basis of All Computation and EncapsulationClasses and Methods · 12 key factsRead
  4. 4User-Defined MethodsClasses and Methods · 16 key factsRead
  5. 5ConstructorsClasses and Methods · 15 key factsRead
  6. 6Library Classes and Wrapper ClassesLibrary Classes and Data Structures · 13 key factsRead
  7. 7ArraysLibrary Classes and Data Structures · 16 key factsRead
  8. 8String HandlingLibrary Classes and Data Structures · 17 key factsRead
Object-Oriented Programming and Java Basics · Chapter 1

Revision of Class IX Concepts

4 topics · 20 facts

  1. 1Principles of Object-Oriented Programming: abstraction, encapsulation, inheritance, polymorphism
  2. 2Tokens, identifiers, literals, keywords, primitive and non-primitive data types
  3. 3Operators, operator precedence, expressions, and type conversion
  4. 4Mathematical library methods: Math class functions
Key facts
  1. Abstraction in object-oriented programming hides complex implementation details and exposes only the essential features to the user.

  2. Encapsulation binds data and methods together into a single unit (class) and protects data using access specifiers.

  3. Inheritance allows a new class to acquire properties and behaviors of an existing class, promoting code reusability.

  4. Polymorphism enables an object or method to behave in multiple forms during compile-time or run-time execution.

  5. Tokens are the smallest individual units in a Java program, comprising keywords, identifiers, literals, punctuators, and operators.

  6. Keywords are reserved words with predefined meanings in Java and cannot be used as user-defined identifiers.

  7. Identifiers are programmer-defined names given to variables, methods, and classes, starting with a letter, underscore, or dollar sign.

  8. Primitive data types in Java include boolean, byte, short, int, long, float, double, and char, storing raw values directly.

  9. Non-primitive data types include classes, interfaces, and arrays, which store references to objects in memory.

  10. Arithmetic operators perform mathematical calculations, while relational operators compare values and return boolean outcomes.

  11. Logical operators (&&, ||, !) evaluate conditions to combine multiple boolean expressions according to truth tables.

  12. The ternary operator (? :) evaluates a boolean condition and selects one of two expressions based on the result.

  13. Operator precedence determines the order of evaluation in an expression, executed from highest precedence to lowest.

  14. Implicit type conversion (widening) occurs automatically when a smaller data type is assigned to a larger data type.

  15. Explicit type conversion (narrowing or casting) requires a cast operator to convert a larger data type into a smaller one.

  16. Mathematical library methods belong to the java.lang.Math class and are invoked statically without creating objects.

  17. Math.max(a, b) and Math.min(a, b) return the greater and smaller of two numeric arguments respectively.

  18. Math.pow(a, b) computes the exponential value returning a double representing base 'a' raised to the power 'b'.

  19. Math.sqrt(a) returns the positive square root of a given double value as a double result.

  20. Math.random() generates a pseudo-random double value greater than or equal to 0.0 and strictly less than 1.0.

Object-Oriented Programming and Java Basics · Chapter 2

Conditionals and Loops

3 topics · 20 facts

  1. 1Conditional statements: if, if-else, nested if, and switch-case
  2. 2Iteration statements: for, while, and do-while loops
  3. 3Jump statements: break and continue, and nested loop execution
Key facts
  1. The if statement executes a single statement or a block of code conditionally only when the Boolean expression evaluates to true.

  2. An if-else statement provides two alternative paths of execution, ensuring that either the if block or the else block runs.

  3. Nested if statements involve placing an if or if-else construct inside another if or else block for hierarchical decision making.

  4. The switch statement selects among multiple execution paths based on the matching value of an integer, character, byte, short, or string expression.

  5. In a switch statement, each case label must be a constant expression matching the switch expression type, and duplicate case values are prohibited.

  6. Fall-through behavior occurs in a switch statement when a break statement is omitted, causing execution to flow sequentially into subsequent cases.

  7. The default label in a switch statement executes when none of the preceding case labels match the switch expression value.

  8. The conditional operator (? :) acts as a ternary shorthand for simple if-else statements, evaluating a boolean condition to return one of two values.

  9. Entry-controlled loops such as for and while evaluate their loop continuation condition before executing the loop body.

  10. Exit-controlled loops such as do-while evaluate their loop condition after executing the body, guaranteeing at least one execution.

  11. A for loop header combines initialization, test condition, and update expressions into a compact single structure for counted iterations.

  12. A while loop checks its boolean condition before every iteration and repeats execution as long as the condition remains true.

  13. If the loop control variable is not updated correctly inside a while or for loop, it results in an infinite loop.

  14. A do-while loop terminates when its trailing boolean condition evaluates to false after completing an iteration of the loop body.

  15. The break statement immediately terminates the innermost enclosing loop or switch block and transfers control to the statement following it.

  16. The continue statement skips the remaining statements in the current iteration of a loop and proceeds directly to the next iteration.

  17. Nested loop execution involves placing one or more loops inside the body of an outer loop, multiplying the total iterations.

  18. In nested loops, for every single iteration of the outer loop, the inner loop executes completely through all its iterations.

  19. Using a labeled break or continue statement in Java allows transferring control out of or skipping iterations in outer nested loops.

  20. Unlike if-else-if ladders, switch expressions evaluate equality against discrete constants and do not support range or relational conditions directly.

Classes and Methods · Chapter 3

Class as the Basis of All Computation and Encapsulation

3 topics · 12 facts

  1. 1Class as an object factory, state, behavior, and object instantiation
  2. 2Access specifiers: public, private, protected, and default scope
  3. 3Scope and lifetime of variables: local, instance, and static variables
Key facts
  1. A class acts as an object factory that defines the attributes (state) and methods (behavior) common to all objects instantiated from it.

  2. An object is an instance of a class that represents a real-world or software entity possessing a distinct state and behavior.

  3. Object instantiation is the process of creating an instance of a class in memory using the new operator and a constructor.

  4. Public access specifier allows members of a class to be accessed from any other class across packages without restrictions.

  5. Private access specifier restricts the visibility of members strictly within the class in which they are declared.

  6. Protected access specifier allows members to be accessed within the same package and by subclasses derived across packages.

  7. Default package-private scope permits members to be accessed only within classes residing in the same package.

  8. Encapsulation is achieved by combining data and methods into a single unit and restricting direct access using access specifiers.

  9. Local variables are declared inside methods, constructors, or blocks, and their scope and lifetime are confined to that block.

  10. Instance variables are declared inside a class but outside methods, and each object maintains a separate copy of these variables.

  11. Static variables belong to the class rather than any single object, sharing a single copy across all instances of the class.

  12. The static keyword implies that variables and methods can be accessed without creating an instance of the class.

Classes and Methods · Chapter 4

User-Defined Methods

4 topics · 16 facts

  1. 1Method definition, signature, prototype, return types, and invocation
  2. 2Parameters and parameter passing: call by value and call by reference
  3. 3Pure (accessor) and impure (mutator) methods
  4. 4Method overloading: rules and compile-time polymorphism
Key facts
  1. A method definition begins with the method header specifying the access modifier, return type, method name, and parameter list followed by the method body enclosed in braces.

  2. A method signature consists of the method name and the parameter list, while the method prototype also includes the access specifier and return type.

  3. The return statement terminates the execution of a method and transfers control back to the calling method, optionally returning a value matching the specified return type.

  4. A method whose return type is declared as void does not return any value back to the calling environment.

  5. Method invocation or calling is performed by using the method name along with the required arguments matching the parameter types defined in the method signature.

  6. Formal parameters are variables declared in the method header to receive values, whereas actual parameters are the values or expressions passed during a method call.

  7. In call by value parameter passing mechanism, a copy of the actual parameter's value is passed to the formal parameter, so modifications made to the formal parameter do not affect the original actual parameter.

  8. In call by reference parameter passing mechanism, the memory reference or address of the object is passed, allowing the called method to modify the original object's state.

  9. Primitive data types in Java are always passed by value into methods.

  10. Reference types such as arrays and class objects passed as arguments behave according to reference semantics where object references are copied by value.

  11. A pure accessor method inspects the state of an object or computes a result without modifying any instance variables or observable object states.

  12. An impure mutator method alters the internal state of an object or produces side effects during its execution.

  13. Pure methods always return the exact same output when invoked with the same arguments under identical object states.

  14. Method overloading occurs when multiple methods share the same name within the same class but possess distinct parameter lists.

  15. Overloaded methods must differ in the number, data type, or sequence of their parameters, while differing solely in return type is invalid.

  16. Method overloading is an implementation of compile-time polymorphism or static binding, where the appropriate method version to execute is resolved by the compiler during compilation.

Classes and Methods · Chapter 5

Constructors

3 topics · 15 facts

  1. 1Definition, purpose, and key characteristics of constructors
  2. 2Types of constructors: default, non-parameterized, and parameterized constructors
  3. 3Constructor overloading and comparison between constructors and methods
Key facts
  1. A constructor is a special member function of a class that has the exact same name as the class and is used to initialize the state of an object during its creation.

  2. Constructors never have a return type, not even void, distinguishing them syntactically from ordinary member methods.

  3. A constructor is invoked automatically when an object is instantiated using the new operator, allocating memory and initializing its member variables.

  4. Constructors perform the vital role of setting up initial valid values for instance variables so that objects do not start in an uninitialized or indeterminate state.

  5. Every class must have at least one constructor; if none is explicitly declared, the compiler automatically supplies a default constructor.

  6. The default constructor is provided automatically by the Java compiler if no explicit constructor is defined within the class, initializing numeric fields to zero and object references to null.

  7. A non-parameterized constructor is explicitly written by the programmer with an empty parameter list to set initial default values for object attributes.

  8. A parameterized constructor accepts arguments during object creation, allowing different objects to be initialized with distinct custom values passed by the user.

  9. Parameterized constructors enable runtime flexibility by populating instance variables with varying initial states depending on the arguments supplied in the instantiation statement.

  10. When a parameterized constructor is defined explicitly without a non-parameterized constructor, the compiler does not provide the default zero-argument constructor automatically.

  11. Constructor overloading occurs when a class has multiple constructors with the same name but different parameter lists, differentiated by number, type, or order of parameters.

  12. Constructor overloading is a form of compile-time polymorphism that provides multiple ways to initialize objects based on the available initial data.

  13. Unlike methods, constructors cannot be inherited by subclasses, cannot be marked abstract, static, or final, and do not return any value whatsoever.

  14. Methods are invoked explicitly on existing objects using dot notation, whereas constructors are invoked implicitly only once during the object creation process with the new operator.

  15. Methods require a return type declaration in their header, whereas constructors have no return type declaration preceding their class-matching name.

Library Classes and Data Structures · Chapter 6

Library Classes and Wrapper Classes

3 topics · 13 facts

  1. 1Java packages and wrapper classes for primitive data types
  2. 2Autoboxing and unboxing mechanisms
  3. 3Methods of the Character wrapper class
Key facts
  1. Java class libraries and packages organize pre-written classes into namespaces, where packages like java.lang and java.util provide fundamental utilities and core programming support.

  2. Wrapper classes encapsulate primitive data types into objects, fulfilling the need and purpose of treating primitives as objects when required by certain data structures and APIs.

  3. The wrapper classes corresponding to the eight primitive data types in Java are Byte, Short, Integer, Long, Float, Double, Character, and Boolean.

  4. Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes.

  5. Unboxing is the automatic conversion made by the Java compiler from a wrapper class object back to its corresponding primitive data type.

  6. The Character wrapper class method isLetter(char c) checks if the specified character is a letter, returning a boolean true or false.

  7. The Character wrapper class method isDigit(char c) determines if the specified character is a digit, returning true if it is a digit and false otherwise.

  8. The Character wrapper class method isLetterOrDigit(char c) tests whether the specified character is either a letter or a digit.

  9. The Character wrapper class method isWhitespace(char c) checks if the specified character is white space according to Java.

  10. The Character wrapper class method isUpperCase(char c) verifies whether the specified character is an uppercase letter.

  11. The Character wrapper class method isLowerCase(char c) verifies whether the specified character is a lowercase letter.

  12. The Character wrapper class method toUpperCase(char c) returns the uppercase equivalent of the specified character argument.

  13. The Character wrapper class method toLowerCase(char c) returns the lowercase equivalent of the specified character argument.

Library Classes and Data Structures · Chapter 7

Arrays

4 topics · 16 facts

  1. 1Single dimensional arrays: declaration, creation, initialization, and length property
  2. 2Array traversal and element manipulation
  3. 3Searching algorithms: linear search and binary search
  4. 4Sorting algorithms: bubble sort and selection sort
Key facts
  1. A single dimensional array in Java is a reference data type used to store a fixed-size sequential collection of elements of the same data type.

  2. Declaration of a 1D array specifies its reference variable and data type without allocating memory, such as 'int arr[];' or 'int[] arr;'.

  3. Instantiation of a 1D array using the 'new' operator allocates memory dynamically in the heap, for example, 'arr = new int[10];'.

  4. Array initialization assigns initial values to array elements at the time of declaration or instantiation, such as 'int arr[] = {1, 2, 3};'.

  5. The built-in array length property, denoted by '.length', returns the total number of elements contained in the array.

  6. Array traversal involves visiting each element of the array sequentially, typically from index 0 to length - 1 using a 'for' or 'while' loop.

  7. Element manipulation in an array allows modifying or accessing specific elements using their valid integer indices, such as 'arr[i] = 5;'.

  8. Attempting to access an array index outside the range of 0 to length - 1 throws an ArrayIndexOutOfBoundsException at runtime.

  9. Searching techniques are used to locate the position of a specific target element within an array data structure.

  10. Linear search (sequential search) checks each element of the array one by one from the beginning until the target is found or the array ends.

  11. Linear search can be performed on both sorted and unsorted arrays with a time complexity proportional to the number of elements.

  12. Binary search is an efficient search algorithm that requires the array to be strictly sorted in ascending or descending order before execution.

  13. Binary search calculates the midpoint index as '(lb + ub) / 2' and repeatedly compares the target with the middle element to halve the search space.

  14. Sorting techniques arrange the elements of an array in a specified order, typically ascending or descending numerical or alphabetical order.

  15. Bubble sort algorithm sorts an array by repeatedly comparing adjacent elements and swapping them if they are in the wrong order.

  16. Selection sort algorithm sorts an array by repeatedly finding the minimum (or maximum) element from the unsorted part and placing it at the beginning.

Library Classes and Data Structures · Chapter 8

String Handling

4 topics · 17 facts

  1. 1String class concepts, object creation, and string immutability
  2. 2String manipulation methods: length, charAt, substring, trim, and case conversion
  3. 3String comparison and search methods: equals, compareTo, indexOf, startsWith, endsWith
  4. 4String processing techniques: character extraction, word extraction, and string reversal
Key facts
  1. In Java, the String class represents character strings, and all string literals in Java programs are implemented as instances of this class.

  2. Strings can be created using string literals or by using the new keyword to instantiate a new String object in memory.

  3. String objects in Java are immutable, meaning their contents cannot be modified once the string object has been created.

  4. The length() method of the String class returns the total number of characters contained in the string object.

  5. The charAt(int index) method returns the character located at the specified index position within the string.

  6. The substring() method extracts and returns a portion of the string starting from a specified index up to an optional end index.

  7. The trim() method removes all leading and trailing whitespace characters from the string object and returns the resulting string.

  8. The toLowerCase() and toUpperCase() methods convert all characters of the string into lowercase and uppercase respectively.

  9. The equals() method compares two strings for exact content equality and returns a boolean value true if they match.

  10. The compareTo() method performs a lexicographical comparison between two strings and returns an integer value representing their alphabetical relation.

  11. The indexOf() method searches for the first occurrence of a specified character or substring and returns its starting index position.

  12. The startsWith() method checks whether a string begins with a specified prefix substring and returns a boolean result.

  13. The endsWith() method verifies if the string terminates with a specified suffix substring and returns true or false accordingly.

  14. Character extraction techniques involve iterating through a string using loops and accessing individual characters via charAt().

  15. Word extraction algorithms parse sentences by locating whitespace delimiters to isolate and retrieve individual words from a string.

  16. String reversal algorithms construct a reversed string by traversing the original string from its last index down to zero.

  17. Additional string operations like concat() join two strings together, while replace() substitutes specified characters or substrings.