You are on page 1of 4

1) List any two restriction for applet. 14)List any two differences between HashMap and HashTable.

1.If we are running an applet from a provider who is not HashMap :-


trustworthy than security is important. 1.HashMap is non-synchronized. It is not thread-safe and can't be
2.Applet itself cannot run or modify any application on the local shared between many threads without proper synchronization
system. code
3.Applets has no access to client-side resources such as files , OS 2.HashMap allows one null key and multiple null values
etc. 3.Multiple threads can operate simultaneously and hence
2)What are different ways of creating string object ? hashmap's object is not thread-safe.
There are two ways to create a String object: Hashtable:-
By string literal : Java String literal is created by using double 1.Hashtable is synchronized. It is thread-safe and can be shared
quotes. For Example: String s=“Welcome”; with many threads.
By new keyword : Java String is created by using a keyword “new 2.Hashtable doesn’t allow any null key or value.
”. For example: String s=new String(“Welcome”); 3.At a time only one thread is allowed to operate the Hashtable’s
3)Can we use super() and this() within the same object. Hence it is thread-safe.
“this()” and “super()” cannot be used inside the same  15)What are the different ways to create an object in Java ?
constructor, as both cannot be executed at once (both cannot be  There are five different ways to create an object in Java:
the first statement). “this” can be passed as an argument in the  1.Java new Operator.
method and constructor calls. 2.Java Class. newInstance() method.
4)State the use of wrapper class. 3.Java newInstance() method of constructor.
The wrapper class implements the technique to convert the 4.Java Object. clone() method.
primitive into object and object into primitive. There is a concept 5.Java Object Serialization and Deserialization.
of autoboxing and unboxing in the wrapper class, which 16)Can you save a Java source file by name than class name ?
transform the primitives into objects and objects into primitives Yes,you can save your java source code file with any other name,
automatically. not same as your main class name but when you comiple it than
5)How to create and access the package in Java ? byte code file name will be same as your main class name.
1.First create a directory within name of package. alization.
2.Create a java file in newly created directory. 17)What is instance variable ?
3.In this java file you must specify the package name with the help An instance variable is a variable which is declared in a class but
of package keyword. outside of constructors, methods, or blocks. Instance variables
4.Save this file with same name of public class. are created when an object is instantiated, and are accessible to
5.Now you can use this package in your program. all the constructors, methods, or blocks in the class. Access
6)State the purpose of throw keyword. modifiers can be given to the instance variable.mplementation.
The throws keyword is used to declare which exceptions can be 18)List Java non-access modifiers.
thrown from a method, while the throw keyword is used to Modifiers in Java fall into one of two groups - access and non-
explicitly throw an exception within a method or block of code. Access:
The throws keyword is used in a method signature and declares Access:- public , private , protected .
which exceptions can be thrown from a method. Non-Access:- static, final, abstract, synchronized, volatile,
7)State the use of jar file. transient and native .
JAR files are packaged with the ZIP file format, so you can use 19) Swing :-
them for tasks such as lossless data compression, archiving, Java Swing is a lightweight Java graphical user interface (GUI)
decompression, and archive unpacking. These tasks are among widget toolkit that includes a rich set of widgets. It is part of the
the most common uses of JAR files, and you can realize many JAR Java Foundation Classes (JFC) and includes several packages for
file benefits using only these basic features. developing rich desktop applications in Java.
8)Which container use border layout as its default layout ? 20) AWT :-
The window, Frame and Dialog classes use a border layout as their AWT stands for Abstract window toolkit is an Application
default layout. programming interface (API) for creating Graphical User
9)Does the order of public static void matter in main method. Interface (GUI) in Java. It allows Java programmers to develop
It doesn't matter but void should always come before main(). window-based applications. AWT provides various components
10)List the types of Applet. like button, label, checkbox, etc. used as objects inside a Java
1.Form applet , 2.List applet , 3.Pick applet , 4.Multi-value group Program.
applet , 5.Chart applet , 6.Association applet , 7.Explorer or Tree 21)Container :-
applet , 8.File attachment applet. Containers are the interface between a component and the low-
11)What is exception ? level, platform-specific functionality that supports the component
An exception is an event, which occurs during the execution of a . Before it can be executed, a web, enterprise bean, or application
program, that disrupts the normal flow of the program's client component must be assembled into a Java EE module and
instructions. When an error occurs within a method, the method deployed into its container.
creates an object and hands it off to the runtime system. 23)Event:-
12)What is collection framework ? An event in Java is an object that is created when something
The Java collections framework is a set of classes and interfaces changes within a graphical user interface. If a user clicks on a
that implement commonly reusable collection data structures. button, clicks on a combo box, or types characters into a text field
Although referred to as a framework, it works in a manner of a , etc., then an event triggers, creating the relevant event object.
library. The collections framework provides both interfaces that 24)Event handling :-
define various collections and classes that implement them. Event Handling is the mechanism that controls the event and
13)What is JVMA Java virtual machine is a virtual machine that decides what should happen if an event occurs. This mechanism
enables a computer to run Java programs as well as programs have the code which is known as event handler that is executed
written in other languages that are also compiled to Java bytecode. when an event occurs. Java Uses the Delegation Event Model to
The JVM is detailed by a specification that formally describes handle the events.
what is required in a JVM implementation.
T T

You might also like