MC7305
MC7305
QUESTION BANK
PART-A (2 MARKS)
UNIT-1
UNIT-2
1) What are the Java Features?
Platform Independence
Object Oriented
Compiler/Interpreter Combo
Robust
Automatic Memory Management
Security
Dynamic Binding
Good Performance
Threading
Built-in Networking
2) What is Data Type ?
Data Types: It has Eight Simple Data types which can be put in four groups, they are:
Integers: byte, short, int, and long for whole valued signed numbers.
Floating-point numbers: float, and double for fractional precision.
Characters: char for representing symbols in character set.
Boolean: boolean a special type for representing true/false.
3) Define Variable ?
Variables: The basic unit of storage in Java Program. And is defined by the combination of an
identifier, a type, and an optional initializer. The syntax for declaring a variable is:
type identifier [= value] [ ,identifier [ = value]…]; e.g.: int a = 5, b=6;
4) Type Conversions and Casting:
a. Java’s Automatic Conversions:
i. The Two types are compatible.
ii. The destination type is larger then the source type.
b. Casting Incompatible Types:
i. Also called as narrowing conversions, since we are explicitly making the value
narrower so that it will fit into the target type.
ii. A cast is simply a explicit type conversion. The general form is (target type)
value e.g. int a; byte b; b = (byte) a;
5) Arrays:
a. An array is a group of variables of the same data type and referred to by a common
name. An array is contiguous block of memory locations referred by a common name.
E.g. char[] s;
Class[] Obj;
b. Like all objects we use the new keyword to create an array.
s = new char[10];
c. Types of Arrays:
i. One Dimensional Array.
type array_name []; //type is the datatype of the array.
ii. Multi – Dimensional Array.
type array_name = new type [rows] [cols];
6) What is Expressions?
In Java, arithmetic, boolean, and String expressions are written in conventional mathematical
infix notation, adapted to the standard computer character set (called ASCII).
7) What is Operators:
Java provides a rich operator environment. And it can be classified into four groups as:
a. Arithmetic: Used in mathematical expressions. They are: +, -, *, /.
b. Bitwise: It operates on individual bits of integer values. They are: &, |, ~,
c. Relational: It compares two values and determines the relationship between them. They
are: ==, !=, <, >, <=, and >=
d. Logical: It is an easy way to handle multiple conditions. They are: &&, || and, !.
8) What is Control Structures?
Statements that support repetition and conditional execution are called control statements or
control structures.
They are of two type: They are:
o Branching Statements: - They are If and Switch Statements.
o Looping Statements: - They are for, while, and do-while loops.
9) Define Classes?
Java classes contain fields and methods. A field is like a C++ data member, and a method is like a
C++ member function.
Each field and method has an access level:
private: accessible only in this class
(package): accessible only in this package
protected: accessible only in this package and in all subclasses of this class
public: accessible everywhere this class is available
Example: Class MyClass{
int RollNo; // Member Variable
String Name; // Member Variable
void getDetails(); // Member Function
void dispDetails(); // Member Function }
10) Define Object?
Objects are key to understanding object-oriented technology.
Object is an instance (or instantiation) of a class.
Three properties characterize objects:
o Identity: the property of an object that distinguishes it from other objects
o State: describes the data stored in the object
o Behavior: describes the methods in the object's interface by which the object can be
used
Example:
public static void main(String args[])
{
MyClass c1 = new MyClass(); //c1 is the Object of the Class MyClass
MyClass c2; // declare reference to Object
c2 = new MyClass(); //Allocate a MyClass Object
}
The new Keyword is used to allocate memory dynamically
11 ) Define Method?
A method is a set of Java statements which can be included inside a Java class.
They are similar to functions or procedures in other programming languages.
The only required elements of a method declaration are the method's return type, name, a pair
of parentheses, (), and a body between braces, {}.
The general from is
return-type method-name(parameters-list)
{
// body of the method
}
12) What is Constructor?
Constructors have one purpose in life: to create an instance of a class. This can also be called
creating an object
Constructors and methods differ in three aspects of the signature: modifiers, return type, and
name.
Like methods, constructors can have any of the access modifiers: public, protected, private, or
none.
Constructors cannot be abstract, final, native, static, or synchronized.
UNIT-4
1) Utility Packages:
The final Java package, java.util, contains a collection of utility classes.
The Utility Package of Java consist of the following components:
Collections framework
Legacy collection classes
Event model
Date and time facilities
Internationalization
Miscellaneous utility classes such as string tokenizer, random-number generator and bit
array
2) What is DataStructure Class
Data Structure Classes: Data Structure Classes are very useful classes for implementing
standard computer science data structures: including BitSet, Dictionary, Hashtable,
Stack and Vector. The Enumeration interface of java.util package is used to count
through a set of values.
Date: The Date class is used to manipulate calendar dates in a system-independent
fashion.
3) What is String Tokenizer ?
StringTokenizer: This StringTokenizer class is used to convert a String of text into its tokens.
4) What is Input Stream?
InputStream: The abstract class InputStream declares methods to read bytes from a particular
source. InputStream is the superclass of most byte input streams in java.io.
5)What is Output Stream ?
OutputStream: The abstract class OutputStream is analogous to InputStream; it provides an
abstraction
for writing bytes to a destination
6)Define Character Streams ?
Character Streams: The abstract classes for reading and writing streams of characters are Reader
and Writer.
Each supports methods similar to those of its byte stream counterpart—InputStream and
OutputStream, respectively.
Reader has a read method that returns a char as the lowest 16 bits of an int. And, Writer has
methods that write char arrays.
The character streams were designed after the byte streams to provide full support for working
with Unicode characters, and in the process the contracts of the classes were improved to make
them easier to work with.
7) What is Inner Class ?
There are four other types of classes, loosely known as inner classes, that can be defined in a
Java program. Used correctly, inner classes are an elegant and powerful feature of the Java
language.
8)What is Static Member ?
A static member class is a class (or interface) defined as a static member of another class.
A static method is called a class method, so, by analogy, we could call this type of inner class a
"class
class," but this terminology would obviously be confusing.
A static member class behaves much like an ordinary top-level class, except that it can access the
static
members of the class that contains it. Interfaces can be defined as static members of classes.
9) Define Anonymous classes?
An anonymous class is a kind of local class that has no name; it combines the syntax for class
definition
with the syntax for object instantiation.
While a local class definition is a Java statement, an anonymous class definition (and
instantiation) is a
Java expression, so it can appear as part of a larger expression, such as method invocation.
10) Java Database Connectivity:
Java Database Connectivity or in short JDBC is a technology that enables the java program to
manipulate data stored into the database.
JDBC is Java application programming interface that allows the Java programmers to access
database management system from Java code. It was developed by JavaSoft, a subsidiary of Sun
Microsystems.
JDBC is consists of four Components: The JDBC API, JDBC Driver Manager, The JDBC Test
Suite
and JDBC-ODBC Bridge.
JDBC is an API specification developed by Sun Microsystems that defines a uniform interface
for
accessing various relational databases. JDBC is a core part of the Java platform and is included
in
the standard JDK distribution.
11) JDBC Driver Manager:
The JDBC DriverManager class defines objects which can connect Java applications to a
JDBC
driver. DriverManager has traditionally been the backbone of the JDBC architecture.
Its main purpose is to provide a means of managing the different types of JDBC database
driver.
When opening a connection to a database it is the DriverManager' s role to choose the most
appropriate driver from the previously loaded drivers.
A Java program that uses the JDBC API loads the specified driver for a particular DBMS
before it
actually connects to a database. The JDBC DriverManager class then sends all JDBC API calls
to
the loaded driver.
12 ) What is Servlets?
Servlets are Java technology's answer to CGI programming. They are programs that run on a
Web server and build Web pages.
Java servlets are more efficient, easier to use, more powerful, more portable, and cheaper than
traditional CGI and than many alternative CGI-like technologies.
The Servlet API, contained in the Java package hierarchy javax.servlet, defines the expected
interactions of a Web container and a servlet.
12) Servlet containers
A Servlet container is a specialized web server that supports Servlet execution.
It combines the basic functionality of a web server with certain Java/Servlet specific
optimizations and extensions – such as an integrated Java runtime environment, and the ability
to automatically translate specific URLs into Servlet requests.
13 ) Remote Method Invocation:
Remote Method Invocation (RMI) facilitates object function calls between Java Virtual
Machines
(JVMs).
JVMs can be located on separate computers - yet one JVM can invoke methods belonging to an
object stored in another JVM. Methods can even pass objects that a foreign virtual machine has
never encountered before, allowing dynamic loading of new classes as required.
The first thing we need to do is to agree upon an interface, an interface is a description of the
methods we will allow remote clients to invoke. An interface is a method which contains
abstract methods
14) What is Event-Driven-Thread (EDT) in Swing?
Event-Driven-Thread or EDT is a special thread in Swing and AWT. Event-Driven Thread is
used to draw graphics and listen for events in Swing. You will get a bonus point if you able to
highlight that time consuming operations like connecting to database, opening a file or
connecting to network should not be done on EDT thread because it could lead to freezing GUI
because of blocking and time consuming nature of these operations instead they should be done
on separate thread and EDT can just be used to spawn those thread on a button click or mouse
click.
15) Does Swing is thread safe? What do you mean by swing is not thread-safe?
This swing interview questions is getting very popular now days. Though it’s pretty basic many
developer doesn't understand thread-safety issue in Swing. Since Swing components are not
thread-safe it means you can not update these components in any thread other than
Event-Driven-Thread. If you do so you will get unexpected behavior. Some time interviewer will
also ask what are thread-safe methods in swing which can be safely called from any thread only
few like repaint() and revalidate().
1) AWT component are considered to be heavyweight while Swing component are lightweights
2) Swing has plug-gable look and feel.
3) AWT is platform depended same GUI will look different on different platform while Swing is
developed in Java and is platform dependent.
19) Write code for JTable with custom cell editor and custom cell renderer?
Now comes harder part of swing interviews, questions asked in this part of Swing interview is
mostly about writing code and checking developer’s capability of API familiarity, key concept of
swing code etc.
JTable is one of favorite topic of all Swing interviews and most popular questions on swing
interviews are from JTable why? Because here interviewer will directly asked you to write code
another reason is JTable heavily used in all Electronic trading GUI. GUI used for online stock
trading uses JTable to show data in tabular format so an in depth knowledge of JTable is
required to work on online trading GUI developed in Swing. While this question is just an
example questions around JTable are mostly centered around updating table, how do you
handle large volume of data in table, using customize cell renderer and editor, sorting table
data based on any column etc. so just make sure you have done quite a few handsone exercise on
JTable before appearing for any java swing interview in IB.
20) Write code to print following layout (mainly focused on GridBag layout)?
After JTable second favorite topic of swing interviewer is GridBagLayout. GridBagLayout in
swing is most powerful but at same time most complex layout and a clear cut experience and
expertise around GridBagLayout is desired for developing Swing GUI for trading systems. No
matter whether you are developing GUI for equities trading, futures or options trading or forex
trading you always required GridBagLayout. Swing interview question on GridBagLayout will
be mostly on writing code for a particular layout just like an example shown here. In which six
buttons A, B, C, D, E and F are organized in certain fashion.
21) How do you handle opening of database, file or network connection on a click of
button?
This one is one of the easy java swing interview question. Interviewer is interested on whether
you know the basic principle of Java GUI development or not. answer is you should not do this
operation in EDT thread instead spawn a new thread from actionListener or button and disable
the button until operation gets completed to avoid resubmitting request. Only condition is that
your GUI should always be responsive no matter what happens on network connection or
database connection because these operations usually take time.
23) Question around JList like Creating a Jlist component such which should contain all the
asset classes like stocks, futures, options and derivatives etc in form of String. But constraint
is JList should always be sorted in Ascending order except that all assets which begins with
"Electronic trading” appears on top?
This is an excellent java swing interview questions which is based on real world task and focus
on JList component, Sorting and customizing JList model. For sorting you can use comparable in
Java and by customizing the JList model you can display content as requested. Once you
successfully answer this question there may be some followup on customizing the color of cell
etc which can be done by customizing renderer.
UNIT-5
1) What is JavaBeans?
JavaBeans is a portable, platform-independent component model written in the Java
programming language, developed in collaboration with industry leaders. It enables developers
to write reusable components once and run them anywhere -- benefiting from the
platform-independent power of Java technology. JavaBeans acts as a Bridge between proprietary
component models and provides a seamless and powerful means for developers to build
components that run in ActiveX container applications.
2)What is a Bean? Why isn't a Bean an Applet?
JavaBeans components, or Beans, are reusable software components that can be manipulated
visually in a builder tool. Beans can be combined to create traditional applications, or their
smaller web-oriented brethren, applets. In addition, applets can be designed to work as reusable
Beans.
Individual Beans will function quite differently, but typical unifying features that distinguish a
Bean are:
• Introspection: enables a builder tool to analyze how a Bean works
• Customization: enables a developer to use an app builder tool to customize the
appearance and behavior of a Bean
• Events: enables Beans to communicate and connect together
• Properties: enable developers to customize and program with Beans
• Persistence: enables developers to customize Beans in an app builder, and then retrieve
those Beans, with customized features intact, for future use
3)Why are component architectures useful?
Developers are turning to creating components rather than monolithic applications to free
themselves from slow, expensive application development, and to build up a portable, reusable
code base. This enables developers to quickly attack new market opportunities, new joint
development opportunities, and new ways to sell smaller packages of software.
4)Is JavaBeans a complete component architecture?
JavaBeans is a complete component model. It supports the standard component architecture
features of properties, events, methods, and persistence. In addition, JavaBeans provides support
for introspection (to allow automatic analysis of a JavaBeans component) and customization (to
make it easy to configure a JavaBeans component).
5)Why a component architecture for the Java platform?
JavaBeans brings the extraordinary power of the Java platform to component development,
offering the ideal environment for a developer who wants to extend the concept of reusable
component development beyond one platform and one architecture to embrace every platform
and every architecture in the industry.
6)What kind of industry support exists for JavaBeans?
A coalition of industry leaders in component development worked with JavaSoft to create the
JavaBeans specification, which was released to the Internet for public comments on September
4, 1996. The "frozen" JavaBeans specification combines the work of Apple, Borland, IBM,
JustSystem, Microsoft, Netscape, Rogue Wave, SunSoft and Symantec and many, many others...
We're very pleased to see the tools community swiftly embracing JavaBeans by announcing
support for JavaBeans in their visual application builder tools.
7)Are there JavaBeans components available that I can buy today?
Yes. A large number of companies, both large and small, have announced their plans to deliver
JavaBeans-based products.
8)What is the relationship between Sun's JFCs and JavaBeans?
The JFC (Java Foundation Classes) is based upon the AWT (Abstract Windowing Toolkit),
which has been part of the Java platform from the beginning. JFC effectively adds a richer set of
visual elements for building JavaBeans components and applications. See the JFC web site for
more information.
9)What are the security implications for downloading Beans over the Internet?
JavaBeans does not add any security features to the Java platform. Rather, JavaBeans
components have full access to the broad range of security features that are part of the Java
platform. JavaBeans components can be used to build a range of different kinds of solutions from
full-fledged Java desktop applications to web-based Applets.
1. What is network? What are the three criteria necessary for an effective and efficient
network?
Network is a connected group of autonomous computers that are abided by some rules and also
where functionality is shared.
The most important criteria are performance, reliability and security.
Performance of the network depends on number of users, type of transmission medium, and the
capabilities of the connected h/w and the efficiency of the s/w.
Reliability is measured by frequency of failure, the time it takes a link to recover from the failure
and the network's robustness in a catastrophe.
Security issues include protecting data from unauthorized access and viruses.
3. What are the three fundamental characteristics determine the effectiveness of the data
communication system?
The effectiveness of the data communication system depends on three fundamental
characteristics:
Delivery: The system must deliver data to the correct destination.
Accuracy: The system must deliver data accurately.
Timeliness: The system must deliver data in a timely manner.
6. What are some of the factors that determine whether a communication system is a LAN,
MAN, or WAN?
Size, Ownership, the distance it covers and its physical structure
Co-ordination across the nodes of a network is necessary for an efficient communication. If there are
no standards, difficulties arise. A standard provides a model or basis for development to which everyone
has agreed.
8. For n devices in a network, what is the number of cable links required for a mesh and ring
topology?
Mesh topology - n (n-1)/2
Ring topology - n
11. Assume 6 devices are arranged in a mesh topology. How many cables are needed? How many
ports are needed for each device?
Number of cables=n (n-1)/2=6(6-1)/2=15
Number of ports per device=n-1=6-1=5
13. What are header and trailers and how do they get added and removed?
Each layer in the sending machine adds its own information to the message it receives from the
layer just above it and passes the whole package to the layer just below it. This information is added in
the form of headers or trailers. Headers are added to the message at the layers 6,5,4,3, and 2. A trailer
is added at layer2. At the receiving machine, the headers or trailers attached to the data unit at the
corresponding sending layers are removed, and actions appropriate to that layer are taken.
14. The transport layer creates a communication between the source and destination. What are
the three events involved in a connection?
Creating a connection involves three steps: connection establishment, data transfer and connection
release.
16-MARKS
PART – B
UNIT-1
UNIT-2
UNIT-3
UNIT-4