SlideShare ist ein Scribd-Unternehmen logo
1 von 60
www.GarudaTrainings.com
www.GarudaTrainings.com
You focus at the person asking you that query and think, I
should know this! But at that time, you cannot quite keep
in mind, and then punch yourself psychologically for not
planning for your meeting. Good thing that is just a bogus
situation and you are definitely going to be able to
response that query and more when the time comes! The
common organization choosing a JAVA developer is
looking for someone who can system well beyond the
stage trained in an starting JAVA category. Hiring
managers ask concerns that are not actually stumpers, but
are intended to generate a applicant's further information
of the topic.
www.GarudaTrainings.com
Java is a high-level programming language originally
developed by Sun Microsystems and released in 1995. Java
runs on a variety of platforms, such as Windows, Mac OS, and
the various versions of UNIX.
www.GarudaTrainings.com
Java runs on a variety of platforms, such as Windows, Mac
OS, and the various versions of UNIX/Linux like HP-
Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc.
www.GarudaTrainings.com
Some features include Object Oriented, Platform
Independent, Robust, Interpreted, Multi-threaded
www.GarudaTrainings.com
It’s compiler generates an architecture-neutral object file
format, which makes the compiled code to be executable
on many processors, with the presence of Java runtime
system.
www.GarudaTrainings.com
Java uses Just-In-Time compiler to enable high
performance. Just-In-Time compiler is a program that
turns Java byte code, which is a program that contains
instructions that must be interpreted into instructions
that can be sent directly to the processor.
www.GarudaTrainings.com
It is designed to adapt to an evolving environment.
Java programs can carry extensive amount of run-time
information that can be used to verify and resolve
accesses to objects on run-time.
www.GarudaTrainings.com
When Java is compiled, it is not compiled into
platform specific machine, rather into platform
independent byte code. This byte code is distributed
over the web and interpreted by virtual Machine
(JVM) on whichever platform it is being run.
www.GarudaTrainings.com
Variables defined inside methods, constructors or blocks
are called local variables. The variable will be declared
and initialized within the method and it will be destroyed
when the method has completed.
www.GarudaTrainings.com
These are variables declared with in a class, outside
any method, with the static keyword.
www.GarudaTrainings.com
Singleton class control object creation, limiting the
number to one but allowing the flexibility to create
more objects if the situation changes.
www.GarudaTrainings.com
Constructor gets invoked when a new object is created.
Every class has a constructor. If we do not explicitly
write a constructor for a class the java compiler builds a
default constructor for that class.
www.GarudaTrainings.com
Default value of float and double data type in different
as compared to C/C++. For float its 0.0f and for double
it’s 0.0d
www.GarudaTrainings.com
This data type is used to save space in large arrays,
mainly in place of integers, since a byte is four times
smaller than an int.
www.GarudaTrainings.com
Java provides access modifiers to set access levels for
classes, variables, methods and constructors. A member
has package or default accessibility when no accessibility
modifier is specified.
www.GarudaTrainings.com
Variables, methods and constructors which are
declared protected in a super class can be accessed
only by the subclasses in other package or any class
within the package of the protected members' class.
www.GarudaTrainings.com
Java provides these modifiers for providing
functionalities other than Access
Modifiers, synchronized used to indicate that a
method can be accessed by only one thread at a time.
www.GarudaTrainings.com
 JVM, or the Java Virtual Machine, is an interpreter which accepts ‘Byte
code’ and executes it.
 Java has been termed as a ‘Platform Independent Language’ as it
primarily works on the notion of ‘compile once, run everywhere’. Here’s
a sequential step establishing the Platform independence feature in
Java:
 The Java Compiler outputs Non-Executable Codes called ‘Byte code’.
 Byte code is a highly optimized set of computer instruction which
could be executed by the Java Virtual Machine (JVM).
 The translation into Byte code makes a program easier to be executed
across a wide range of platforms, since all we need is a JVM designed
for that particular platform.
 JVMs for various platforms might vary in configuration, those they
would all understand the same set of Byte code, thereby making the
Java Program ‘Platform Independent’.
www.GarudaTrainings.com
 When asked typical JAVA most start up Java
developers get confused with JDK and JRE. And
eventually, they settle for ‘anything would do man, as
long as my program runs!!’ Not quite right if you aspire
to make a living and career out of Programming.
 The “JDK” is the Java Development Kit. I.e., the JDK is
bundle of software that you can use to develop Java
based software.
www.GarudaTrainings.com
 We are sure you must be well-acquainted with
the JAVA Basic Now that we are settled with the initial
concepts, let’s look into the Language specific
offerings.
 Static variable is associated with a class and not objects
of that class.
www.GarudaTrainings.com
public class ExplainStatic
{
public static String name = "Look I am a static variable";
}
www.GarudaTrainings.com
public class Application
{
public static void main(String[] args)
{
System.out.println(ExplainStatic.name)
}
}
www.GarudaTrainings.com
 We don’t create object of the class ExplainStatic to
access the static variable. We directly use the class
name itself: ExplainStatic.name
 The “JRE” is the Java Runtime Environment. I.e., the
JRE is an implementation of the Java Virtual Machine
which actually executes Java programs.
 Typically, each JDK contains one (or more) JRE’s along
with the various development tools like the Java source
compilers, bundling and deployment tools, debuggers,
development libraries, etc.
www.GarudaTrainings.com
 This is one of the most common and fundamental Java interview
questions. This is something you should have right at your finger-tips when
asked. The eight Primitive Data types supported by Java are:
 Byte : 8-bit signed two’s complement integer. It has a minimum value of -
128 and a maximum value of 127 (inclusive)
 Short : 16-bit signed two’s complement integer. It has a minimum value of
-32,768 and a maximum value of 32,767 (inclusive).
 Int : 32-bit signed two’s complement integer. It has a minimum value of -
2,147,483,648 and a maximum value of 2,147,483,647 (inclusive)
 Long : 64-bit signed two’s complement integer. It has a minimum value of -
9,223,372,036,854,775,808 and a maximum value of
9,223,372,036,854,775,807 (inclusive)
 Float
 Double
www.GarudaTrainings.com
 Autoboxing: The Java compiler brings about an automatic
transformation of primitive type (int, float, double etc.)
into their object equivalents or wrapper type (Integer,
Float, Double,etc) for the ease of compilation.
 Unboxing: The automatic transformation of wrapper types
into their primitive equivalent is known as Unboxing.
 Autoboxing: The Java compiler brings about an automatic
transformation of primitive type (int, float, double etc.)
into their object equivalents or wrapper type (Integer,
Float, Double,etc) for the ease of compilation.
 Unboxing: The automatic transformation of wrapper types
into their primitive equivalent is known as Unboxing
www.GarudaTrainings.com
String object is immutable. i.e , the value stored in
the String object cannot be changed.
Consider the following code snippet:
 String myString = “Hello”;
 myString = myString + ” Guest”;
www.GarudaTrainings.com
StringBuffer/StringBuilder objects are
mutable: StringBuffer/StringBuilder objects are
mutable; we can make changes to the value stored in
the object. What this effectively means is that string
operations such as append would be more efficient if
performed using String Buffer/StringBuilder objects
than String objects.
www.GarudaTrainings.com
 String str = “Be Happy With Your Salary.''
 str += “Because Increments are a myth";
 StringBuffer strbuf = new StringBuffer();
 strbuf.append(str);
 System.out.println(strbuf);
The Output of the code snippet would be: Be Happy
With Your Salary. Because Increments are a myth.
www.GarudaTrainings.com
 This is a very important concept in OOP and is a
must-know for every Java Programmer.
 Over-Riding: An override is a type of function which
occurs in a class which inherits from another class. An
override function “replaces” a function inherited from
the base class, but does so in such a way that it is
called even when an instance of its class is pretending
to be a different type through polymorphism. That
probably was a little over the top. The code snippet
below should explain things better.
www.GarudaTrainings.com
 public class Car {
 public static void main (String [] args) {
 Car a = new Car();
 Car b = new Ferrari(); //Car ref, but a Ferrari object
 a.start(); // Runs the Car version of start()
 b.start(); // Runs the Ferrari version of start()
 }
 }
 class Car {
 public void start() {
 System.out.println("This is a Generic start to any Car");
 }
 }
 class Ferrari extends Car {
 public void start() {
 System.out.println("Lets start the Ferrari and go out for a cool Party.");
 }
 }
www.GarudaTrainings.com
Over-Loading:
Overloading is the action of defining multiple methods
with the same name, but with different parameters. It is
unrelated to either overriding or polymorphism. Functions
in Java could be overloaded by two mechanisms ideally:
 Varying the number of arguments.
 Varying the Data Type.
www.GarudaTrainings.com
 class CalculateArea{
 void Area(int length){System.out.println(length*2);}
 void Area(int length , int width){System.out.println(length*
width);}
 public static void main(String args[]){
 CalculateArea obj=new CalculateArea();
 obj.Area(10); // Area of a Square
 obj.Area(20,20); // Area of a Rectangle
 }
}
www.GarudaTrainings.com
 Constructor: The sole purpose of having Constructors is to
create an instance of a class. They are invoked while creating an
object of a class. Here are a few salient features of Java
Constructors:
 Constructors can be public, private, or protected.
 If a constructor with arguments has been defined in a class, you
can no longer use a default no-argument constructor – you have
to write one.
 They are called only once when the class is being instantiated.
 They must have the same name as the class itself.
 They do not return a value and you do not have to specify the
keyword void.
 If you do not create a constructor for the class, Java helps you by
using a so called default no-argument constructor.
www.GarudaTrainings.com
ublic class Boss{
String name; Boss(String input)
{ //This is the constructor
name = "Our Boss is also known as :
" + input;
} public static void main(String args[])
{ Boss p1 = new Boss("Super-Man");
}
}
www.GarudaTrainings.com
Constructor overloading: passing different number and
type of variables as arguments all of which are private
variables of the class. Example snippet could be as
follows:
www.GarudaTrainings.com
 public class Boss{
 String name;
 Boss(String input) { //This is the constructor
 name = "Our Boss is also known as : " + input;
 }
 Boss() {
 name = "Our Boss is a nice man. We don’t call him names.”;
 }
 public static void main(String args[]) {
 Boss p1 = new Boss("Super-Man");
 Boss p2 = new Boss();
 }
 }
www.GarudaTrainings.com
Copy Constructor: A copy constructor is a type of
constructor which constructs the object of the class
from another object of the same class. The copy
constructor accepts a reference to its own class as a
parameter.
www.GarudaTrainings.com
 Anything that’s not Normal is an exception.
Exceptions are the customary way in Java to indicate to
a calling method that an abnormal condition has
occurred.
 In Java, exceptions are objects. When you throw an
exception, you throw an object. You can’t throw just
any object as an exception, however — only those
objects whose classes descend from Throwable.
www.GarudaTrainings.com
base class for an entire family of classes, declared in
java.lang, that your program can instantiate and throw.
Here’s a hierarchical
www.GarudaTrainings.com
www.GarudaTrainings.com
 An Unchecked Exception inherits from RuntimeException
(which extends from Exception). The JVM treats
RuntimeException differently as there is no requirement for the
application-code to deal with them explicitly.
 A Checked Exception inherits from the Exception-class. The
client code has to handle the checked exceptions either in a try-
catch clause or has to be thrown for the Super class to catch the
same. A Checked Exception thrown by a lower class (sub-
class) enforces a contract on the invoking class (super-class) to
catch or throw it.
 Errors (members of the Error family) are usually thrown for
more serious problems, such as Out Of Memory Error (OOM),
that may not be so easy to handle.www.GarudaTrainings.com
Throws: A throws clause lists the types of exceptions
that a method might throw, thereby warning the
invoking method – ‘Dude. You need to handle this list
of exceptions I might throw.’ Except those of type Error
or Runtime Exception, all other Exceptions or any of
their subclasses, must be declared in the throws
clause, if the method in question doesn’t implement a
try…catch block. It is therefore the onus of the next-
on-top method to take care of the mess.
www.GarudaTrainings.com
 public void myMethod() throws PRException
 {..}
 This means the super function calling the function should be eq
uipped to handle this exception.
 public void Callee()
 {
 try{
 myMethod();
 }catch(PRException ex)
 {
 ...handle Exception....
 }
 }
www.GarudaTrainings.com
Using the Throw: If the user wants to throw an
explicit Exception, often customized, we use the
Throw. The Throw clause can be used in any part of
code where you feel a specific exception needs to be
thrown to the calling
www.GarudaTrainings.com
 Try
 {
 if(age>100){throw new AgeBarException(); //Customiz
ed ExceptioN
 }else{
 ....}
 }
 }catch(AgeBarException ex){
 ...handle Exception.....
 }
www.GarudaTrainings.com
Every JAVA Programmer deals with File Operations.
To generate User reports, send attachments through
mails and spill out data files from Java programs. And a
sound knowledge on File Operation becomes even
more important while dealing with Java questions.
www.GarudaTrainings.com
 byte stream : For reading and writing binary data, byte stream is
incorporated. Programs use byte streams to perform byte input and
output.
 Performing InputStream operations or OutputStream operations
means generally having a loop that reads the input stream and writes
the output stream one byte at a time.
 You can use buffered I/O streams for an overhead reduction (overhead
generated by each such request often triggers disk access, network
activity, or some other operation that is relatively expensive).
 Character streams: Character streams work with the characters rather
than the byte. In Java, characters are stored by following the Unicode
(allows a unique number for every character) conventions. In such kind
of storage, characters become the platform independent, program
independent, language independent.
www.GarudaTrainings.com
 FileInputStream : It contains the input byte from a
file and implements an input stream.
 FileOutputStream : It uses for writing data to a file
and also implements an output stream.
www.GarudaTrainings.com
 public class FileHandling {
 public static void main(String [ ] args) throws IOException
 {
 FileInputStream inputStream = new FileInputStream ("Input.txt") ;
 FileOutputStream outputStream = new FileOutputStream("Output.txt",true) ;

 byte[] buffer = new byte[1024];
 //For larger files we specify a buffer size which defines the chunks size for data
 int bytesRead;
 while ((bytesRead = inputStream.read(buffer)) != -1)
 outputStream.write(buffer, 0, bytesRead);
 inputStream.close() ;
 outputStream.close() ;
 }
 }
www.GarudaTrainings.com
FileReader : The FileReader class makes it possible to
read the contents of a file as a stream of characters. It
works much like the FileInputStream, except the
FileInputStream reads bytes, whereas the FileReader
reads characters. The FileReader is intended to read
text, in other words. One character may correspond to
one or more bytes depending on the character
encoding scheme. The File Reader object also lets web
applications asynchronously read the contents of files
(or raw data buffers) stored on the user’s
computer, using File or Blob objects to specify the file
or data to read.
www.GarudaTrainings.com
FileWriter : This class is used to write to character files.
Creation of a File Writer is not dependent on the file
already existing. FileWriter will create the file before
opening it for output when you create the object. Its
write() methods allow you to write character(s) or Strings
to a file. FileWriters are usually wrapped by higher-level
Writer objects such as BufferedWriters or Print Writers,
which provide better performance and higher-level, more
flexible methods to write data.
www.GarudaTrainings.com
 File file = new File("fileWrite2.txt");
 FileWriter fw = new FileWriter(file);
 for(int i=0;i<10;i++){
 fw.write("Soham is Just Awesome : "+i);
 fw.flush();
 }
 fw.close();
 Usage of FileWriter and FileReader used in conjunction is as follows:
 int c;
 FileReader fread = new FileReader("xanadu.txt");
 FileWriter fwrite = new FileWriter("characteroutput.txt");
 while ((c = fread.read()) != -1)
 fwrite.write(c);
www.GarudaTrainings.com
 Iterators allow the caller to remove elements from the
underlying collection during the iteration with well-
defined semantics.
 Iterator actually adds one method that Enumeration
doesn’t have: remove ().
www.GarudaTrainings.com
www.GarudaTrainings.com
www.GarudaTrainings.com
 Simple Date Format is one such concrete class which is
widely used by Java developers for parsing and
formatting of dates. This is also used to convert Dates
to String and vice-versa.
 Literally every Enterprise level Java Application
invariably uses the Simple Date Format for handling
user dates. We of course aren’t expecting Java
interviewees to be absolutely spectacular with the
syntaxes. But a basic know-how of this class is
mandatory.
www.GarudaTrainings.com
 public class CurrentSystemDate {
 public static void main(String[] args) {
 SimpleDateFormat sysForm = new SimpleDateFormat
("yyyy/MM/DD HH:mm:ss");
 Date curdate= new Date();
 System.out.println(sysForm.format(curdate));
 }
 }
 The best way to brush up your Java knowledge is to open up
an eclipse and write loads of codes and sample programs.
Get into the habit of remembering syntaxes and applying
the best coding standards possible.
www.GarudaTrainings.com
www.GarudaTrainings.com

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 

Kürzlich hochgeladen (20)

Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 

Empfohlen

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Java Latest Interview Questions And Answers

  • 3. You focus at the person asking you that query and think, I should know this! But at that time, you cannot quite keep in mind, and then punch yourself psychologically for not planning for your meeting. Good thing that is just a bogus situation and you are definitely going to be able to response that query and more when the time comes! The common organization choosing a JAVA developer is looking for someone who can system well beyond the stage trained in an starting JAVA category. Hiring managers ask concerns that are not actually stumpers, but are intended to generate a applicant's further information of the topic. www.GarudaTrainings.com
  • 4. Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. www.GarudaTrainings.com
  • 5. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP- Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc. www.GarudaTrainings.com
  • 6. Some features include Object Oriented, Platform Independent, Robust, Interpreted, Multi-threaded www.GarudaTrainings.com
  • 7. It’s compiler generates an architecture-neutral object file format, which makes the compiled code to be executable on many processors, with the presence of Java runtime system. www.GarudaTrainings.com
  • 8. Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java byte code, which is a program that contains instructions that must be interpreted into instructions that can be sent directly to the processor. www.GarudaTrainings.com
  • 9. It is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time. www.GarudaTrainings.com
  • 10. When Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run. www.GarudaTrainings.com
  • 11. Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed. www.GarudaTrainings.com
  • 12. These are variables declared with in a class, outside any method, with the static keyword. www.GarudaTrainings.com
  • 13. Singleton class control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes. www.GarudaTrainings.com
  • 14. Constructor gets invoked when a new object is created. Every class has a constructor. If we do not explicitly write a constructor for a class the java compiler builds a default constructor for that class. www.GarudaTrainings.com
  • 15. Default value of float and double data type in different as compared to C/C++. For float its 0.0f and for double it’s 0.0d www.GarudaTrainings.com
  • 16. This data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int. www.GarudaTrainings.com
  • 17. Java provides access modifiers to set access levels for classes, variables, methods and constructors. A member has package or default accessibility when no accessibility modifier is specified. www.GarudaTrainings.com
  • 18. Variables, methods and constructors which are declared protected in a super class can be accessed only by the subclasses in other package or any class within the package of the protected members' class. www.GarudaTrainings.com
  • 19. Java provides these modifiers for providing functionalities other than Access Modifiers, synchronized used to indicate that a method can be accessed by only one thread at a time. www.GarudaTrainings.com
  • 20.  JVM, or the Java Virtual Machine, is an interpreter which accepts ‘Byte code’ and executes it.  Java has been termed as a ‘Platform Independent Language’ as it primarily works on the notion of ‘compile once, run everywhere’. Here’s a sequential step establishing the Platform independence feature in Java:  The Java Compiler outputs Non-Executable Codes called ‘Byte code’.  Byte code is a highly optimized set of computer instruction which could be executed by the Java Virtual Machine (JVM).  The translation into Byte code makes a program easier to be executed across a wide range of platforms, since all we need is a JVM designed for that particular platform.  JVMs for various platforms might vary in configuration, those they would all understand the same set of Byte code, thereby making the Java Program ‘Platform Independent’. www.GarudaTrainings.com
  • 21.  When asked typical JAVA most start up Java developers get confused with JDK and JRE. And eventually, they settle for ‘anything would do man, as long as my program runs!!’ Not quite right if you aspire to make a living and career out of Programming.  The “JDK” is the Java Development Kit. I.e., the JDK is bundle of software that you can use to develop Java based software. www.GarudaTrainings.com
  • 22.  We are sure you must be well-acquainted with the JAVA Basic Now that we are settled with the initial concepts, let’s look into the Language specific offerings.  Static variable is associated with a class and not objects of that class. www.GarudaTrainings.com
  • 23. public class ExplainStatic { public static String name = "Look I am a static variable"; } www.GarudaTrainings.com
  • 24. public class Application { public static void main(String[] args) { System.out.println(ExplainStatic.name) } } www.GarudaTrainings.com
  • 25.  We don’t create object of the class ExplainStatic to access the static variable. We directly use the class name itself: ExplainStatic.name  The “JRE” is the Java Runtime Environment. I.e., the JRE is an implementation of the Java Virtual Machine which actually executes Java programs.  Typically, each JDK contains one (or more) JRE’s along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc. www.GarudaTrainings.com
  • 26.  This is one of the most common and fundamental Java interview questions. This is something you should have right at your finger-tips when asked. The eight Primitive Data types supported by Java are:  Byte : 8-bit signed two’s complement integer. It has a minimum value of - 128 and a maximum value of 127 (inclusive)  Short : 16-bit signed two’s complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive).  Int : 32-bit signed two’s complement integer. It has a minimum value of - 2,147,483,648 and a maximum value of 2,147,483,647 (inclusive)  Long : 64-bit signed two’s complement integer. It has a minimum value of - 9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive)  Float  Double www.GarudaTrainings.com
  • 27.  Autoboxing: The Java compiler brings about an automatic transformation of primitive type (int, float, double etc.) into their object equivalents or wrapper type (Integer, Float, Double,etc) for the ease of compilation.  Unboxing: The automatic transformation of wrapper types into their primitive equivalent is known as Unboxing.  Autoboxing: The Java compiler brings about an automatic transformation of primitive type (int, float, double etc.) into their object equivalents or wrapper type (Integer, Float, Double,etc) for the ease of compilation.  Unboxing: The automatic transformation of wrapper types into their primitive equivalent is known as Unboxing www.GarudaTrainings.com
  • 28. String object is immutable. i.e , the value stored in the String object cannot be changed. Consider the following code snippet:  String myString = “Hello”;  myString = myString + ” Guest”; www.GarudaTrainings.com
  • 29. StringBuffer/StringBuilder objects are mutable: StringBuffer/StringBuilder objects are mutable; we can make changes to the value stored in the object. What this effectively means is that string operations such as append would be more efficient if performed using String Buffer/StringBuilder objects than String objects. www.GarudaTrainings.com
  • 30.  String str = “Be Happy With Your Salary.''  str += “Because Increments are a myth";  StringBuffer strbuf = new StringBuffer();  strbuf.append(str);  System.out.println(strbuf); The Output of the code snippet would be: Be Happy With Your Salary. Because Increments are a myth. www.GarudaTrainings.com
  • 31.  This is a very important concept in OOP and is a must-know for every Java Programmer.  Over-Riding: An override is a type of function which occurs in a class which inherits from another class. An override function “replaces” a function inherited from the base class, but does so in such a way that it is called even when an instance of its class is pretending to be a different type through polymorphism. That probably was a little over the top. The code snippet below should explain things better. www.GarudaTrainings.com
  • 32.  public class Car {  public static void main (String [] args) {  Car a = new Car();  Car b = new Ferrari(); //Car ref, but a Ferrari object  a.start(); // Runs the Car version of start()  b.start(); // Runs the Ferrari version of start()  }  }  class Car {  public void start() {  System.out.println("This is a Generic start to any Car");  }  }  class Ferrari extends Car {  public void start() {  System.out.println("Lets start the Ferrari and go out for a cool Party.");  }  } www.GarudaTrainings.com
  • 33. Over-Loading: Overloading is the action of defining multiple methods with the same name, but with different parameters. It is unrelated to either overriding or polymorphism. Functions in Java could be overloaded by two mechanisms ideally:  Varying the number of arguments.  Varying the Data Type. www.GarudaTrainings.com
  • 34.  class CalculateArea{  void Area(int length){System.out.println(length*2);}  void Area(int length , int width){System.out.println(length* width);}  public static void main(String args[]){  CalculateArea obj=new CalculateArea();  obj.Area(10); // Area of a Square  obj.Area(20,20); // Area of a Rectangle  } } www.GarudaTrainings.com
  • 35.  Constructor: The sole purpose of having Constructors is to create an instance of a class. They are invoked while creating an object of a class. Here are a few salient features of Java Constructors:  Constructors can be public, private, or protected.  If a constructor with arguments has been defined in a class, you can no longer use a default no-argument constructor – you have to write one.  They are called only once when the class is being instantiated.  They must have the same name as the class itself.  They do not return a value and you do not have to specify the keyword void.  If you do not create a constructor for the class, Java helps you by using a so called default no-argument constructor. www.GarudaTrainings.com
  • 36. ublic class Boss{ String name; Boss(String input) { //This is the constructor name = "Our Boss is also known as : " + input; } public static void main(String args[]) { Boss p1 = new Boss("Super-Man"); } } www.GarudaTrainings.com
  • 37. Constructor overloading: passing different number and type of variables as arguments all of which are private variables of the class. Example snippet could be as follows: www.GarudaTrainings.com
  • 38.  public class Boss{  String name;  Boss(String input) { //This is the constructor  name = "Our Boss is also known as : " + input;  }  Boss() {  name = "Our Boss is a nice man. We don’t call him names.”;  }  public static void main(String args[]) {  Boss p1 = new Boss("Super-Man");  Boss p2 = new Boss();  }  } www.GarudaTrainings.com
  • 39. Copy Constructor: A copy constructor is a type of constructor which constructs the object of the class from another object of the same class. The copy constructor accepts a reference to its own class as a parameter. www.GarudaTrainings.com
  • 40.  Anything that’s not Normal is an exception. Exceptions are the customary way in Java to indicate to a calling method that an abnormal condition has occurred.  In Java, exceptions are objects. When you throw an exception, you throw an object. You can’t throw just any object as an exception, however — only those objects whose classes descend from Throwable. www.GarudaTrainings.com
  • 41. base class for an entire family of classes, declared in java.lang, that your program can instantiate and throw. Here’s a hierarchical www.GarudaTrainings.com
  • 43.  An Unchecked Exception inherits from RuntimeException (which extends from Exception). The JVM treats RuntimeException differently as there is no requirement for the application-code to deal with them explicitly.  A Checked Exception inherits from the Exception-class. The client code has to handle the checked exceptions either in a try- catch clause or has to be thrown for the Super class to catch the same. A Checked Exception thrown by a lower class (sub- class) enforces a contract on the invoking class (super-class) to catch or throw it.  Errors (members of the Error family) are usually thrown for more serious problems, such as Out Of Memory Error (OOM), that may not be so easy to handle.www.GarudaTrainings.com
  • 44. Throws: A throws clause lists the types of exceptions that a method might throw, thereby warning the invoking method – ‘Dude. You need to handle this list of exceptions I might throw.’ Except those of type Error or Runtime Exception, all other Exceptions or any of their subclasses, must be declared in the throws clause, if the method in question doesn’t implement a try…catch block. It is therefore the onus of the next- on-top method to take care of the mess. www.GarudaTrainings.com
  • 45.  public void myMethod() throws PRException  {..}  This means the super function calling the function should be eq uipped to handle this exception.  public void Callee()  {  try{  myMethod();  }catch(PRException ex)  {  ...handle Exception....  }  } www.GarudaTrainings.com
  • 46. Using the Throw: If the user wants to throw an explicit Exception, often customized, we use the Throw. The Throw clause can be used in any part of code where you feel a specific exception needs to be thrown to the calling www.GarudaTrainings.com
  • 47.  Try  {  if(age>100){throw new AgeBarException(); //Customiz ed ExceptioN  }else{  ....}  }  }catch(AgeBarException ex){  ...handle Exception.....  } www.GarudaTrainings.com
  • 48. Every JAVA Programmer deals with File Operations. To generate User reports, send attachments through mails and spill out data files from Java programs. And a sound knowledge on File Operation becomes even more important while dealing with Java questions. www.GarudaTrainings.com
  • 49.  byte stream : For reading and writing binary data, byte stream is incorporated. Programs use byte streams to perform byte input and output.  Performing InputStream operations or OutputStream operations means generally having a loop that reads the input stream and writes the output stream one byte at a time.  You can use buffered I/O streams for an overhead reduction (overhead generated by each such request often triggers disk access, network activity, or some other operation that is relatively expensive).  Character streams: Character streams work with the characters rather than the byte. In Java, characters are stored by following the Unicode (allows a unique number for every character) conventions. In such kind of storage, characters become the platform independent, program independent, language independent. www.GarudaTrainings.com
  • 50.  FileInputStream : It contains the input byte from a file and implements an input stream.  FileOutputStream : It uses for writing data to a file and also implements an output stream. www.GarudaTrainings.com
  • 51.  public class FileHandling {  public static void main(String [ ] args) throws IOException  {  FileInputStream inputStream = new FileInputStream ("Input.txt") ;  FileOutputStream outputStream = new FileOutputStream("Output.txt",true) ;   byte[] buffer = new byte[1024];  //For larger files we specify a buffer size which defines the chunks size for data  int bytesRead;  while ((bytesRead = inputStream.read(buffer)) != -1)  outputStream.write(buffer, 0, bytesRead);  inputStream.close() ;  outputStream.close() ;  }  } www.GarudaTrainings.com
  • 52. FileReader : The FileReader class makes it possible to read the contents of a file as a stream of characters. It works much like the FileInputStream, except the FileInputStream reads bytes, whereas the FileReader reads characters. The FileReader is intended to read text, in other words. One character may correspond to one or more bytes depending on the character encoding scheme. The File Reader object also lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user’s computer, using File or Blob objects to specify the file or data to read. www.GarudaTrainings.com
  • 53. FileWriter : This class is used to write to character files. Creation of a File Writer is not dependent on the file already existing. FileWriter will create the file before opening it for output when you create the object. Its write() methods allow you to write character(s) or Strings to a file. FileWriters are usually wrapped by higher-level Writer objects such as BufferedWriters or Print Writers, which provide better performance and higher-level, more flexible methods to write data. www.GarudaTrainings.com
  • 54.  File file = new File("fileWrite2.txt");  FileWriter fw = new FileWriter(file);  for(int i=0;i<10;i++){  fw.write("Soham is Just Awesome : "+i);  fw.flush();  }  fw.close();  Usage of FileWriter and FileReader used in conjunction is as follows:  int c;  FileReader fread = new FileReader("xanadu.txt");  FileWriter fwrite = new FileWriter("characteroutput.txt");  while ((c = fread.read()) != -1)  fwrite.write(c); www.GarudaTrainings.com
  • 55.  Iterators allow the caller to remove elements from the underlying collection during the iteration with well- defined semantics.  Iterator actually adds one method that Enumeration doesn’t have: remove (). www.GarudaTrainings.com
  • 58.  Simple Date Format is one such concrete class which is widely used by Java developers for parsing and formatting of dates. This is also used to convert Dates to String and vice-versa.  Literally every Enterprise level Java Application invariably uses the Simple Date Format for handling user dates. We of course aren’t expecting Java interviewees to be absolutely spectacular with the syntaxes. But a basic know-how of this class is mandatory. www.GarudaTrainings.com
  • 59.  public class CurrentSystemDate {  public static void main(String[] args) {  SimpleDateFormat sysForm = new SimpleDateFormat ("yyyy/MM/DD HH:mm:ss");  Date curdate= new Date();  System.out.println(sysForm.format(curdate));  }  }  The best way to brush up your Java knowledge is to open up an eclipse and write loads of codes and sample programs. Get into the habit of remembering syntaxes and applying the best coding standards possible. www.GarudaTrainings.com