JAVA (1 MARK Q& A)


1.      Define abstract class?
·         A class that is declared using “abstract” keyword is known as abstract class.
·         Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
·         if a class has at least one pure virtual function, then the class becomes abstract.
·         an instance of an abstract class cannot be created
·         an abstract class can contain constructors in Java

2.      Why does the java be a strongly typed language?
·         Java is a strongly typed programming language because every variable must be declared with a data type.
·         A variable cannot start off life without knowing the range of values it can hold, and once it is declared, the data type of the variable cannot change.
·         A strongly typed language compiler enforces strict rules over the operations, what programmer can do, on data types and also passing parameters and return type to a method.
·         An advantage of strongly typed language is it gives consistency over the results 
·         Example: Boolean  hasDataType;
For the rest of its life, hasDataType can only ever have a value of true or false.

3.      Specify default priority value of a thread in Java.
Default priority of a thread is 5 (NORM_PRIORITY).
The value of MIN_PRIORITY is 1 and the value of MAX_PRIORITY is 10.

4.      List out the advantages of exception handling.
4.1.   Separating Error-Handling Code from "Regular" Code- 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
4.2.   Propagating Errors Up the Call Stack- is the ability to propagate error reporting up the call stack of methods.
4.3.   Grouping and Differentiating Error Types

5.      What is the usage of seek in file?
Seek method sets the file-pointer offset, measured from the beginning of this file, at which the next read or write, occurs.

6.      Define socket?
·         A socket is a software object that acts as an end point establishing a bidirectional network communication link between a server-side and a client-side program.

7.      What is JDBC driver?
·         A JDBC driver is a software component enabling a Java application to interact with a database
·         The JDBC driver gives out the connection to the database and implements the protocol for transferring the query and result between client and database.

8.      What is cookie?
·         is a small piece of data sent from a website and stored on the user's computer by the user's web browser while the user is browsing.
·         Cookies were designed to be a reliable mechanism for websites to remember stateful information (such as items added in the shopping cart in an online store) or to record the user's browsing activity (including clicking particular buttons, logging in, or recording which pages were visited in the past).

9.      Define interface?
·         Like a class, an interface can have methods and variables, but the methods declared in interface are by default abstract (only method signature, no body).
·         To declare an interface, use interface keyword. It is used to provide total abstraction- all the methods in interface are declared with empty body and are public and all fields are public, static and final by default.

10.  Give example for events?
·         Changing the state of an object is known as an event.
·         For example, click on button, dragging mouse etc.
·         The java.awt.event package provides many event classes and Listener interfaces for event handling.

11.  What is AWT?
·         Java AWT (Abstract Window Toolkit) is an API to develop GUI or window-based applications in java.
·         Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. AWT is heavyweight i.e. its components are using the resources of OS.
·         The java.awt package provides classes for AWT api such as TextField, Label, TextArea, RadioButton, CheckBox, Choice, List etc.

12.  Mention the purpose of connection interface.
·         A Connection is the session between java application and database.
·          The Connection interface is a factory of Statement, PreparedStatement, and DatabaseMetaData
·         i.e. object of Connection can be used to get the object of Statement and DatabaseMetaData.
·         The Connection interface provide many methods for transaction management like commit(), rollback() etc.

No comments:

Post a Comment