Java Questions For Viva3
Java Questions For Viva3
Home
Explore
Search
Submit Search
Upload
Login
Signup
Home
Explore
Login
Signup
Search
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 1/20
11/30/21, 3:08 PM Java questions for viva
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 2/20
11/30/21, 3:08 PM Java questions for viva
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 3/20
11/30/21, 3:08 PM Java questions for viva
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 4/20
11/30/21, 3:08 PM Java questions for viva
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 5/20
11/30/21, 3:08 PM Java questions for viva
Upcoming SlideShare
Loading in …5
×
2 of 6
1
of 6
Next SlideShares
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 6/20
11/30/21, 3:08 PM Java questions for viva
Upcoming SlideShare
Basic java important interview questions and answers to secure a job
Next
Download Now
Download to read offline and view in fullscreen.
Education
Dec. 16, 2014
35,631 views
49 Likes
Share
Download Now
Download
Education
Dec. 16, 2014
35,631 views
Read more
Vipul Naik
Follow
Head
at
S.S.samiti's Higher Sec. School, Kavalem ponda
Recommended
Java programming-examples
Mumbai Academisc
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 7/20
11/30/21, 3:08 PM Java questions for viva
Java codes
Hussain Sherwani
Related Books
See all
Carousel previous
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 8/20
11/30/21, 3:08 PM Java questions for viva
Fighting Forward: Your Nitty-Gritty Guide to Beating the Lies That Hold You Back
Hannah Brencher
(0/5)
Free
No One Succeeds Alone: Learn Everything You Can from Everyone You Can
Robert Reffkin
(4/5)
Free
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 9/20
11/30/21, 3:08 PM Java questions for viva
Dry: A Memoir
Augusten Burroughs
(4.5/5)
Free
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 10/20
11/30/21, 3:08 PM Java questions for viva
Girl, Stop Apologizing: A Shame-Free Plan for Embracing and Achieving Your Goals
Rachel Hollis
(3.5/5)
Free
Maybe You Should Talk to Someone: A Therapist, HER Therapist, and Our Lives Revealed
Lori Gottlieb
(4.5/5)
Free
Uninvited: Living Loved When You Feel Less Than, Left Out, and Lonely
Lysa TerKeurst
(4.5/5)
Free
Girl, Wash Your Face: Stop Believing the Lies About Who You Are so You Can Become Who You Were Meant to Be
Rachel Hollis
(3.5/5)
Free
Boundaries Updated and Expanded Edition: When to Say Yes, How to Say No To Take Control of Your Life
Henry Cloud
(4/5)
Free
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 11/20
11/30/21, 3:08 PM Java questions for viva
1 2 3 4
Related Audiobooks
See all
Carousel previous
My Friend Fear: How to Move Through Social Anxiety and Embrace the Life You Want
Rose Berry
(5/5)
Free
A Body to Love: Cultivate Community, Body Positivity, and Self-Love in the Age of Social Media
Angelina Caruso
(5/5)
Free
Getting More Done: Wielding Intention and Planning to Achieve Your Most Ambitious Goals
Michelle Loucadoux
(4.5/5)
Free
The Power of Your Attitude: 7 Choices for a Happy and Successful Life
Stan Toler
(4.5/5)
Free
Power, for All: How It Really Works and Why It's Everyone's Business
Julie Battilana
(4.5/5)
Free
The Full Spirit Workout: A 10-Step System to Shed Your Self-Doubt, Strengthen Your Spiritual Core, and Create a Fun & Fulfilling Life
Kate Eckman
(4/5)
Free
Checking In: How Getting Real about Depression Saved My Life---and Can Save Yours
Michelle Williams
(4.5/5)
Free
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 12/20
11/30/21, 3:08 PM Java questions for viva
1 2 3 4
49 Likes
Statistics
Notes
HarshSen7
2 months ago
telugutechworld1
2 months ago
ShaileshYadav753013
2 months ago
HarshitTinkar
3 months ago
Matchless Bilal
9 months ago
Bhargavreddy147
9 months ago
Aswathy M B
9 months ago
Josh Josh
10 months ago
AkshayPokharkar5
11 months ago
AviralAgarwal34
12 months ago
Vinod Kumar
1 year ago
NaomiNan
1 year ago
Deepthi Narayana
1 year ago
Reshma Bharath
2 years ago
Masudadmad
2 years ago
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 13/20
11/30/21, 3:08 PM Java questions for viva
pidugusrinivasu
2 years ago
Srikanth Thumma
2 years ago
BijayaLaxmi7
2 years ago
Himanshu Sharma
2 years ago
Pragya Rawat
2 years ago
Show More
Views
Total views
35,631
On SlideShare
0
From Embeds
0
Number of Embeds
64
Actions
Shares
0
Downloads
609
Comments
0
Likes
49
No notes for slide
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 14/20
11/30/21, 3:08 PM Java questions for viva
When throws keyword is used?
A: If a method does not handle a checked exception, the method must declare it using the throwskeyword. The throws
keyword appears
at the end of a method's signature.
32. Q: When throw keyword is used?
A: An exception can be thrown, either a newly instantiated one or an
exception that you just caught, by using throw keyword.
33. Q: How finally used under Exception Handling?
A: The finally keyword is used to create a block
of code that follows a try block. A finally block of code always executes, whether or not an
exception has occurred.
34. Q: Define Inheritance?
A: It is the
process where one object acquires the properties of another. With the use of inheritance the information is made manageable
in a hierarchical order.
35. Q:
When super keyword is used?
A: If the method overrides one of its superclass's methods, overridden method can be invoked through the use of the keyword
super. It
can be also used to refer to a hidden field
36. Q: What is Polymorphism?
A: Polymorphism is the ability of an object to take on many forms. The most
common use of polymorphism in OOP occurs when a parent
class reference is used to refer to a child class object.
37. Q: What is Abstraction?
A: It refers to
the ability to make a class abstract in OOP. It helps to reduce the complexity and also improves the maintainability of the
system.
38. Q: What is Abstract class
A: These classes cannot be instantiated and are either partially implemented or not at all implemented. This class contains one or more
abstract methods which
are simply method declarations without a body.
39. Q: When Abstract methods are used?
A: If you want a class to contain a particular method but you want
the actual implementation of that method to be determined by child
classes, you can declare the method in the parent class as abstract.
40. Q: What is
Encapsulation?
A: It is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared
private,
it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. Therefore encapsulation is also
referred to as data hiding.
41. Q:
What is the primary benefit of Encapsulation?
A: The main benefit of encapsulation is the ability to modify our implemented code without breaking the code
of others who use our code.
With this Encapsulation gives maintainability, flexibility and extensibility to our code.
3. 3.
42. Q: What is an Interface?
A: An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of
the
interface.
43. Q: Give some features of Interface?
A: It includes:
Interface cannot be instantiated
An interface does not contain any constructors.
All of the
methods in an interface are abstract.
44. Q: Define Packages in Java?
A: A Package can be defined as a grouping of related types(classes, interfaces,
enumerations and annotations ) providing access
protection and name space management.
45. Q: Why Packages are used?
A: Packages are used in Java in-
order to prevent naming conflicts, to control access, to make searching/locating and usage of classes,
interfaces, enumerations and annotations, etc., easier.
46.
Q: What do you mean by Multithreaded program?
A: A multithreaded program contains two or more parts that can run concurrently. Each part of such a
program is called a thread, and
each thread defines a separate path of execution.
47. Q: What are the two ways in which Thread can be created?
A: Thread can
be created by: implementing Runnable interface, extending the Thread class.
48. Q: What is an applet?
A: An applet is a Java program that runs in a Web
browser. An applet can be a fully functional Java application because it has the entire
Java API at its disposal.
49. Q: An applet extend which class?
A: An
applet extends java.applet.Applet class.
50. Q: Explain garbage collection in Java?
A: It uses garbage collection to free the memory. By cleaning those objects
that is no longer reference by any of the program.
51. Q: Define immutable object?
A: An immutable object can’t be changed once it is created.
52. Q: Explain
the usage of this() with constructors?
A: It is used with variables or methods and used to call constructer of same class.
53. Q: Explain Set Interface?
A: It is a
collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection
and adds the restriction that
duplicate elements are prohibited.
54. Q: Explain TreeSet?
A: It is a Set implemented when we want elements in a sorted order.
55. Q: What is Comparable
Interface?
A: It is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the
Comparable interface can be ordered.
56. Q: Difference between throw and throws?
A: It includes:
Throw is used to trigger an exception where as throws is
used in declaration of exception.
Without throws, Checked exception cannot be handled where as checked exception can be propagated with throws.
57. Q:
Explain the following line used under Java Program:
public static void main (String args[ ])
A: The following shows the explanation individually:
public: it is
the access specifier.
static: it allows main() to be called without instantiating a particular instance of a class.
4. 4.
void: it affirns the compiler that no value is returned by main().
main(): this method is called at the beginning of a Java program.
String args[ ]: args
parameter is an instance array of class String
58. Q: Define JRE i.e. Java Runtime Environment?
A: Java Runtime Environment is an implementation of the
Java Virtual Machine which executes Java programs. It provides the minimum
requirements for executing a Java application;
59. Q: What is JAR file?
A: JAR
files is Java Archive fles and it aggregates many files into one. It holds Java classes in a library. JAR files are built on ZIP file
format and have .jar file
extension.
60. Q: What is a WAR file?
A: This is Web Archive File and used to store XML, java classes, and JavaServer pages. which is used to distribute a
collection of
JavaServer Pages, Java Servlets, Java classes, XML files, static Web pages etc.
61. Q: Define JIT compiler?
A: It improves the runtime
performance of computer programs based on bytecode.
62. Q: What is the difference between object oriented programming language and object based
programming language?
A: Object based programming languages follow all the features of OOPs except Inheritance. JavaScript is an example of object based
programming languages
63. Q: What is the purpose of default constructor?
A: The java compiler creates a default constructor only if there is no constructor in
the class.
64. Q: Can a constructor be made final?
A: No, this is not possible.
65. Q: What is static block?
A: It is used to initialize the static data member, It is
excuted before main method at the time of classloading.
66. Q: Define composition?
A: Holding the reference of the other class within some other class is
known as composition.
67. Q: What is function overloading?
A: If a class has multiple functions by same name but different parameters, it is known as
Method Overloading.
68. Q: What is function overriding?
A: If a subclass provides a specific implementation of a method that is already provided by its parent
class, it is known as Method
Overriding.
69. Q: Difference between Overloading and Overriding?
A: Method overloading increases the readability of the
program. Method overriding provides the specific implementation of the method
that is already provided by its super class parameter must be different in case
of overloading, parameter must be same in case of
overriding.
70. Q: What is final class?
A: Final classes are created so the methods implemented by that class
cannot be overridden. It can’t be inherited.
71. Q: What is NullPointerException?
A: A NullPointerException is thrown when calling the instance method of a
null object, accessing or modifying the field of a null object etc.
72. Q: What are the ways in which a thread can enter the waiting state?
A: A thread can enter
the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an
object's lock, or by invoking an object's wait()
method. It can also enter the waiting state by invoking its (deprecated) suspend() method.
73. Q: How does multi-threading take place on a computer with a
single CPU?
A: The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it
creates the
impression that tasks execute sequentially.
74. Q: What invokes a thread's run() method?
A: After a thread is started, via its start() method of the Thread class,
the JVM invokes the thread's run() method when the thread is
initially executed.
75. Q: Does it matter in what order catch statements for
FileNotFoundException and IOException are written?
A: Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses
have to be caught first.
76. Q: What is the difference between yielding and sleeping?
A: When a task invokes its yield() method, it returns to the ready state.
When a task invokes its sleep() method, it returns to the waiting
state.
77. Q: Why Vector class is used?
5. 5.
A: The Vector class provides the capability to implement a growable array of objects. Vector proves to be very useful if you don't know
the size of the array
in advance, or you just need one that can change sizes over the lifetime of a program.
78. Q: How many bits are used to represent Unicode, ASCII, UTF-16,
and UTF-8 characters?
A: Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8
bits.
UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.
79. Q: What are Wrapper classes?
A: These are
classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.
80. Q: What is the difference between a
Window and a Frame?
A: The Frame class extends Window to define a main application window that can have a menu bar.
81. Q: Which package has light
weight components?
A: javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.
82. Q:
What is the difference between the paint() and repaint() methods?
A: The paint() method supports painting via a Graphics object. The repaint() method is used
to cause paint() to be invoked by the AWT
painting thread.
83. Q: What is the purpose of File class?
A: It is used to create objects that provide access to the
files and directories of a local file system.
84. Q: What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class
hierarchy?
A: The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.
85. Q: Which class
should you use to obtain design information about an object?
A: The Class class is used to obtain information about an object's design and java.lang.Class
class instance represent classes, interfaces
in a running Java application.
86. Q: What is the difference between static and non-static variables?
A: A static
variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on
unique values with each object
instance.
87. Q: What is Serialization and deserialization?
A: Serialization is the process of writing the state of an object to a byte stream. Deserialization is the
process of restoring these objects.
88. Q: Can you write a Java class that could be used both as an applet as well as an application?
A: Yes, just add a main()
method to the applet.
89. Q: What is the difference between Swing and AWT components?
A: AWT components are heavy-weight, whereas Swing
components are lightweight. Heavy weight components depend on the local
windowing toolkit. For example, java.awt.Button is a heavy weight component,
when it is running on the Java platform for Unix platform, it
maps to a real Motif button.
90. Q: What's the difference between constructors and other
methods?
A: Constructors must have the same name as the class and can not return a value. They are only called once while regular methods
could be called
many times.
91. Q: Is there any limitation of using Inheritance?
A: Yes, since inheritance inherits everything from the super class and interface, it may make
the subclass too clustering and sometimes
error-prone when dynamic overriding or dynamic overloading in some situation.
92. Q: What's the difference
between the methods sleep() and wait()?
A: The code sleep(2000); puts thread aside for exactly two seconds. The code wait(2000), causes a wait of up to two
second. A thread
could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method
sleep()
is defined in the class Thread.
93. Q: When ArithmeticException is thrown?
A: The ArithmeticException is thrown when integer is divided by zero or taking
the remainder of a number by zero. It is never thrown in
floating-point operations.
94. Q: What is the Collections API?
A: The Collections API is a set of
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 15/20
11/30/21, 3:08 PM Java questions for viva
classes and interfaces that support operations on collections of objects.
95. Q: Does garbage collection guarantee that a program will not run out of memory?
A: Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory
resources faster than they
are garbage collected. It is also possible for programs to create objects that are not subject to garbage
collection.
96. Q: What is the difference between a break
statement and a continue statement?
A: A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue
statement is used
to end the current loop iteration and return control to the loop statement.
97. Q: If a variable is declared as private, where may the variable be
accessed?
A: A private variable may only be accessed within the class in which it is declared.
6. 6.
98. What is JVM ? Why is Java called the “Platform Independent Programming Language” ? A Java virtual
machine (JVM) is a process virtual machine
that can execute Java bytecode. Each Java source file is
compiled into a bytecode file, which is executed by the JVM. Java was designed to allow application
programs
to be built that could be run on any platform, without having to be rewritten or recompiled by the programmer
for each separate platform. A Java
virtual machine makes this possible, because it is aware of the specific
instruction lengths and other particularities of the underlying hardware platform.
99.
What is the Difference between JDK and JRE ? The Java Runtime Environment (JRE) is basically the Java
Virtual Machine (JVM) where your Java programs
are being executed. It also includes browser plugins for
applet execution. The Java Development Kit (JDK) is the full featured Software Development Kit for
Java,
including the JRE, the compilers and tools (like JavaDoc, and Java Debugger), in order for a user to develop,
compile and execute Java applications.
100. Explain the available thread states in a high-level. During its execution, a thread can reside in one
of the following states:
Runnable: A thread becomes
ready to run, but does not necessarily start running immediately.
Running: The processor is actively executing the thread code.
Waiting: A thread is in a
blocked state waiting for some external processing to finish.
Sleeping: The thread is forced to sleep.
Blocked on I/O: Waiting for an I/O operation to complete.
Blocked on Synchronization: Waiting to acquire a lock.
Dead: The thread has finished its execution.
Recommended
Java programming-examples
Mumbai Academisc
Java codes
Hussain Sherwani
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 16/20
11/30/21, 3:08 PM Java questions for viva
HarshSen7
telugutechworld1
ShaileshYadav753013
HarshitTinkar
Aug. 5, 2021
MatchlessBilal
Mar. 4, 2021
Bhargavreddy147
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 17/20
11/30/21, 3:08 PM Java questions for viva
Feb. 28, 2021
AswathyMB3
JoshJosh37
AkshayPokharkar5
Dec. 9, 2020
AviralAgarwal34
Dec. 2, 2020
VinodRajput7
NaomiNan
DeepthiNarayana
Jan. 7, 2020
ReshmaPoojary5
Nov. 8, 2019
Masudadmad
pidugusrinivasu
SrikanthThumma3
BijayaLaxmi7
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 18/20
11/30/21, 3:08 PM Java questions for viva
Jun. 27, 2019
HimanshuSharma1401
Jun. 6, 2019
PragyaRawat2
Views
Total views
35,631
On Slideshare
From embeds
Number of embeds
64
Actions
Downloads
609
Shares
Comments
Likes
49
About
Support
Terms
Privacy
Copyright
English
English
Español
Português
Français
Deutsch
Share Clipboard
Facebook
Twitter
LinkedIn
Link
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 19/20
11/30/21, 3:08 PM Java questions for viva
Public clipboards featuring this slide
Create a clipboard
Name*
Best of Slides
Description
Add a brief description so oth
Visibility
Others can see my Clipboard
Cancel
Save
Special Offer to SlideShare Readers
×
https://www.slideshare.net/VipulNaik2/java-questions-for-viva 20/20