Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Important Viva Voice Questions for Advance Java Programming Lab from unit 1(a) basics of java

The document provides a comprehensive overview of important Viva Voice questions related to Advance Java Programming, covering key concepts such as JDK, JRE, JVM, and the structure of the main method. It also discusses Java's platform independence, wrapper classes, constructors, and various features of the Java programming language. Additionally, it addresses common misconceptions and clarifies the roles of local and instance variables, static methods, and the nature of objects and classes in Java.

Uploaded by

mayankggn4
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Important Viva Voice Questions for Advance Java Programming Lab from unit 1(a) basics of java

The document provides a comprehensive overview of important Viva Voice questions related to Advance Java Programming, covering key concepts such as JDK, JRE, JVM, and the structure of the main method. It also discusses Java's platform independence, wrapper classes, constructors, and various features of the Java programming language. Additionally, it addresses common misconceptions and clarifies the roles of local and instance variables, static methods, and the nature of objects and classes in Java.

Uploaded by

mayankggn4
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Important Viva Voice Questions for Advance Java Programming Lab

Q1. Explain JDK, JRE and JVM?

JDK JRE JVM

It stands for Java It stands for Java


It stands for Java Virtual Machine.
Development Kit. Runtime Environment.
It is the tool necessary JRE refers to a runtime
It is an abstract machine. It is a specification
to compile, document environment in which
that provides a run-time environment in
and package Java Java bytecode can be
which Java bytecode can be executed.
programs. executed.
It’s an implementation JVM follows three notations:
It contains JRE +
of the JVM which Specification, Implementation, and Runtime
development tools.
physically exists. Instance.

Q2. Explain public static void main(String args[]) in Java.

main() in Java is the entry point for any Java program. It is always written as public static void
main(String[] args).

 public: Public is an access modifier, specify who can access this method. Public means
that this Method will be accessible by any Class.
 static: It is a keyword in java which identifies it is class-based. main() is made static in
Java so that it can be accessed without creating the instance of a Class. In case, main is
not made static then the compiler will throw an error as main() is called by the JVM
before any objects are made and only static methods can be directly invoked via the
class. With the help of class name main() method is called.
 void: It is the return type of the method. Void defines the method which will not return
any value.
 main: It is the name of the method which is searched by JVM as a starting point for an
application.It is the method where the main execution occurs.
 String args[]: It is the parameter passed to the main method to accept user input in String
type Array.

Q3. Why Java is platform independent?

Java is called platform independent because of its byte codes which can run on any operating
system.

Q4. What are wrapper classes in Java?


Wrapper classes convert the Java primitives into the reference types (objects). Every primitive
data type has a class dedicated to it. These are known as wrapper classes because they “wrap” the
primitive data type into an object of that class.

Q5) Is delete, next, main, exit or null keyword in java?

No.

Q6) If I don't provide any arguments on the command line, then what will the value stored
in the String array passed into the main() method, empty or NULL?

It is empty, but not null.

Q7) What if I write static public void instead of public static void?

The program compiles and runs correctly because the order of specifiers doesn't matter in Java.

Q8) What is the default value of the local variables?

The local variables are not initialized to any default value, neither primitives nor object
references.

Q9) Does constructor return any value?

yes, The constructor implicitly returns the current instance of the class (You can't use an explicit
return type with the constructor.

Q10) Is constructor inherited?

No, The constructor is not inherited.

Q11) Can you make a constructor final?

No, the constructor can't be final.

Q12) List the features of Java Programming language.

There are the following features in Java Programming Language.

o Simple: Java is easy to learn. The syntax of Java is based on C++ which makes easier to
write the program in it.
o Object-Oriented: Java follows the object-oriented paradigm which allows us to maintain
our code as the combination of different type of objects that incorporates both data and
behavior.

o Portable: Java supports read-once-write-anywhere approach. We can execute the Java


program on every machine. Java program (.java) is converted to bytecode (.class) which
can be easily run on every machine.

o Platform Independent: Java is a platform independent programming language. It is


different from other programming languages like C and C++ which needs a platform to
be executed. Java comes with its platform on which its code is executed. Java doesn't
depend upon the operating system to be executed.

o Secured: Java is secured because it doesn't use explicit pointers. Java also provides the
concept of ByteCode and Exception handling which makes it more secured.

o Robust: Java is a strong programming language as it uses strong memory management.


The concepts like Automatic garbage collection, Exception handling, etc. make it more
robust.

o Architecture Neutral: Java is architectural neutral as it is not dependent on the


architecture. In C, the size of data types may vary according to the architecture (32 bit or
64 bit) which doesn't exist in Java.

o Interpreted: Java uses the Just-in-time (JIT) interpreter along with the compiler for the
program execution.

o High Performance: Java is faster than other traditional interpreted programming


languages because Java bytecode is "close" to native code. It is still a little bit slower than
a compiled language (e.g., C++).

o Multithreaded: We can write Java programs that deal with many tasks at once by
defining multiple threads. The main advantage of multi-threading is that it doesn't occupy
memory for each thread. It shares a common memory area. Threads are important for
multi-media, Web applications, etc.

o Distributed: Java is distributed because it facilitates users to create distributed


applications in Java. RMI and EJB are used for creating distributed applications. This
feature of Java makes us able to access files by calling the methods from any machine on
the internet.

o Dynamic: Java is a dynamic language. It supports dynamic loading of classes. It means


classes are loaded on demand. It also supports functions from its native languages, i.e., C
and C++.

Q13) what do you understand by Java virtual machine?

Java Virtual Machine is a virtual machine that enables the computer to run the Java program.
JVM acts like a run-time engine which calls the main method present in the Java code. JVM is
the specification which must be implemented in the computer system. The Java code is compiled
by JVM to be a Bytecode which is machine independent and close to the native code.

Q14) what is JAVA?


Java is a high-level programming language and is platform-independent.
Java is a collection of objects. It was developed by Sun Microsystems. There are a lot of
applications, websites, and games that are developed using Java.

Q15) How does Java enable high performance?


Java uses Just In Time compiler to enable high performance. It is used to convert the instructions
into bytecodes.

Q16) Name the Java IDE’s?


Eclipse and NetBeans are the IDE's of JAVA.

Q 17) What do you mean by Constructor?


 When a new object is created in a program a constructor gets invoked corresponding to
the class.
 The constructor is a method which has the same name as the class name.
 If a user doesn’t create a constructor implicitly a default constructor will be created.
 The constructor can be overloaded.
 If the user created a constructor with a parameter then he should create another
constructor explicitly without a parameter.
Q18) What is meant by the Local variable and the Instance variable?
Local variables are defined in the method and scope of the variables existed inside the method
itself.
Instance variable is defined inside the class and outside the method and the scope of the
variables exists throughout the class.

Q19) What is a Class?


Answer: All Java codes are defined in a Class. It has variables and methods.
Variables are attributes which define the state of a class.
Methods It contains a set of statements (or) instructions to satisfy the particular requirement.

Q20)What is an Object?
An instance of a class is called an object. The object has state and behavior.
Whenever the JVM reads the “new()” keyword then it will create an instance of that class.

Q21) Can we overload the constructors?

Yes, the constructors can be overloaded by changing the number of arguments accepted by the
constructor or by changing the data type of the parameters.

Q22) What is the static method?

o A static method belongs to the class rather than the object.


o There is no need to create the object to call the static methods.
o A static method can access and change the value of the static variable.

Q23) What are the restrictions that are applied to the Java static methods?

Two main restrictions are applied to the static methods.

o The static method can not use non-static data member or call the non-static method
directly.
o this and super cannot be used in static context as they are non-static.

Q24) Why is the main method static?

Because the object is not required to call the static method. If we make the main method non-
static, JVM will have to create its object first and then call main() method which will lead to the
extra memory allocation.

Q25) Can we override the static methods?

No, we can't override static methods.

You might also like