Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
13 views
Java Notes
Java basic questions and answers
Uploaded by
Muskan shaikh
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Java notes For Later
Download
Save
Save Java notes For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
13 views
Java Notes
Java basic questions and answers
Uploaded by
Muskan shaikh
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Java notes For Later
Carousel Previous
Carousel Next
Save
Save Java notes For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 9
Search
Fullscreen
Java programming What is Java? Java is a programming language and a platform. Java is a high \evel, robust, object-oriented and secure programming language. Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Platform: Any hardware or software environment in which a program runs, is known as a platform. Since Java has a runtime environment (JRE) and API, it is called a platform. Application 1. Desktop Applications such as acrobat reader, media player, antivirus, etc. . Web Applications such as irctc.co.in, javatpoint.com, etc. . Enterprise Applications such as banking applications. . Mobile . Embedded System . Smart Card . Robotics . Games, etc. ONONRWN Features of Java Simple Java is very easy to learn, and its syntax is simple, clean and easy to understand. According to Sun Microsystem, Java language is a simple programming language because: Java syntax is based on C++ (so easier for programmers to learn it aftero Java has removed many complicated and rarely-used featu 2/10 example, explicit pointers, operator overloading, etc. ‘ea There is no need to remove unreferenced objects because there is an Automatic Garbage Collection in Java. Object-oriented Java is an object-oriented programming language. Everything in Java is an object. Object-oriented means we organize our software as a combination of different types of objects that incorporate both data and behaviour. Platform Independent Class File “| Mac/OS windows Linux JvM VM IV 1 J df oth Java is platform independent because it is different from other languages like C, C++, etc. which are compiled into platform specific machines while Java is a write once, run anywhere language. A platform is the hardware or software environment in which a program runs. Secured Java is best known for its security. With Java, we can develop virus-free systems. Java is secured because: o No explicit pointer « Java Programs run inside a virtual machine sandbox Robust The English mining of Robust is strong. Java is robust because:o Ituses strong memory management. o There is a lack of pointers that avoids security problems. «Java provides automatic garbage collection which runs on the Java Virtual Machine to get rid of objects which are not being used by a Java application anymore. Architecture-natural Java is architecture natural because there are no implementation dependent features, for example, the size of primitive types is fixed. Portable Java is portable because it facilitates you to carry the Java bytecode to any platform. It doesn’t require any implementation. High-performance Java is faster than other traditional interpreted programming languages because Java bytecode is "close" to native code. Distributed Java is distributed because it facilitates users to create distributed applications in Java. Multi-threaded A thread is like a separate program, executing concurrently. We can write Java programs that deal with many tasks at once by defining multiple threads. Dynamic Java is a dynamic language. It supports the dynamic loading of classes. It means classes are loaded on demand. It also supports functions from its native languages, i.e., C and C++.First Java Program @ class keyword is used to declare a class in Java. public keyword is an access modifier that represents visibility. It means it is visible to all. static is a keyword. If we declare any method as static, it is known as the static method. The core advantage of the static method is that there is no need to create an object to invoke the static method. The main() method is executed by the JVM, so it doesn't require creating an object to invoke the main() method. So, it saves memory. void is the return type of the method. It means it doesn't return any value. o main represents the starting point of the program. o String[] args or String args[] is used for command line argument. > $ystem.out.printin() is used to print statement. Here, System is a class, out is an object of the PrintStream class, println() is a method of the PrintStream class. What happens at runtime? At runtime, the following steps are performed: C2 ees a Qa &)Q) Can you save a Java source file by another name than the class name? Yes, if the class is not Public. It is explained in the figure given below: case simple} eubtestatic void main(seang argst I} compiles System out pani Helo"): —* ertecode » ard ji: smple.aes Q) Can you have multiple classes in a java source file? Yes, like the figure given below illustrates: e- - &> - * = Djava Difference between JDK, JRE, and JVM JVM JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn't physically exist. It is a specification that provides a runtime environmentJRE 10 JRE is an acronym for Java Runtime Environment. It is also written a a RTE. The Java Runtime Environment is a set of software tools which are used for developing Java applications. It is used to provide the runtime environment. JDK JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a software development environment which is used to develop Java applications and applets. It physically exists. It contains JRE + development tools. Java Variables A variable is a container which holds the value while the Java program is executed. A variable is assigned with a data type. Variable is a name of memory location. There are three types of variables in java: local, instance and static. 1) Local Variable A variable declared inside the body of the method is called local variable. You can use this variable only within that method and the other methods in the class aren't even aware that the variable exists. A local variable cannot be defined with "static" keyword. 2) Instance Variable A variable declared inside the class but outside the body of the method, is called an instance variable. It is not declared as static. 3) Static variable A variable that is declared as static is called a static variable. It cannot be local. You can create a single copy of the static variable and share it among all the instances of the class.Data Types in Java @ id in the Data types specify the different sizes and values that can be store variable. There are two types of data types in Java: 1, Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double. 2. Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays. Unicode System Unicode is a universal international standard character encoding that is capable of representing most of the world's written languages. Why java uses Unicode System? Before Unicode, there were many language standards: © ASCII (American Standard Code for Information Interchange) for the United States. > ISO 8859-1 for Western European Language. o KOI-8 for Russian. >» GB18030 and BIG-5 for Chinese, and so on. Problem This caused two problems: 1. A particular code value corresponds to different letters in the various language standards. 2. The encodings for languages with large character sets have variable lengtt 3. Some common characters are encoded as single bytes, other require two or more byte.Solution To solve these problems, a new language standard was developed i.e! 8/10 System. In unicode, character holds 2 byte, so java also uses 2 byte for characters. lowest value:\u0000 highest value:\UFFFF Operators in Java Operator in Javais a symbol that is used to perform operations. For example: +, -, *,/ etc. There are many types of operators in Java which are given below: © Unary Operator, o Arithmetic Operator, o Shift Operator, © Relational Operator, o Bitwise Operator, e Logical Operator, Ternary Operator and o Assignment Operator. Java Keywords Java keywords are also known as reserved words. Keywords are particular words that act as a key to a code. These are predefined words by Java so they cannot be used as a variable or object name or class name.Java Control Statements | Control Flow in Java provides three types of control flow statements. 1. Decision Making statements o tf statements o switch statement 2. Loop statements o do while loop o while loop o for loop for-each loop 3. Jump statements © break statement e continue statement Decision-Making statements: As the name suggests, decision-making statements decide which statement to execute and when. 1) If Statement: In Java, the "if” statement is used to evaluate a condition. The control of the program is diverted depending upon the specific condition. The condition of the If statement gives a Boolean value, either true or false. 2) if-else statement The if-else statement is an extension to the if-statement, which uses another block of code, i.e., else block. 3) if-else-if ladder: if-statement followed by multiple else- The if-else-if statement contains the e can say that it is the chain of if-else if statements. In other words, we
You might also like
Hourglass Workout Program by Luisagiuliet 2
PDF
76% (21)
Hourglass Workout Program by Luisagiuliet 2
51 pages
12 Week Program: Summer Body Starts Now
PDF
87% (46)
12 Week Program: Summer Body Starts Now
70 pages
Read People Like A Book by Patrick King-Edited
PDF
57% (82)
Read People Like A Book by Patrick King-Edited
12 pages
Livingood, Blake - Livingood Daily Your 21-Day Guide To Experience Real Health
PDF
77% (13)
Livingood, Blake - Livingood Daily Your 21-Day Guide To Experience Real Health
260 pages
Cheat Code To The Universe
PDF
94% (79)
Cheat Code To The Universe
34 pages
Facial Gains Guide (001 081)
PDF
91% (45)
Facial Gains Guide (001 081)
81 pages
Curse of Strahd
PDF
95% (467)
Curse of Strahd
258 pages
The Psychiatric Interview - Daniel Carlat
PDF
91% (34)
The Psychiatric Interview - Daniel Carlat
473 pages
The Borax Conspiracy
PDF
91% (57)
The Borax Conspiracy
14 pages
COSMIC CONSCIOUSNESS OF HUMANITY - PROBLEMS OF NEW COSMOGONY (V.P.Kaznacheev,. Л. V. Trofimov.)
PDF
94% (215)
COSMIC CONSCIOUSNESS OF HUMANITY - PROBLEMS OF NEW COSMOGONY (V.P.Kaznacheev,. Л. V. Trofimov.)
212 pages
TDA Birth Certificate Bond Instructions
PDF
97% (285)
TDA Birth Certificate Bond Instructions
4 pages
The Secret Language of Attraction
PDF
86% (108)
The Secret Language of Attraction
278 pages
How To Develop and Write A Grant Proposal
PDF
83% (542)
How To Develop and Write A Grant Proposal
17 pages
Penis Enlargement Secret
PDF
60% (124)
Penis Enlargement Secret
12 pages
Workbook For The Body Keeps The Score
PDF
89% (53)
Workbook For The Body Keeps The Score
111 pages
Donald Trump & Jeffrey Epstein Rape Lawsuit and Affidavits
PDF
83% (1016)
Donald Trump & Jeffrey Epstein Rape Lawsuit and Affidavits
13 pages
KamaSutra Positions
PDF
78% (69)
KamaSutra Positions
55 pages
7 Hermetic Principles
PDF
93% (30)
7 Hermetic Principles
3 pages
27 Feedback Mechanisms Pogil Key
PDF
77% (13)
27 Feedback Mechanisms Pogil Key
6 pages
Frank Hammond - List of Demons
PDF
92% (92)
Frank Hammond - List of Demons
3 pages
Phone Codes
PDF
79% (28)
Phone Codes
5 pages
36 Questions That Lead To Love
PDF
91% (35)
36 Questions That Lead To Love
3 pages
How 2 Setup Trust
PDF
97% (307)
How 2 Setup Trust
3 pages
The 36 Questions That Lead To Love - The New York Times
PDF
91% (35)
The 36 Questions That Lead To Love - The New York Times
3 pages
100 Questions To Ask Your Partner
PDF
78% (36)
100 Questions To Ask Your Partner
2 pages
Satanic Calendar
PDF
25% (56)
Satanic Calendar
4 pages
The 36 Questions That Lead To Love - The New York Times
PDF
95% (21)
The 36 Questions That Lead To Love - The New York Times
3 pages
14 Easiest & Hardest Muscles To Build (Ranked With Solutions)
PDF
100% (8)
14 Easiest & Hardest Muscles To Build (Ranked With Solutions)
27 pages
Jeffrey Epstein39s Little Black Book Unredacted PDF
PDF
75% (12)
Jeffrey Epstein39s Little Black Book Unredacted PDF
95 pages
1001 Songs
PDF
70% (73)
1001 Songs
1,798 pages
The 4 Hour Workweek, Expanded and Updated by Timothy Ferriss - Excerpt
PDF
23% (954)
The 4 Hour Workweek, Expanded and Updated by Timothy Ferriss - Excerpt
38 pages
Zodiac Sign & Their Most Common Addictions
PDF
63% (30)
Zodiac Sign & Their Most Common Addictions
9 pages
Java Notes
PDF
No ratings yet
Java Notes
23 pages
Java Premium Notes
PDF
No ratings yet
Java Premium Notes
80 pages
Core Java Note
PDF
No ratings yet
Core Java Note
79 pages
Java Complete Notes
PDF
No ratings yet
Java Complete Notes
79 pages
Coding a to z
PDF
No ratings yet
Coding a to z
53 pages
Introduction To Java
PDF
No ratings yet
Introduction To Java
15 pages
Java UNIT 1
PDF
No ratings yet
Java UNIT 1
58 pages
UNIT 1.1 Java Fundamentals
PDF
No ratings yet
UNIT 1.1 Java Fundamentals
41 pages
core java
PDF
No ratings yet
core java
163 pages
Core Java Notes
PDF
No ratings yet
Core Java Notes
136 pages
Module 2
PDF
No ratings yet
Module 2
101 pages
Java Unit-1 Notes
PDF
No ratings yet
Java Unit-1 Notes
19 pages
Presentation 1
PDF
No ratings yet
Presentation 1
26 pages
Notes Unit 1
PDF
No ratings yet
Notes Unit 1
9 pages
DAY 1 TECH
PDF
No ratings yet
DAY 1 TECH
37 pages
JAVA VIVA ??
PDF
No ratings yet
JAVA VIVA ??
74 pages
Notesjavadocx__2024_11_26_22_44_32
PDF
No ratings yet
Notesjavadocx__2024_11_26_22_44_32
61 pages
D1.1 What Makes Java More Powerful Than C and C++?
PDF
No ratings yet
D1.1 What Makes Java More Powerful Than C and C++?
16 pages
Core Java
PDF
No ratings yet
Core Java
77 pages
Java I
PDF
No ratings yet
Java I
47 pages
Java Unit 1
PDF
No ratings yet
Java Unit 1
56 pages
Java Module I and II
PDF
No ratings yet
Java Module I and II
31 pages
Software Engineer - Learn Java by Examples (2019)
PDF
No ratings yet
Software Engineer - Learn Java by Examples (2019)
69 pages
1 Introduction To Java
PDF
No ratings yet
1 Introduction To Java
25 pages
JavaUnit 1
PDF
No ratings yet
JavaUnit 1
24 pages
Unit - 1 Object Oriented Programming Through Java (B.Tech II-I)
PDF
No ratings yet
Unit - 1 Object Oriented Programming Through Java (B.Tech II-I)
10 pages
Java NOTES PDF
PDF
No ratings yet
Java NOTES PDF
33 pages
Vbspu Bca Java Note
PDF
No ratings yet
Vbspu Bca Java Note
203 pages
An Introduction To Core Java Unit-1
PDF
No ratings yet
An Introduction To Core Java Unit-1
97 pages
Java-class-1-compressed (1)
PDF
No ratings yet
Java-class-1-compressed (1)
14 pages
Lecture Notes Unit 1 Java
PDF
No ratings yet
Lecture Notes Unit 1 Java
37 pages
Java Porgramming Part 1
PDF
No ratings yet
Java Porgramming Part 1
37 pages
JAVA
PDF
No ratings yet
JAVA
34 pages
Java Notebook
PDF
100% (1)
Java Notebook
76 pages
DishuNotes
PDF
No ratings yet
DishuNotes
68 pages
Java Project
PDF
No ratings yet
Java Project
35 pages
175 16sccit4-16sccca3-16scccs3 2020051602435211 PDF
PDF
No ratings yet
175 16sccit4-16sccca3-16scccs3 2020051602435211 PDF
126 pages
Java Unit 1
PDF
No ratings yet
Java Unit 1
65 pages
LectureNotesdocx__2024_11_22_16_12_13docx__2024_11_25_15_01_08
PDF
No ratings yet
LectureNotesdocx__2024_11_22_16_12_13docx__2024_11_25_15_01_08
27 pages
CS-22
PDF
No ratings yet
CS-22
42 pages
Chapter 1. Introduction To Java
PDF
No ratings yet
Chapter 1. Introduction To Java
20 pages
Java First Unit
PDF
No ratings yet
Java First Unit
42 pages
Java Notes
PDF
No ratings yet
Java Notes
120 pages
JAVA1
PDF
No ratings yet
JAVA1
42 pages
Java 1 Intro, Variable Datetype Oper
PDF
No ratings yet
Java 1 Intro, Variable Datetype Oper
22 pages
Unit 1 Introduction to Java notes Jan 2025
PDF
No ratings yet
Unit 1 Introduction to Java notes Jan 2025
45 pages
Introduction To Java Language: Saravana Kumar
PDF
No ratings yet
Introduction To Java Language: Saravana Kumar
48 pages
What Is Java?: Platform: Any Hardware or Software
PDF
No ratings yet
What Is Java?: Platform: Any Hardware or Software
46 pages
Java Notes
PDF
No ratings yet
Java Notes
391 pages
What Is Java
PDF
No ratings yet
What Is Java
15 pages
Unit1
PDF
No ratings yet
Unit1
14 pages
Java Notes Unit2
PDF
No ratings yet
Java Notes Unit2
29 pages
Javaenture Workshop Finaldraft.pptx
PDF
No ratings yet
Javaenture Workshop Finaldraft.pptx
181 pages
Java 1 Unit
PDF
No ratings yet
Java 1 Unit
45 pages
Wepik Unraveling The Wonders of Java A Comprehensive Guide 20231106101829jKUr
PDF
No ratings yet
Wepik Unraveling The Wonders of Java A Comprehensive Guide 20231106101829jKUr
106 pages
Java
PDF
No ratings yet
Java
21 pages
KCA 202 OOP Unit 1 - 240429 - 111726
PDF
No ratings yet
KCA 202 OOP Unit 1 - 240429 - 111726
24 pages
Core Java Cheat Sheet
PDF
No ratings yet
Core Java Cheat Sheet
11 pages