0% found this document useful (0 votes)
43 views4 pages

Java Exam Prep Notes and MCQs

The document provides comprehensive Java syllabus notes covering key concepts such as Java's features, basics, operators, packages, math functions, control statements, methods, OOP concepts, and bubble sort. It includes example code snippets and practice multiple-choice questions for exam preparation. The notes serve as a guide for understanding Java programming fundamentals and its application.

Uploaded by

khushidhir54
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)
43 views4 pages

Java Exam Prep Notes and MCQs

The document provides comprehensive Java syllabus notes covering key concepts such as Java's features, basics, operators, packages, math functions, control statements, methods, OOP concepts, and bubble sort. It includes example code snippets and practice multiple-choice questions for exam preparation. The notes serve as a guide for understanding Java programming fundamentals and its application.

Uploaded by

khushidhir54
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 (Handwritten Style)

Complete Java Syllabus Notes for Exam Preparation


1. Introduction to Java
Java is a high-level, object-oriented programming language
developed by Sun Microsystems (1995).
Features: Simple, Secure, Platform Independent, Object-Oriented,
Robust, Multithreaded, Portable.
JVM (Java Virtual Machine) → Runs Java bytecode.
JRE (Java Runtime Environment) → Provides JVM + libraries.
JDK (Java Development Kit) → JRE + compiler + tools.
Example Program:
class HelloWorld { public static void main(String[] args) {
[Link]("Hello, World!"); } }

2. Java Basics
Identifiers → Names for variables, methods, classes.
Variables → Containers for storing values. Example: int a = 10;
Keywords → Reserved words like class, public, static, void.
Rules for naming: start with letter, no spaces, case-sensitive.
Data Types: int, float, double, char, boolean, String, Arrays (1D,
2D, Jagged).
Casting: Implicit (automatic widening) and Explicit (manual
narrowing).

3. Operators in Java
Arithmetic (+, -, *, /, %).
Relational (==, !=, >, <, >=, <=).
Logical (&&, ||, !).
Assignment (=, +=, -=, *=, /=).
Unary (++ , --).
Bitwise (&, |, ^, ~, <<, >>, >>>).
Ternary (condition ? value1 : value2).
Precedence: Unary > Multiplicative > Additive > Relational >
Equality > Logical > Assignment.

4. Java Packages
Package = collection of classes & interfaces.
[Link] → String, Math, Object, Wrapper classes.
[Link] → Scanner, ArrayList, HashMap, Collections.
Import syntax: import [Link];
Custom packages: defined using 'package' keyword.

5. Math Functions in Java


abs(x) → absolute value.
max(a,b), min(a,b).
sqrt(x), pow(a,b).
ceil(x), floor(x), round(x).
random() → double between 0.0 and 1.0.

6. Control Statements
Decision-making: if, if-else, nested if, switch.
Loops: for, while, do-while, enhanced for.
Jump: break, continue, return.
Example if-else:
int marks = 75; if(marks >= 50){ [Link]("Pass");
}else{ [Link]("Fail"); }

7. Methods in Java
Method = block of code that performs a task.
Declaration: returnType methodName(parameters).
Example: int sum(int a, int b){ return a+b; }
Actual args = values passed, Formal args = parameters in method.
Pure Function → always same output for same input.
Impure Function → may change external variables.

8. OOP Concepts
Class = blueprint for objects.
Object = instance of class.
Constructor = special method to initialize object.
Types: Default, Parameterized, Copy.
Encapsulation = hiding data using private + getters/setters.
Inheritance = acquiring properties from parent class (extends).
Polymorphism = Method Overloading (compile-time), Method
Overriding (runtime).
Abstraction = Hiding implementation using abstract classes /
interfaces.
Enum = set of predefined constants.

9. Bubble Sort in Java


Algorithm: Compare adjacent elements & swap if out of order.
Code:
int arr[] = {5,3,1,4,2}; for(int i=0; i arr[j+1]){ int temp =
arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } }
10. Practice MCQs
Q1: Which of these is not a Java feature? (a) Object-Oriented (b)
Use of pointers (c) Robust (d) Secure
Q2: Default value of boolean variable? (a) true (b) false (c) 0 (d)
null
Q3: Which package contains Scanner class? (a) [Link] (b)
[Link] (c) [Link] (d) [Link]
Q4: Which keyword is used for inheritance? (a) implement (b)
extends (c) inherit (d) super
Q5: Output of [Link](3.7)? (a) 3 (b) 4 (c) 3.7 (d) Error

You might also like