0% found this document useful (0 votes)
23 views

Java External Oral

The document provides an overview of various programming concepts in Java, including relational operators, access specifiers, constructors, inheritance types, threading, error handling, and JDBC. It also covers AWT and Swing for GUI development, along with their features and controls. Additionally, it discusses networking concepts such as clients, servers, and proxy servers.

Uploaded by

gadesairaj0
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)
23 views

Java External Oral

The document provides an overview of various programming concepts in Java, including relational operators, access specifiers, constructors, inheritance types, threading, error handling, and JDBC. It also covers AWT and Swing for GUI development, along with their features and controls. Additionally, it discusses networking concepts such as clients, servers, and proxy servers.

Uploaded by

gadesairaj0
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/ 10

1. State any four relational operators and their use.

Operator Meaning
< Less than
> Greater than
<= Less than or
equal to
>= Greater than or
equal to
== Equal to
!= Not equal to
2. Enlist access specifiers in Java.
The access specifiers in java specify accessibility (scope) of a data
member, method, constructor or class. There are 5 types of java access
specifier:
• public
• private
• default (Friendly)
• protected
• private protected
3. Explain constructor with suitable example.
Constructors are used to assign initial value to instance variable of the
class. It has the same name as class name in which it resides and it is
syntactically similar to any method. Constructors do not have return
value, not even ‘void’ because they return the instance if class.
Constructor called by new operator.
Example:
class Rect
{
int length, breadth;
Rect() //constructor
{
length=4; breadth=5;
}
public static void main(String args[])
{
Rect r = new Rect();
System.out.println(“Area : ” +(r.length*r.breadth));
}
}
Output : Area : 20
4. List the types of inheritance which is supported by java.

5. Define thread. Mention 2 ways to create thread.


• Thread is a smallest unit of executable code or a single task is also
called as thread.
• Each tread has its own local variable, program counter and
lifetime.
• A thread is similar to program that has a single flow of control.
There are two ways to create threads in java:
• By extending thread class
Syntax: - class Mythread extends Thread
{
-----
}
• Implementing the Runnable Interface
Syntax: class MyThread implements Runnable
{
public void run()
{
------
}
6. Enlist the logical operators in Java.
• && : Logical AND
• || : Logical OR
• ! : Logical NOT
7. Give the syntax and example for the following functions
Min ( )
Sqrt ( )
Min ()
• Syntax: (Any one of the following)
static int min(int x, int y) Returns minimum of x and y
static long min(long x, long y) Returns minimum of x and y
static float min(float x, float y) Returns minimum of x and y
static double min(double x, int y) Returns minimum of x and y
• Example:
int y= Math.min(64,45);
• ii)Sqrt()
Syntax:
static double sqrt(double arg) Returns square root of arg.
• Example:
double y= Math.sqrt(64);
8. Define the interface in Java.
• Interface is similar to a class.
• It consist of only abstract methods and final variables.
• To implement an interface a class must define each of the method
declared in the interface.
• It is used to achieve fully abstraction and multiple inheritance in
Java.
9. Enlist any four inbuilt packages in Java.
• java.lang
• java.util
• java.io
• java.awt
• java.net
• java.applet
10. Explain any two methods of File Class
1. boolean createNewFile(): It creates a new, empty file named by this
abstract pathname automatically, if and only if no file with the same
name exists. if(file.createNewFile()) System.out.println("A new file is
successfully created.");
2. String getName(): It returns the name of the file or directory denoted
by the object‟s abstract pathname. System.out.println("File name : " +
file.getName());
3. String getParent(): It returns the parent‟s pathname string of the
object‟s abstract pathname or null if the pathname does not name a
parent directory. System.out.println("Parent name : " + file.getParent());
4. boolean isFile(): It returns True if the file denoted by the abstract
pathname is a normal file, and False if it is not a normal file.
System.out.println("File size (bytes) : " + file.isFile()); 5. 5. boolean
canRead(): It returns True if the application can read the file denoted by
the abstract pathname, and returns False otherwise.
System.out.println("Is file readable : " + file.canRead());
6. boolean canWrite(): It returns True if the application can modify the
file denoted by the abstract pathname, and returns False otherwise.
System.out.println("Is file writeable : " + file.canWrite());
7. boolean canExecute(): It returns True if the application can execute
the file denoted by the abstract pathname, and returns False otherwise.
System.out.println("Is file executable : " + file.canExecute());
11. Enlist any four compile time errors.
• Missing semicolon
• Missing of brackets in classes and methods
• Misspelling of variables and keywords.
• Missing double quotes in Strings.
• Use of undeclared variable.
• Incompatible type of assignment/initialization.
• Bad reference to object.
12. Define Constructor. List its types.
• Constructor: A constructor is a special member which initializes an
object immediately upon creation. It has the same name as class name
in which it resides and it is syntactically similar to any method. When a
constructor is not defined, java executes a default constructor which
initializes all numeric members to zero and other types to null or spaces.
Once defined, constructor is automatically called immediately after the
object is created before new operator completes.
• Types of constructors:
• Default constructor
• Parameterized constructor
• Copy constructor
13. Define Class and Object.
• Class: A class is a user defined data type which groups data members
and its associated functions together.
• Object: It is a basic unit of Object Oriented Programming and represents
the real life entities. A typical Java program creates many objects, which
as you know, interact by invoking methods.
14. List the methods of File Input Stream Class
• void close()
• int read()
• int read(byte[] b)
• read(byte[] b, int off, int len)
• int available()
15. Define error. List types of error.
• Errors are mistakes that can make a program go wrong. Errors may be
logical or may be typing mistakes. An error may produce an incorrect
output or may terminate the execution of the program abruptly or even
may cause the system to crash.
• Errors are broadly classified into two categories:
Compile time errors
Runtime errors
16. List any four Java API packages.
• java.lang
• java.util
• java.io
• java.awt
• java.net

• java.applet

17. Define array. List its types.


• An array is a homogeneous data type where it can hold only objects of
one data type.
• Types of Array:
One-Dimensional
Two-Dimensional
18. List access specifiers in Java.
1)public
2)private
3)friendly
4)protected
5)Private Protected
19. List any eight features of Java.
Features of Java:
• Data Abstraction and Encapsulation
• Inheritance
• Polymorphism
• Platform independence
• Portability
• Robust
• Supports multithreading
• Supports distributed applications
• Secure
• Architectural neutral
• Dynamic

20. State use of finalize ( ) method with its syntax.

Use of finalize( ): Sometimes an object will need to perform some action when
it is destroyed. Eg. If an object holding some non java resources such as file
handle or window character font, then before the object is garbage collected
these resources should be freed. To handle such situations java provide a
mechanism called finalization. In finalization, specific actions that are to be
done when an object is garbage collected can be defined. To add finalizer to a
class define the finalize() method. The java run-time calls this method
whenever it is about to recycle an object.
Syntax: protected void finalize() {
}
21. Name the wrapper class methods for the following:
(i) To convert string objects to primitive int.
(ii) To convert primitive int to string objects.
(i) To convert string objects to primitive int:
String str=”5”;
int value = Integer.parseInt(str);
(ii) To convert primitive int to string objects:
int value=5;
String str=Integer.toString(value);

22. List the types of inheritances in Java. (Note: Any four types shall be
considered)
Types of inheritances in Java:
i. Single level inheritance
ii. Multilevel inheritance
iii. Hierarchical inheritance
iv. Multiple inheritance
v. Hybrid inheritance
23. Write the syntax of try-catch-finally blocks
try{
//Statements to be monitored for any exception
}
catch(ThrowableInstance1 obj) {
//Statements to execute if this type of exception occurs
} catch(ThrowableInstance2 obj2) {
//Statements
}finally{
//Statements which should be executed even if any exception happens
}
24. What is an event? How is it handled in Java?
An event is an action or occurrence detected by the program, typically
originating from user input like mouse clicks, keyboard presses, or other
system events. In Java, events are handled through event listeners, which
listen for specific types of events and execute code in response. Java's event
handling mechanism is based on the Observer design pattern, where event
sources generate events, and event listeners handle those events.
25. Define AWT.
AWT (Abstract Window Toolkit) is a set of application programming interfaces
(APIs) provided by Java to create graphical user interfaces (GUIs). It includes
components like buttons, text fields, and windows. AWT uses the underlying
operating system's GUI components, making it less flexible compared to Swing.
26. List the different AWT controls.
Some of the main AWT controls include:
• Button
• Label
• TextField
• TextArea
• Checkbox
• RadioButton
• List
• Choice
• Scrollbar
• Canvas
27. What is a layout manager in Java?
A layout manager is responsible for arranging the components within a
container (like a window or a frame) in Java. It automatically adjusts the size
and position of the components. Some commonly used layout managers
include FlowLayout, BorderLayout, GridLayout, and CardLayout
28. Enumerate key features of Swing.
Swing is a part of Java's Standard Library that provides a more flexible and
powerful way to build graphical user interfaces. Key features include:
• Platform-independent, written entirely in Java.
• Lightweight components (do not rely on the operating system's GUI
components).
• Rich set of controls like JButton, JLabel, JTable, etc.
• Built-in support for pluggable look-and-feel (customizable GUI themes).
• Event-handling using listeners, with support for complex event handling.
• Support for 2D graphics and user interface effects.
29. What is JDBC?
JDBC (Java Database Connectivity) is an API in Java that allows Java
applications to connect to relational databases, execute SQL queries, and
process the results. It provides a standard interface for database interaction.
30. List the four types of JDBC drivers.
The four types of JDBC drivers are:
1. JDBC-ODBC Bridge Driver (Type 1)
2. Native-API Driver (Type 2)
3. Network Protocol Driver (Type 3)
4. Thin Driver (Type 4)
30. Define ODBC.
ODBC (Open Database Connectivity) is an open standard API for accessing
database management systems (DBMS). ODBC allows applications to
communicate with different DBMSs without needing to know the specific
database details.
31. What is the importance of a proxy server?
A proxy server acts as an intermediary between a client and a server. It is used
to:
• Improve security by hiding the client's real IP address.
• Control and monitor internet usage.
• Cache data for faster access.
• Filter content and restrict access to certain websites or services.
32. Define "client" and "server" in networking
• A client is a device or program that requests services or resources from
a server. It is typically a computer or software that connects to a server.
• A server is a device or program that provides services or resources to
clients. It listens for requests from clients and responds accordingly

You might also like