ISC Class 11 Computer Science Notes
ISC Class 11 Computer Science Notes
Type casting in Java is converting a variable from one data type to another. Implicit casting (widening conversion) occurs when a smaller type is automatically converted to a larger type, such as int to double, without data loss. Explicit casting (narrowing conversion) requires specific syntax and is used when a larger type is converted to a smaller one, like double to int, potentially losing information .
In Java, a while loop checks the condition before executing the loop body, meaning it may not execute if the condition is false initially. A do-while loop executes the loop body first before checking the condition, ensuring it runs at least once regardless of the condition. Thus, do-while is useful when the condition check must occur only after the loop's initial execution .
Recursion involves a function calling itself to solve smaller instances of a problem. It simplifies code for problems naturally fitting recursive solutions, like file directories. However, it can lead to performance issues due to excessive memory use from call stack growth. Proper base cases and tail recursion are essential to mitigate pitfalls, making recursion both powerful and potentially risky .
In Java, String objects are immutable, meaning any modification creates a new object. StringBuffer, however, is mutable, allowing direct modification without creating new objects. StringBuffer provides better performance in scenarios involving numerous modifications or concatenations, while Strings are simpler when immutability is desired to ensure consistent data state .
Method overloading occurs within a class by defining multiple methods with the same name but different parameters. Method overriding involves a subclass providing a specific implementation for a method declared in a superclass. Overloading requires unique signatures in the same scope; overriding involves a superclass-subclass relationship, allowing polymorphism .
The four pillars of OOP are Encapsulation, Abstraction, Inheritance, and Polymorphism. Encapsulation involves bundling data with methods that operate on the data. Abstraction reduces complexity by hiding unnecessary details. Inheritance allows new classes to inherit properties of existing ones. Polymorphism enables objects to be treated as instances of their parent class. These principles lead to code reusability, improved maintainability, and a modular structure, enhancing software development productivity .
Number systems are systems for representing numbers. The primary types include Binary, Octal, Decimal, and Hexadecimal. Conversion between number systems involves different methods based on their bases. For example, to convert a binary number to decimal, each bit is multiplied by 2 raised to the power of its position from right and summed. Conversely, to convert a decimal number to binary, divide the number by 2 and record the remainders, reading them in reverse order .
Java's platform independence allows developers to write code that runs on any device that has the Java Virtual Machine (JVM). This is achieved by compiling Java code into bytecode, which is interpreted by the JVM. This 'write once, run anywhere' capability reduces development and deployment costs, allowing applications to work seamlessly across different platforms .
Wrapper classes in Java allow primitive data types to be treated as objects through autoboxing (automatic conversion of primitives to corresponding objects) and unboxing (conversion of wrapper objects back to primitives). These facilitate collection framework operations where objects are required. Advantages include seamless integration and manipulation of primitive data types in object contexts, but they may involve performance overhead due to object creation .
To construct a truth table for (p ∧ q) → r, list all possible truth values of p, q, and r. Calculate (p ∧ q), followed by evaluating (p ∧ q) → r using the rule that a conditional statement is false only when the antecedent is true and the consequent is false. This table helps visualize logical consistency and equivalence in propositional logic .