0% found this document useful (0 votes)
328 views3 pages

BCSL-043 Viva

Uploaded by

banif19483
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
328 views3 pages

BCSL-043 Viva

Uploaded by

banif19483
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

BCSL-043 : JAVA PROGRAMMING LAB

1. What are the features of Java ?


It has many features like:
Object Oriented, Compiled and Interpreted, platform independent, Secure, Strongly typed, distributed,
multi-threaded, robust.
2. What is JVM ?
JVM stands for Java Virtual machine. It works as an interpreter. Because of JVM, it is platform
independent.
3. What is byte code ?
When we compile java program, compiler gives a class file which is basically in byte code which can
only be understood by JVM.
4. Is JVM part of JDK (Java Development Kit) or JRE (Java Runtime Environment) ?
JVM is part of JRE (Java Runtime Environment).
5. What is Application and Applet ?
We can write two types of programs i.e. applications and applets, in java.
Applications are the programs which has CUI (Character User Interface), main method and executed
without web browser.
Applets are the programs which has GUI (Graphical User Interface), has its own life cycle and executed
using web browser.
6. Is java a case sensitive language ?
Yes
7. Which character set is supported by java ?
Java supports UNICODE, that is why in java, charcter takes 2 bytes to store.
Data types and memory consumption :
char : 2 bytes
int : 4 bytes
long : 8 bytes
float : 4 bytes
double : 8 bytes
8. Why main method is written as public static void main ( String args [ ] ) ?
public is an access specifier is used because program is called from operating system.
static is used so that main method will be called using class name.
void is data type used because main method do not return any value.
main is used because execution starts from the class where main is enclosed.
String is a class.
args [ ] is an array of strings to accept command line arguments.
9. What is :
Encapsulation: Process of Binding data members and related methods (functions).
Data Hiding: Process of suppressing unwanted details.
Data Abstraction: Process of providing important details.
Polymorphism: Process of using single name or operator for multiple purposes.
Inheritance: Process of transferring properties of existing class to form new class.
10. What is Class and Object ?
Collection of objects having similar properties is called as class. Ex: Student
Instance of class is called as object. Ex: Amit is an object of class student.
11. What is method overloading and method overriding ?
Declaring multiple methods in a class, with same name having different parameter list is called as
method overloading.
Re-defining a method, available in base class, in derived class is called as method overriding. Method
definition should be same.
12. What is abstract class ?
Abstract class is used as a base class. Objects are not formed for this class.
13. Types of polymorphism :
Compile time polymorphism: When binding is done at compile time. Ex: Method overloading, operator
overloading. Also called as static polymorphism.
Run time polymorphism: When binding is done at run time. It is implemented using Dynamic method
despatch.
14. What are constructors and destructors ?
Constructors are special methods used to initialize data members of an object. Automatically executed
at the time of object creation. Name is same as of class. No return value.
Multiple constructors can be designed for a class i.e. Non parameterized, Parameterised.
Destructors are not available in java. finalise ( ) method is used in java.
15. What is Exception handling ?
Runtime error caused due to some wrong input, is called as Exception. Ex: Divide by zero error.
Exceptions are handled using try, catch, throw, throws and finally.
16. Why super keyword is used ?
super is used to refer immediate parent class.
17. Does java supports multiple inheritance ?
No, but can be implemented using interface.
class will be inherited using extends keyword and
interface will be inherited using implements keyword.
18. What is a thread ? How can it be implemented ?
thread is used to run a subtask or we can say for implementing multi-threading.
To implement a thread we can use Thread class or Runnable interface.
19. What is the difference between class and interface ?
interface is similar to class but with some differences :
data members in interface are by default final (constant or say fixed i.e. can’t be changed)
methods do not have body and should be overridden.
For practical in sheet :
Sample java program: (using notepad)
class Demo {
public static void main( String args[ ] ) {
int n=5 , p=1 , i ;
for( i=1 ; i <= n ; i++ ) {
p=p*i; }
System.out.println ( “Factorial is “ + p );
}
}
Save : Demo.java
Complie : javac Demo.java
Run : java Demo

Output will be : Factorial is 120

You might also like