Java Viva Questions - Coders Lodge
Java Viva Questions - Coders Lodge
Java Viva Questions - Coders Lodge
VIVA QUESTIONS
1. All these questions are important for examination and interview point
of view, so practice them well.
2. If you have any doubt or facing any problem regarding these questions
you can mail us at [email protected] or drop a message
in our WhatsApp or telegram group.
3. If you want to support us, give your valuable feedback so that next
time we can improve while interacting with you.
4. Reminder-Practice all questions well it will build your concept clear
and you can easily score good in your exams.
Connect with us
• If you want to join our WhatsApp community then mail us at: -
[email protected]
• Join our Telegram group: - https://t.me/coderslodgeofficial
• Like our Facebook page: - https://www.facebook.com/coderslodge
• Follow us on Instagram:- https://www.instagram.com/coderslodge/
• Follow us on Twitter: - https://twitter.com/CodersLodge
• Follow us on LinkedIn:- https://www.linkedin.com/company/coderslodge
1. Why is Java a platform independent language?
Java language was developed in such a way that it does not depend
on any hardware or software due to the fact that the compiler
compiles the code and then converts it to platform-independent
byte code which can be run on multiple systems.
The only condition to run that byte code is for the machine to
have a runtime environment (JRE) installed in it.
Abbreviation Java
Development Java Runtime Java Virtual
Kit Environment Machine
5) String class uses String constant pool. StringBuffer uses Heap memory
No,you can’t.As you know static variable are at class level not at
object level and you serialize a object so you can’t serialize static
variables.
23. What is wrapper class?
The wrapper class in Java provides the mechanism to convert
primitive into object and object into primitive.
24. What is inner class?
Java inner class or nested class is a class that is declared inside the
class or interface.
We use inner classes to logically group classes and interfaces in one
place to be more readable and maintainable.
Additionally, it can access all the members of the outer class,
including private data members and methods.
25. What is package?
A java package is a group of similar types of classes, interfaces and
sub-packages.
Package in java can be categorized in two form, built-in package and
user-defined package.
There are many built-in packages such as java, lang, awt, javax,
swing, net, io, util, sql etc.
26. What is use of super keyword in java?
The super keyword in Java is a reference variable which is used to
refer immediate parent class object.
Whenever you create the instance of subclass, an instance of parent
class is created implicitly which is referred by super reference
variable.
27. What is interface in java?
An interface in Java is a blueprint of a class. It has static constants
and abstract methods.The interface in Java is a mechanism to
achieve abstraction
There can be only abstract methods in the Java interface, not
method body. It is used to achieve abstraction and multiple
inheritance in java.
In other words, you can say that interfaces can have abstract
methods and variables. It cannot have a method body.Java Interface
also represents the IS-A relationship.
28. What is the use of this keyword in java?
The this keyword refers to the current object in a method or
constructor.
29. Briefly tell about multithreading?
Multithreading in Java is a process of executing multiple
threads simultaneously.
A thread is a lightweight sub-process, the smallest unit of
processing. Multiprocessing and multithreading, both are used
to achieve multitasking.
However, we use multithreading than multiprocessing because
threads use a shared memory area. They don't allocate
separate memory area so saves memory, and context-
switching between the threads takes less time than process.
Java Multithreading is mostly used in games, animation, etc.
30. What are advantages of multithreading?
1) It doesn't block the user because threads are independent and
you can perform multiple operations at the same time.
2) You can perform many operations together, so it saves time.
3) Threads are independent, so it doesn't affect other threads if an
exception occurs in a single thread.
31. What is thread synchronization?
Thread synchronization is the concurrent execution of two or more
threads that share critical resources. Threads should be synchronized
to avoid critical resource use conflicts. Otherwise, conflicts may arise
when parallel-running threads attempt to modify a common variable
at the same time.
32. What is difference between Container and Component ?
Main difference between Container and Component is that former
can hold other components e.g. JFrame which is used as container to
hold other components e.g. JButton. This is rather a simple Swing
question and mostly asked in telephonic or upto 2 years experienced
programmers.
3) AWT doesn't support pluggable look Swing supports pluggable look and feel.
and feel.