Java
Java
Non-primitive types
(also known as
reference types) are
derived from classes
and are not predefined
by the language itself..
What is a ClassLoader?
JDK VERSIONS
JDK 1.0 (January 23, 1996) (The initial
release of JDK)
Versions
Private: Accessible only within the same class. It is not visible to any
other class, even if they are in the same package.
Protected: Access specifier allows access to members within the same package and by
subclasses, whether they are in the same package or a different package. However, non-
subclasses in different packages cannot access protected members to maintain
encapsulation and prevent unintended dependencies between unrelated classes.
Interface - Interfaces define a contract for classes to implement. They can contain
method signatures (without method bodies), default methods, static methods,
constants (public static final fields), and nested types (interfaces or classes).
Nested Classes- Nested classes are classes defined within another class. They
can be static or non-static (inner classes)
Final Classes - Final classes cannot be subclassed (extended). They are typically
used when inheritance is not intended.
Utility Classes - Utility classes are typically final with private constructors and
contain static methods that provide commonly used functions or constants.
LOOPS :QUICK NOTES
● for Loop: Use when the number of iterations is known.
● while Loop: Use when the condition depends on a
state that may change during execution.
● do-while Loop: Use when you need to execute the
block of code at least once, regardless of the condition.
● foreach Loop: Use for iterating over collections and
arrays without worrying about indices.Simplifies
iterating over collections and arrays.
What is an Association?
2.Anagrams Check: Write a function to check if two strings are anagrams of each other. Anagrams are strings
that contain the same characters with the same frequencies.
3.String Permutations: Implement a method to print all permutations of a given string. Assume all characters in
the string are unique.
Valid Parentheses
Given a string s containing just the characters '(', ')', '{', '}', '[', ']', determine if the input string is valid.
An input string is valid if:
1.Open brackets must be closed by the same type of brackets.
2.Open brackets must be closed in the correct order.
Write a Java program that checks if a given range of numbers (say between 1 and 1000) are prime using
multiple threads. Each thread should handle a subset of the numbers and report which numbers within its
subset are prime. Finally, collect and print all prime numbers found.