Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Sample Oral Questions: JAVA Programming TY Btech CSE

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Sample Oral Questions

JAVA Programming

TY Btech CSE

1) Which are the features of Java?


• Simple and Familiar
• Compiled and Interpreted
• Platform Independent
• Portable
• Architectural Neutral
• Object-Oriented
• Robust
• Secure
• Distributed
• Multi-threaded and Interactive
• High Performance
• Dynamic and Extensible

2) What is JVM?
JVM (Java Virtual Machine) is an abstract machine. It is a
specification that provides runtime environment in which java
bytecode can be executed.

3) What is JIT Compiler?


A just-in-time (JIT) compiler is a program that turns bytecode into instructions that can
be sent directly to a computer's processor (CPU).

4) What is Hotspot in java?


HotSpot is a technology that makes Java programs run faster. Quite a bit
faster
It’s built into Java virtual machine - both JDK and JRE versions use it. HotSpot
starts automatically with every Java program. It observes the patterns in the
running program’s behaviour, and optimizes the most used parts (“hot
spots”) on the fly by converting them directly into machine code
5) What is Byte code?
Byte Code can be defined as an intermediate code generated by the
compiler after the compilation of source code(JAVA Program). This
intermediate code makes Java a platform-independent language.

6) How to set path in Java?


Open the command prompt
Copy the path of the JDK/bin directory
Write in command prompt: set path=copied_path

7) Which are the differences between Java and C++?


C++ uses only compiler, whereas Java uses compiler and interpreter both.
C++ supports both operator overloading & method
overloading whereas Java only supports method overloading.
C++ supports structures whereas Java doesn’t supports structures.
C++ supports unions while Java doesn’t support unions.

8) Which types of applications developed from Java?


• Desktop GUI Applications
• Mobile Applications
• Enterprise Applications
• Scientific Applications
• Web-based Applications
• Embedded Systems
• Big Data Technologies
• Distributed Applications
• Cloud-based Applications
• Web servers and Application servers
• Software Tools
• Gaming Applications

9) Which are data types in java?


In Java, we have eight primitive data types: boolean, char,
byte, short, int, long, float and double.

10) What is IDE? Give few names


An integrated development environment (IDE) is a software application that
provides comprehensive facilities to computer programmers for software
development.Example. VSCODE,Eclips,pycharm,netbeans
11) What is variable? How it is declared and initialized in java
Variable in Java is a data container that saves the data values
during Java program execution. Every variable is assigned a data
type that designates the type and quantity of value it can hold.
Variable is a memory location name of the data.
A variable is a name given to a memory location. It is the basic
unit of storage in a program.

12) Which are the types of operators in java?


• Arithmetic Operators.
• Assignment Operators.
• Relational Operators.
• Logical Operators.
• Unary Operators.
• Bitwise Operators.

13) How to take input from user in java?

Java Scanner class allows the user to take input from the console. It belongs
to java.util package. It is used to read the input of primitive types like int, double,
long, short, float, and byte. It is the easiest way to read input in Java program.
Scanner sc=new Scanner(System.in);

14) Whether printf () statement allowed in java?


YES Allowed
Formatting output using System.out.printf()
This is the easiest of all methods as this is similar to printf in C. Note
that System.out.print() and System.out.println() take a single
argument, but printf() may take multiple arguments.

15) What is Arrays in java?


Java array is an object which contains elements of a similar data
type. Additionally, The elements of an array are stored in a contiguous
memory location. It is a data structure where we store similar
elements. We can store only a fixed set of elements in a Java array.
16) What is Array of objects in java?
The array of Objects the name itself suggests that it stores an array
of objects. Unlike the traditional array stores values like String,
integer, Boolean, etc an Array of Objects stores objects that mean
objects are stored as elements of an array

17) What is this keyword?


The this keyword refers to the current object in a method or
constructor.
The most common use of the this keyword is to eliminate the confusion
between class attributes and parameters with the same name (because
a class attribute is shadowed by a method or constructor parameter).

18) What is class?


A class is a group of objects which have common properties. It is a
template or blueprint from which objects are created. It is a logical
entity. It can't be physical.

19) What are objects?


An object is an instance of a class. A class is a template or blueprint
from which objects are created. So, an object is the instance(result) of a
class.

20) How the objects are created?


An object is created based on its class. ... When an object is
created, memory is allocated to hold the object properties. An object
reference pointing to that memory location is also created.

21) What is a literal in java?


Literal in Java is a synthetic representation of boolean, numeric,
character, or string data. It is a means of expressing particular
values in the program,

22) Which are the types of literals in java?


• Integral Literals. Floating-point Literals.
• Char Literals. String Literals.
• Boolean Literals. Null Literals.
23) Which are the keywords in java?
abstract continue for new switch
assert*** default goto* package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum**** instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp** volatile
const* float native super while

24) What is instance variable?


o The variables that are declared inside the class but outside the scope of
any method are called instance variables in Java.
o The instance variable is initialized at the time of the class loading or when
an object of the class is created

25) What is local variable?


o Variables that are declared within or inside a function block are known
as Local variables.
o These variables can only be accessed within the function in which they are
declared.

26) What is constructor?


Constructor is a block of code used to initialize objects. NOTE:
... Constructor name is same as class name. Constructor is called
when an object of a classs is created. Access modifiers applicable for
constructors are public, private, protected and default.

27) Which are different types of constructors?


Constructor Types
• Default Constructor.
• Parameterized Constructor.
• Copy Constructor.
• Static Constructor.
• Private Constructor.
28) What is use of static in main () method?
The static is a keyword which we use in the main() method to define
it as static. There is no object of the class available at the time of
starting java runtime, and because of that, we have to define the
main() method as static. By doing that, JVM can load the class into
the main memory and call the main() method.

29) What is static variable?


The static keyword in Java is used for memory management mainly.
We can apply static keyword with variables, methods, blocks
and nested classes. The static keyword belongs to the class than an
instance of the class.

30) What is static method?


Static methods are the methods in Java that can be called without
creating an object of class. They are referenced by the class name
itself or reference to the Object of that class.

31) What is the use of super keyword in java?


super keyword is used to access methods of the parent
class while this is used to access methods of the current class.

32) What is interface?


An interface in Java is syntactically similar to a class but can have
only abstract methods declaration and constants as members. In other
words, an interface is a collection of abstract methods and
constants (i.e. static and final fields). It is used to achieve complete
abstraction.

33) What is inheritance?


Inheritance in Java is a concept that acquires the properties from
one class to other classes; for example, the relationship between
father and son. In Java, a class can inherit attributes and methods
from another class. The class that inherits the properties is known as
the sub-class or the child class
34) Which are the different types of inheritance supported in java?
Types of inheritance in Java: Single,Multiple,Multilevel & Hybrid.

35) Whether multiple inheritance is supported in java?


Java doesn't support multiple inheritance but implicitly every
class in java extends Object and allows one more [duplicate] Closed 6
years ago. In Java, all classes are extending Object class implicitly ,
on top of that at max only one class can be inherited.

36) What is method overloading in java?


Method overloading in java is based on the number and type of the
parameters passed as an argument to the methods. We can not
define more than one method with the same name, Order, and type of
the arguments. It would be a compiler error.

37) What is method overriding in java?


If subclass (child class) has the same method as declared in the
parent class, it is known as method overriding in Java. In other
words, If a subclass provides the specific implementation of the
method that has been declared by one of its parent class, it is
known as method overriding.

38) What is the use of final keyword in java?


When a class is made final, a sublcass of it can not be created
When a method is final, it can not be overridden.

When a variable is final, it can be assigned value only once.

39) What is abstract class?


An abstract class, in the context of Java, is a superclass that
cannot be instantiated and is used to state or define general
characteristics. An object cannot be formed from a Java
abstract class; trying to instantiate an abstract class only
produces a compiler error.
40) What are abstract methods?
Abstract methods are those types of methods that don't require
implementation for its declaration. These methods don't have a
body which means no implementation. A few properties of an abstract
method are: An abstract method in Java is declared through the
keyword “abstract”

41) What is nested class?


The Java programming language allows you to define a class within another
class. Such a class is called a nested

42) What is garbage collection in java?


Garbage collection refers to the process of automatically freeing
memory on the heap by deleting objects that are no longer
reachable in your program. The heap is a memory which is referred
to as the free store, represents a large pool of unused memory
allocated to your Java application.

43) What is package in java?


Package in Java is a mechanism to encapsulate a group of classes,
sub packages and interfaces
Java package is a mechanism of grouping similar types of classes,
interfaces, and sub-classes collectively based on functionality. When
software is written in the Java programming language, it can be
composed of hundreds or even thousands of individual classes.

44) How the package is created?


To create a package, you choose a name for the package put a
package statement with that name at the top of every source
file that contains the types (classes, interfaces, enumerations, and
annotation types) that you want to include in the package.

45) What is exception in java?


In Java “an event that occurs during the execution of a program
that disrupts the normal flow of instructions” is called an exception

46) Which are the types of exceptions in java?


1] Checked exception 2] Unchecked exception.
47) Which are the Advantages of exceptions?
Exceptions provide the means to separate the details of what to do
when something out of the ordinary happens from the main logic
of a program. In traditional programming, error detection, reporting,
and handling often lead to confusing spaghetti code.

48) What is multithreading in java?


Multithreading is a Java feature that allows concurrent execution of
two or more parts of a program for maximum utilization of CPU.
Each part of such program is called a thread. So, threads are light-
weight processes within a process.

49) What is swing?


Java Swing tutorial is a part of Java Foundation Classes (JFC) that
is used to create window-based applications. It is built on the top of
AWT (Abstract Windowing Toolkit) API and entirely written in java.

50) What is JSP?


• It stands for Java Server Pages.
• It is a server side technology.
• It is used for creating web application.
• It is used to create dynamic web content.
• In this JSP tags are used to insert JAVA code into HTML
pages.
• It is an advanced version of Servlet Technology.

51) What is servlet?


Servlets are the Java programs that run on the Java-enabled web
server or application server. They are used to handle the request
obtained from the webserver, process the request, produce the
response, then send a response back to the webserver.

52) Who discovered Java language? When? Where?


James Gosling at Sun Microsystems and released in May 1995
53) Which are the built in packages in java?
There are many built-in packages such as java, lang, awt, javax,
swing, net, io, util, sql etc.

54) What is user defined packages?


User-defined packages are those packages that are designed or
created by the developer to categorize classes and packages. It
can be imported into other classes and used the same as we use built-
in packages

55) Which are rules for declaring identifier in java?


o A valid identifier must have characters [A-Z] or [a-z] or numbers [0-9],
and underscore(_) or a dollar sign ($). for example, @javatpoint is not a
valid identifier because it contains a special character which is @.
o There should not be any space in an identifier. For example, java tpoint is
an invalid identifier.
o An identifier should not contain a number at the starting. For example,
123javatpoint is an invalid identifier.
o An identifier should be of length 4-15 letters only. However, there is no
limit on its length. But, it is good to follow the standard conventions.
o We can't use the Java reserved keywords as an identifier such as int, float,
double, char, etc. For example, int double is an invalid identifier in Java.
o An identifier should not be any query language keywords such as SELECT,
FROM, COUNT, DELETE, etc.
56) Which are differences between Java and C language?

C Java

C was developed by Dennis M. Java was developed by James


Ritchie between 1969 and 1973. Gosling in 1995.

C is a Procedural Programming
Language. Java is Object-Oriented language.

C is more procedure-oriented. Java is more data-oriented.

C is a middle-level language. Java is a high-level language

C is a compiled language that is Java is an Interpreted language that


it converts the code into machine is in Java, the code is first
language so that it could be transformed into bytecode and that
understood by the machine or bytecode is then executed by the
system. JVM (Java Virtual Machine).

C generally breaks down to


functions. Java breaks down to Objects.

C programming language can be


used for system programming as
well as Application programming. This is not the case in Java.

Subject In charge

Prof.A.H.Pudale

You might also like