Lecture-1 - Java
Lecture-1 - Java
ai
linkedinid:: Nitin M(https://www.linkedin.com/in/nitin-m-110169136)
Topic(13 sessions)
==================
=> Need of Compiler vs Interpreter
=> Usage of identifiers,reserve words
=> Need of datatype in Java
=> Operators and Control statements
=> Arrays
=> Strings
=> JVM Architecture
=> OOps
=> Exceptionhandling
=> MultiThreading
=> Collections
=> JDK8 features
=> JDBC,Servlet,JSP
=> Hibernate
=> SpringBasics,SpringBoot and Microservices
Compiler -> It is a software which takes sourcecode(HLL) as the input and generates
MLL code as the ouput
To convert the HLL code to MLL code compiler will scan the HLL code
only once.
Program Execution
=================
=> java programs will be first compiled,to compile java program we need java
compiler and java compiler will be installed when we install
jdk software.
=> jdk software installation location :: c:\programfiles\jdk....
=> All the commands required for java developer to run his program would be
present inside <java_home>\bin folder
=> bin folder
|=> javac
|=> java
|=> javap
|=> javadoc
|=> jar
=> .class file generated will have instructions in bytecode(neither HLL nor MLL).
=> bytecodes will be taken by JVM and it will be loaded inside JRE, then the
execution begins.
What is an identifier?
identifer is a name in java program.
identifer can be classname,methodname,variablename,labelname.
eg::
class Demo
{
public static void main(String[] args)
{
int x = 10;
}
}
Demo: classname
main: methodName
String: className
args : variablename
x : variableName
eg::
public class Sample
{
public static void main(String[] args)
{
int String = 20;
System.out.println(String);//20
eg::
public class Sample
{
public static void main(String[] args)
{
int System = 20;
java.lang.System.out.println(System);
}
}
eg::
public class Sample
{
public static void main(String[] args)
{
int Thread = 20;
System.out.println(new Thread());
}
}
eg::
public class Sample
{
public static void main(String[] args)
{
int String = 10;
System.out.println(args.length);
}
}
eg::
public class String
{
public static void main(java.lang.String[] args)
{
System.out.println("Hello World!");
}
}
What is a ReserverWord?
They are builtin words associated with special meaning.
Keyword -> 50
a. used keywords(48)
b. unused keywords(2)
a. goto
b. const
Reserved literals -> 3
a. null
b. true
c. false
public,private,protected,static,synchronized,strictfp,final,abstract,native,transie
nt,volatile
ClassRelated keywords(7)
enum,class,package,interface,extends,import,implements
ObjectRelated keywords(4)
new,instanceof,super,this
For the code below, what should be the name of java file?
1.
public class HelloWorld {
public static void main(String [] args) {
System.out.println("Hello World!");
}
}
A. Hello.java
B. World.java
C. HelloWorld.java
D. helloworld.java
Answer:: C
2.
Does below code compile successfully?
public class Test {
public static void main(String [] args) {
System.out.println("Hello");;;;;;;;;
}
}
A. yes
B. no
Answer: A
3.
What is the signature of special main method?
A. public static void main(String args)
B. public static void main(String[] a)
C. public static void main()
D. private static void main(String[] args)
Answer::B
4.
What will be the result of compiling and executing Test class?
java Test good morning everyone
private class Test{
public static void main(String args[]) {
System.out.println(args[1]);
}
}
A. compilation error
B. good
C. morning
D. everyone
5.
For the class Test, which options, if used to replace /*INSERT*/, will print
"Hurrah! I passed..." on to the console? Select 2 options.
public class Test {
/*INSERT*/ {
System.out.println("Hurrah! I passed...");
}
}
Answer:: A,B