Cbseskilleducation Com Java-class-12-Notes #Google Vignette
Cbseskilleducation Com Java-class-12-Notes #Google Vignette
Teachers and Examiners (CBSESkillEduction) collaborated to create the Java Class 12 Notes. All
the important Information are taken from the NCERT Textbook Information Technology (802) class
12. November 2023
April 2023
Java is a high-level, class-based, object-oriented programming language. Java Interpreter java program to October 2022
Java Bytecode. This method has the advantage that once a Java programme has been converted to bytecode, September 2022
it can be executed on any platform (such as Windows, Linux, or Mac), provided the platform is running the
August 2022 July
JVM. Because of this, Java programmes are extremely portable and cross-platform.
2022
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
March 2022 February
2022
Algorithm Flowchart
When declaring variables, we have to specify the data type of information that the member will hold – CBSE Class 9 Science CBSE
integer, fractional, alphanumeric, and so on. The type of a variable tells the compiler, how much memory to NCERT Books PDF
reserve when storing a variable of that type.
CBSE Skill Education Class
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Employability Skills Class 10
byte Integer 8-bit
Question Answers
short Integer 16-bit
Employability Skills Class 11
int Integer 32-bit Employability Skills Class 11 MCQ
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
String variables, also known as alphanumeric variables or character variables, treat their values as text. As a UPSC Short Notes
result, string variables may have values that are made up of letters, numbers, or symbols.
Web Application Class 11 Web
Operators
In a programming language, operators are special symbols that carry out certain operations.
Arithmetic Operators
Relational Operators
Assignment Operators
Logical Operators
Athematic Operator
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Relational Operators
Assignment Operators
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Logical Operator
Selection Structures
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
In real life, you often select your actions based on whether a condition is true or false. Similarly in a
program, you may want to execute a part of the program based on the value of an expression. Java provides
two statements –
If else Statement
Switch Statement
The if else statement in Java lets us execute a block of code depending upon whether an expression
evaluates to true or false. The structure of the Java if statement is as below –
Syntax –
if (expression) {
statements
}
else
{ }
Question > Write a Java program to check weather age is grater then 20 not?
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
The Switch Statement
The switch statement is used to execute a block of code matching one value out of many possible values.
The structure of the Java switch statement is as follows –
Syntax –
case 2:
System.out.println(“Case 2”);
case 3:
System.out.println(“Case 3”);
default:
System.out.println(“Default case”);
}
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Question > Java programme to display a Switch statement example.
Repetition Structures
In real life you often do something repeatedly, for example, consider a task such as reading a book, first you
open the book, and then repeatedly – read a page; flip the page – until you get to the end of the book, then
close the book.
In entry control loop condition is checked In exit control loop condition is checked last
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
first
If the condition is false, loop body will not If the condition is false, loop body will execute at least
execute once
The while statement evaluates the test before executing the body of a loop. The structure of the Java while
statement is as shown –
Syntax –
while (expression)
{
statements
}
Question > Write a Java program to print the number from 1 to 5 using while statement. public class
WhileDemo {
public static void main (String[ ] args)
{ int number = 1;
while (number <= 5) {
System.out.print (“number);
number++;
}}}
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
The do while statement evaluates the test after executing the body of a loop. The structure of the Java do
while statement is as shown –
Syntax –
do
{
statements
} while (expression);
Question > Write a Java program to print the number from 1 to 5 using do-while statement. public
class DowhileDemo {
public static void main (String[ ] args)
{ int number = 1;
do {
System.out.print (“number);
number++;
} while (number <= 5);
}}
The for loop is the most widely used Java loop construct. The structure of the Java for statement is as below:
Syntax –
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Question > Write a Java program to print the number from 1 to 5 using for statement.
Arrays in Java
Arrays are variables that can hold more than one value, they can hold a list of values of the same type.
For example,
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Array Variable Declaration
Syntax –
Example – Let us write a method that given the length and breadth of a rectangle as
parameters returns the area of the rectangle.
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
static double rectangle_area (double length, double breadth)
{
return (length * breadth);
}
What is Class?
A class is a collection of objects with similar characteristics. It serves as a model or blueprint from which
things can be made. It makes sense as a whole. It cannot be bodily.
Fields
Methods
Constructors
Blocks
Nested class and interface
class <class_name>{
field;
method;
}
What is Object?
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
An object is an entity with state and behaviour, such as a chair, bike, marker, pen, table, or car. It could be
intellectual or physical (tangible and intangible). The banking system is an illustration of an intangible entity.
Object Definitions:
Constructors
A special method member called the constructor method is used to initialize the data members of the class
(or any other initialization is to be done at time of object creation).
The constructor has the same name as the class, has no return type, and may or may not have a
parameter list. Whenever a new object of a class is created, the constructor of the class is invoked
automatically. We do not call the constructor explicitly.
Access Modifiers
In object-oriented languages, the accessibility of classes, methods, and other members is controlled through
the use of access modifiers . Access modifiers are a particular type of syntax used in programming
languages that make it easier to encapsulate components.
Public, protected, default, and private are the four types of access modifiers in Java.
A class’s private data members cannot be accessed from outside the class, but you can grant getter and setter
methods controlled access to data members outside the class. The value of a data member is returned by a
getter method.
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
For example we could define a getter method in the Bookclass for the price data member as given below –
double getPrice ( )
{ return price;
}
Java Libraries
A Java library is nothing more than a selection of already created classes. You can use those classes in your
code when you download them and inform your computer about them.
Without String, Enum, Double, etc., we cannot write any Java programme. Everything we need to
write Java code is available to us through the lang library.
Because util class contains the definitions of all data structures and collections, it is necessary in
order to use data structures and collections in Java.
We require the io library in order to deal with pipes and read data from files. It enables Java
programmers to use files in their programmes.
Data Input
The data input helps to take input from the user, this input are by default string. There are three ways to read
user input into a Java programme in a command-line environment: Java BufferedReader Class, Java Scanner
Class, and Console Class.
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Question > Write a program to accept name from user and print them in the console.
import java.util.Scanner;
public class Datainput {
public static void main(String[] args) {
Scanner user_input = new Scanner(System.in);
System.out.println(“Enter Your Name”);
String name = user_input.next();
System.out.println(“Your name is : ” + name);
}}
Array Manipulation
The elements of an array can be any combination of integers, floating numbers, or complex numbers, and
they all share the same underlying data type. Array manipulation helps to manipulate the data using
predefine function, from example “binarySearch()”.
We can search for a specific element in an array using the binarySearch() function of the Arrays class. The
array to be searched and the key element to be searched are the parameters required. The method returns the
array’s index, which is the location of the key. The binarySearch method gives a negative value if the key
cannot be found in the array.
Example –
String Manipulation
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Exception Handling
Runtime issues such as ClassNotFoundException, IOException, SQLException, RemoteException, etc. can
be handled through the Java Exception Handling mechanism. An exception is a disruptive occurrence that
takes place at run time, or during the execution of a programme, which interrupts the regular flow of the
program’s instructions.
try – A try block surrounds the part of the code that can generate exception(s).
catch – The catch blocks follow a try block. A catch block contains the exception handler – specific code
that is executed when the exception occurs. Multiple catch blocks following a try block can handle different
types of exceptions.
Threads
A multithreaded programme can execute numerous tasks simultaneously for the best possible resource
utilisation on the computer. A multithreaded programme is made up of two or more threads, each of which is
capable of carrying out a particular task independently and concurrently.
Wrapper Classes
PDFmyURL converts web pages and even full websites to PDF easily and quickly.
Java’s primitive datatypes, including int, float, and others, are typically supplied by value rather than via
reference. Primitive datatypes may occasionally need to be passed by reference. When that happens, you can
use the Java wrapper classes.
These classes encapsulate the primitive datatype in an object. For instance, an int variable is held by the
Integer wrapper class.
PDFmyURL converts web pages and even full websites to PDF easily and quickly.