Professional Documents
Culture Documents
From Each Unit: Minimum 60 questions and as many as possible, if it is 240 questions and more it will be well and good.
I
30 30 If an application has multiple classes in If there is main method in more than one
it, is it okay to have a main method in classes in a java application, it won't
more than one class? cause any issue as entry point for any
application will be a specific class and
I code will start from the main method of
that particular class only.
31 31 Can we cast any other type to Boolean No, we can neither cast any other
Type with type casting? primitive type to Boolean data type nor
can cast Boolean data type to any other
primitive data type.
32 32 What is this keyword in Java? this() represents the current instance of a
class
33 33 What is super keyword in Java? super() represents the current instance of
a parent/base class
34 34 What is static method in Java? The static keyword must be used before
the method name It is called using the
class (className.methodName) They can’
t access any non-static instance variables
or methods
35 35 What is nonstatic method in Java? No need to use the static keyword before
the method nameIt is can be called like
any general methodIt can access any
static method and any static variable
without creating an instance of the class
36 36 What is the default value of the local The local variables are not initialized to
variables? any default value, neither primitives nor
object references.
37 37 What is the static variable? The static variable is used to refer to the
common property of all objects (that is
not unique for each object), e.g., The
company name of employees, college
name of students, etc.
38 38 What are the restrictions that are Two main restrictions are applied to the
applied to the Java static methods? static methods.
char[] ch={'j','a','v','a','t','p','o','i','n','t'};
String s=new String(ch);
is same as:
String s="javatpoint";
122 2 Is String a data type in java? String is not a primitive data type in java.
When a string is created in java, it's
actually an object of Java.Lang.String
class that gets created. After creation of
this string object, all built-in methods of
String class can be used on the string
object.
123 3 In the below example, how many String In the above example, two objects of
Objects are created? Java.Lang.String class are created. s1 and
String s1="I am Java Expert"; s3 are references to same object.
String s2="I am C Expert";
String s3="I am Java Expert";
124 4 Why Strings in Java are called as In java, string objects are called
Immutable? immutable as once value has been
assigned to a string, it can't be changed
and if changed, a new object is created.
str="New Value";
125 5 How to create a string object? There are two ways to create String
object:
1. By string literal
2. By new keyword
126 6 Is String a keyword in Java? No. String is not a keyword in Java. String
is a final class in java.lang package which
is used to represent the set of characters
in Java.
127 7 What is string constant pool? String objects are most used data objects
in Java. Hence, Java has a special
arrangement to store the string objects.
String Constant Pool is one such
arrangement. String Constant Pool is the
memory space in the heap memory
specially allocated to store the string
objects created using string literals. In
String Constant Pool, there will be no two
string objects having the same content.
Whenever you create a string object
using string literal, JVM first checks the
content of the object to be created. If
there exist an object in the string
constant pool with the same content,
then it returns the reference of that
object. It doesn’t create a new object. If
the content is different from the existing
objects then only it creates new object.
128 8 What is special about string objects as One special thing about string objects is
compared to objects of other derived that you can create string objects without
types? using new operator i.e using string
literals. This is not possible with other
derived types (except wrapper classes).
One more special thing about strings is
that you can concatenate two string
objects using ‘+’. This is the relaxation
Java gives to string objects as they will be
used most of the time while coding. And
also Java provides string constant pool to
store the string objects.
129 9 What do you mean by mutable and Immutable objects are like constants. You
immutable objects? can’t modify them once they are created.
They are final in nature. Where as
mutable objects are concerned, you can
perform modifications to them.
130 10 Which is the final class in these three All three are final.
classes – String, StringBuffer and
StringBuilder?
131 11 What is the difference between String, String vs StringBuilder vs StringBuffer in
StringBuffer and StringBuilder? Java
The differences between String,
StringBuffer, and StringBuilder are based
on the following two parameters:
1. Mutability
2. Performance
132 12 Why StringBuffer and StringBuilder The objects of String class are immutable
classes are introduced in Java when in nature. i.e you can’t modify them once
there already exist String class to they are created. If you try to modify
represent the set of characters? them, a new object will be created with
modified content. This may cause
memory and performance issues if you
are performing lots of string
modifications in your code. To overcome
these issues, StingBuffer and
StringBuilder classes are introduced in
Java.
133 13 How do you create mutable string Using StringBuffer and StringBuilder
objects? classes. These classes provide mutable
string objects
134 14 Which one will you prefer among “==” I prefer equals() method because it
and equals() method to compare two compares two string objects based on
string objects? their content. That provides more logical
comparison of two string objects. If you
use “==” operator, it checks only
references of two objects are equal or
not. It may not be suitable in all
situations. So, rather stick to equals()
method to compare two string objects.
135 15 Which class do you recommend among StringBuffer
String, StringBuffer and StringBuilder
classes if I want mutable and thread
safe objects?
136 16 How do you convert given string to char Using toCharArray() method.
array?
137 17 What is the main difference between In C and C++, strings are terminated with
Java strings and C, C++ strings? null character. But in Java, strings are not
terminated with null character. Strings
are treated as objects in Java.
138 18 Can we call String class methods usingYes, we can call String class methods
string literals? using string literals. Here are some
examples,
1. "abc".charAt(0)
2. "abc".compareTo("abc")
3. "abc".indexOf('c')
139 19 do you have any idea why strings have 1. Immutable strings increase security. As
been made immutable in Java? they can’t be modified once they are
created, so we can use them to store
sensitive data like username, password
etc.
2. Immutable strings are thread safe. So,
we can use them in a multi threaded
code without synchronization.
3. String objects are used in class loading.
If strings are mutable, it is possible that
wrong class is being loaded as mutable
objects are modifiable.
140 20 Write a java program to reverse a String str = "MyJava";
string? char[] strArray = str.toCharArray();
for (int i = strArray.length - 1; i >= 0; i--)
{
System.out.print(strArray[i]);
//Output : avaJyM
}
and have many more methods for
reverse of string
141 21 How Can We Split a String in Java? The String class itself provides us with the
String split method, which accepts a
regular expression delimiter. It returns us
a String[] array:
String[] parts = "john,peter,mary".split
(",");
assertEquals(new String[] { "john",
"peter", "mary" }, parts);
One tricky thing about split is that when
splitting an empty string, we may get a
non-empty array:
assertEquals(new String[] { "" }, "".split
(","));
142 22 How Can We Convert String to Integer The most straightforward approach to
and Integer to String in Java? convert a String to an Integer is by using
Integer parseInt:
int num = Integer.parseInt("22");
To do the reverse, we can use
Integer#toString:
String s = Integer.toString(num);
143 23 How Can We Convert a String to String implicitly provides String
Uppercase and Lowercase? toUpperCase to change the casing to
uppercase.
Though, the Javadocs remind us that we
need to specify the user's Locale to
ensure correctness:
String s = "Welcome to Baeldung!";
assertEquals("WELCOME TO
BAELDUNG!", s.toUpperCase(Locale.US));
Similarly, to convert to lowercase, we
have String toLowerCase:
String s = "Welcome to Baeldung!";
assertEquals("welcome to baeldung!", s.
toLowerCase(Locale.UK));
144 24 How Can We Get a Character Array from String provides toCharArray, which
String? returns a copy of its internal char array
pre-JDK9 (and converts the String to a
new char array in JDK9+):
char[] hello = "hello".toCharArray();
assertArrayEquals(new String[] { 'h', 'e',
'l', 'l', 'o' }, hello);
145 25 How Would We Convert a Java String By default, the method String getBytes()
into a Byte Array? encodes a String into a byte array using
the platform’s default charset.
And while the API doesn't require that we
specify a charset, we should in order to
ensure security and portability:
byte[] byteArray2 = "efgh".getBytes
(StandardCharsets.US_ASCII);
byte[] byteArray3 = "ijkl".getBytes("UTF-
8");
146 26 In what way can you perform String Concatenation is an operation used to
concatenation? merge two Strings into a new one. Basic
Strings can be concatenated simply by
using the + operator or by using .concat()
method, while StringBuffers and
StringBuilders achieve concatenation by
using .append() method.
147 27 How do you find the value of a The String class provides a method .
character at a specific position? charAt(int position) which returns a single
character. Which character will the
method return depends on the specified
argument 'position'.
148 28 Checking if String Contains Only Digits The easiest approach to check if the
String contains only digits is using the .
matches() method and providing a String
argument - "[0-9]+". The expected
argument should be a regex (Regular
Expression) to which the String is to be
matched - in our case regex represents
the numeric characters from 0 to 9!
if (str.matches("[0-9]+")) {
System.out.println("String contains
only numbers.");
} else {
System.out.println("String doesn't
contain only numbers!");
}
149 29 Counting the Number of Words in a To accomplish this we should divide our
String String in smaller pieces (words) and use a
space character as a delimiter:
substring(int beginIndex)
substring(int beginIndex, int endIndex)
151 31 What are the ways to compare string? We can compare strings using the
equals() method, == operator and
compareTo() method.
Java
/*
* A Java program showing the use of
* String in switch case.
*/
public class StringInSwitchExample
{
public static void main(String[] args)
{
String str = "two";
switch(str)
{
case "one":
System.out.println("January");
break;
case "two":
System.out.println("February");
break;
case "three":
System.out.println("March");
break;
default:
System.out.println("Invalid
month number");
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
* A Java program showing the use of
* String in switch case.
*/
public class StringInSwitchExample
{
public static void main(String[] args)
{
String str = "two";
switch(str)
{
case "one":
System.out.println("January");
break;
case "two":
System.out.println("February");
break;
case "three":
System.out.println("March");
break;
default:
System.out.println("Invalid
month number");
}
}
}
154 34 How to convert String to double in Java? Similar to Integer.parseInt() method
which is used to convert String to double,
you can use the Double.parseDouble()
method to convert a String to double
primitive value. If you want to learn
fundamentals like this, I also suggest
picking one of the Java Programming
courses for beginners from this list.
155 35 How to remove white space from String You can use the trim() method to remove
in Java? white space from String in Java.
156 36 How to remove or replace characters To replace or remove characters, use
from String? String.replace() or String.replaceAll().
These methods take two arguments. First
argument is character to be replaced, and
second argument is new character which
will be placed in string.
157 37 How to delete white space from You can use the deleteCharAt() method
StringBuffer in Java? to remove white space from StringBuffer
in Java.
158 38 How to delete string from StringBuffer You can use the delete(int,int) method to
in Java? remove string from StringBuffer in Java.
159 39 To print index of a char in string? using indexOf() method to print index of
a char
160 40 To print last index of a char in string? using lastIndexOf() method to print last
index of a char
161 41 How to compare two string on the basis You can use compareTo() method to
of unicode (DICTIONARY ORDER ) compare two string on the basis of
unicode (DICTIONARY ORDER )
162 42 What are the use of valueOf() method in valueOf() method is used to convert in-
java build datatytpe in string
163 43 How to check any string is end with a you can use endsWith() method to check
specific string any string is end with a specific string
164 44 How to check any string is start with a you can use startsWith() method to check
specific string any string is start with a specific string
165 45 How to return the current capacity of capacity() method is used to return the
StringBuffer current capacity of StringBuffer
166 46 How to ensure the capacity at least ensureCapacity(int minimumCapacity)
equal to the given minimum of method is used to ensure the capacity at
StringBuffer least equal to the given minimum of
StringBuffer
167 47 How to append the specified string with append() method is used to append the
this string specified string with this string
168 48 How to insert the specified string with insert(int offset, String s) method is used
this StringBuffer at the specified to insert the specified string with this
position StringBuffer at the specified position
169 49 To replace the StringBuffer from replace(int startIndex, int endIndex,
specified startIndex and endIndex. String str) method is used to replace the
StringBuffer from specified startIndex and
endIndex.
170 50 How to creates an empty string Builder StringBuilder() creates an empty string
with the initial capacity of 16. Builder with the initial capacity of 16.
171 51 How to creates a string Builder with the StringBuilder(String str) creates a string
specified string. Builder with the specified string.
172 52 How to creates an empty string Builder StringBuilder(int length) creates an empty
with the specified capacity as length. string Builder with the specified capacity
as length.
173 53 String[] split(String regex, int limit) String[] split(String regex, int limit)
method is used to? method is used to returns a split string
matching regex and limit.
174 54 compareTo() return 0 (zero) when? compareTo() return 0 (zero) when both
strings lexicographically (Unicode) are
equal
175 55 What will be the output of following H
program?
class StringBufferExample4{
public static void main(String args[]){
StringBuffer sb=new StringBuffer
("Hello");
sb.delete(1,6);
System.out.println(sb);
}
}
176 56 What will be the output of following Hello
program?
public class Main
{
public static void main(String[] args) {
String sb=new String("Hello");
sb.concat(" User");
System.out.println(sb);
}
}
177 57 What will be the output of following HELLO
program?
public class Main
{
public static void main(String[] args) {
String sb=new String("Hello");
sb=sb.toUpperCase();
System.out.println(sb);
}
}
178 58 What is the Output Of the following java
Program java programming
class demo1 {
public static void main(String args[])
{
String str1 = "java";
char arr[] = { 'j', 'a', 'v', 'a', ' ', 'p',
'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g' };
String str2 = new String(arr);
System.out.println(str1);
System.out.println(str2);
}
}
179 59 What is the Output Of the following abcde
Program
class demo3 {
public static void main(String args[])
{
byte[] arr = { 97, 98, 99, 100, 101 };
String str2 = new String(arr);
System.out.println(str2);
}
}
180 60 What is the Output Of the following Java
Program
class demo5 {
public static void main(String args[])
{
String str = "Java Programming";
char arr[] = new char[10];
str.getChars(0, 4, arr, 0);
System.out.println(arr);
}
}
181 1 What Is an Exception? An exception is an abnormal event that
occurs during the execution of a program
and disrupts the normal flow of the
program's instructions.
182 2 What Is the Purpose of the Throw and The throws keyword is used to specify
Throws Keywords? that a method may raise an exception
during its execution. It enforces explicit
exception handling when callinf method.
The throw keyword allows us to throw an
exception object to interrupt the normal
flow of the program.
183 3 How Can You Handle an Exception? By using a try-catch-finally statement:
184 4 How Can You Catch Multiple A try block can be followed by one or
Exceptions? more catch blocks. Each catch block must
contain a different exception handler. So,
if you have to perform different tasks at
the occurrence of different exceptions,
use java multi-catch block.
185 5 What Is the Difference Between a A checked exception must be handled
Checked and an Unchecked Exception? within a try-catch block or declared in
a throws clause; whereas an unchecked
exception is not required to be handled
nor declared.
186 6 What Is the Difference Between an An exception is an event that represents
Exception and Error? a condition from which is possible to
recover, whereas error represents an
external situation usually impossible to
recover from
187 7 Is it possible to keep other statements It is not recommended to include any
in between ‘try’, ‘catch’, and ‘finally’ statements between the sections of ‘try’,
blocks? ‘catch’, and ‘finally’ blocks, since they
form one whole unit of the exception
handling mechanism.
188 8 Will it be possible to only include a ‘try’ This would give a compilation error. It is
block without the ‘catch’ and ‘finally’ necessary for the ‘try’ block to be
blocks? followed with either a ‘catch’ block or a
‘finally’ block, if not both. Either one of
‘catch’ or ‘finally’ blocks is needed so that
the flow of exception handling is
undisrupted.
189 9 Define OutOfMemoryError in Java. It is the sub class of java.lang.Error which
is encountered when the JVM runs out of
memory.
190 10 Does the ‘finally’ block get executed if The ‘finally’ block is always executed
either of ‘try’ or ‘catch’ blocks return irrespective of whether try or catch
the control? blocks are returning the control or not.
191 11 Is it possible to throw an exception It is possible to throw an exception
manually? If yes, explain how. manually. It is done using the ‘throw’
keyword.
192 12 What are some examples of checked ClassNotFoundException, SQLException,
exceptions? and IOException.
193 13 What are some examples of unchecked ullPointerException,
exceptions? ArrayIndexOutOfBoundsException and
NumberFormatException.
194 14 What is the difference between final, By declaring a variable as final, the value
finally and finalize in java? of final variable cannot be changed.
finally:
Used after try or try-catch block, will get
executed after the try and catch blocks
without considering whether an
exception is thrown or not. finalize:
Finalize method is the method that
Garbage Collector always calls just before
the deletion/destroying the object which
is no longer in use in the code.
195 15 What is a SQLException in Exception An exception that provides information
Handling? related to database access error or other
errors is called SQL Exception.
196 16 What is FileNotFound Exception in java It is compile time exception and it occurs
? when file to be read does not exist in
system.
197 17 What is NumberFormatException in NumberFormatException is thrown when
java? you try to convert a String into a number.
198 18 What is ArrayIndexOutOfBoundsException arises
ArrayIndexOutOfBoundsException in while trying to access an index of the
java? array that does not exist or out of the
bound of this array.
199 19 What will happen if an exception is When an exception is thrown by the main
thrown by the main method? method then JVM terminates the
program. As a result, you will find the
exception message and stack trace in the
system console.
200 20 What are the advantages of using Separating "regular" code from error
Exceptions in your programs? handling code. The ability to propagate
errors reporting up the call stack of
methods. Differentiating and grouping
error types.
201 21 What is exception propagation in java? Whenever methods are called stack is
formed and an exception is first thrown
from the top of the stack and if it is not
caught, it starts coming down the stack to
previous methods until it is not caught. If
exception remains uncaught even after
reaching bottom of the stack it is
propagated to JVM and program is
terminated in java.
202 22 What exception may occur by using Null Pointer Exception
following code?
String s=null;
System.out.println(s.length());
203 23 What exception may occur by using Number Format Exception
following code?
String s="abc";
IV int i= Integer.parseint(s);
204 24 What exception may occur by using ArrayIndexOutOfBoundsException
code-
int a[]=new int[5];
a[10]=50;
205 25 What is Thread in java? Thread are light weight process.
206 26 What is difference between Process and One process can have multiple Threads,
Thread in java? Thread are subdivision of Process
207 27 How to create Threads in java? by extending thread class or
implementing runnable interface.
208 28 How many method does runnable only one i.e run() method.
interface has?
209 29 We should implement Runnable Multiple inheritance in not allowed in
interface or extend Thread class. What java
are differences between implementing
Runnable and extending Thread?
210 30 What is difference between starting When you call start() method, main
thread with run() and start() method? thread internally calls run() method to
start newly created Thread, so run()
method is ultimately called by newly
created thread. When you call run()
method main thread rather than starting
run() method with newly thread it start
run() method by itself.
211 31 Can you again start Thread? o, we cannot start Thread again, doing so
will throw runtimeException java.lang.
IllegalThreadStateException. The reason
is once run() method is executed by
Thread, it goes into dead state.
212 32 What is life cycle of Thread New --> Runnable--> Running --> Waiting
---> Terminate
213 33 What are daemon threads? are low priority threads which runs
intermittently in background for doing
garbage collection.
214 34 What is significance of sleep() method in sleep() methods causes current thread to
detail, what statedoes it put thread in ? sleep for specified number of
milliseconds
215 35 What do you understand by inter- The process of communication between
thread communication? synchronized threads is termed as inter-
thread communication.
216 36 What are the advantages of Multithreading allows an
multithreading? application/program to be always
reactive for input, even already running
with some background tasks
217 37 What is context switching? In Context switching the state of the
process (or thread) is stored so that it can
be restored and execution can be
resumed from the same point later.
Context switching enables the multiple
processes to share the same CPU.
218 38 Differentiate between the Thread class By extending the Thread class, we cannot
and Runnable interface for creating a extend any other class, as Java does not
Thread? allow multiple inheritances while
implementing the Runnable interface; we
can also extend other base class
219 39 What does join() method? The join() method waits for a thread to
die. In other words, it causes the
currently running threads to stop
executing until the thread it joins with
completes its task.
220 40 Can we make the user thread as No, if you do so, it will throw
daemon thread if the thread is started? IllegalThreadStateException
221 41 What is Thread Scheduler in java? It selects the priority of the thread. It
determines the waiting time for a thread
222 42 How is the safety of a thread achieved? Synchronization , Using a lock based
mechanism
223 43 How we can set priority of thread By calling thread priority method
224 44 what does MIN_PRIORITY means? 1 as integer
225 45 What does MAX_PRIORITY means? 10
226 46 NORM_PRIORITY? 5
227 47 What is the default name given to Thread_0
threads by JVM
228 48 How can we set the name of threads? Thread.currentThrea().setName();
229 49 How can we find that current thread by using Thread.currentThread().
running is daemon thread or not? isDaemon();
230 50 How can we achieve multitasking? Process based Multitasking
(Multiprocessing) and thread based
multitasking i.e multithreading
231 51 The built-in base class in Java, which is Throwable
used to handle all exceptions is
232 52 In which package does exception class java.lang package
exist?
233 53 Which exception is thrown when a Arithmetic Exception
number is divided by zero?
234 54 What is synchronization? It is a technique of granting access to the
shared resources in multithread
environment to avoid inconsistencies in
the results.
235 55 What will happen if two thread of the It is dependent on the operating system
same priority are called to be processed
simultaneously?
236 56 Which method is used to wait for child Join ()
threads to finish in Java?
237 57 Thread synchronization in a process will All threads sharing the same address
be required when space, All threads sharing the same global
variables, All threads sharing the same
files
238 58 When does Exceptions in Java arises in Run Time
code sequence?
239 59 Which method restarts the thread A thread cant be restarted.
240 60 A thread can acquire a lock by using synchronized
which reserved keyword?
241 1 What is Stream? A stream is a sequence of objects that
supports various methods which can be
pipelined to produce the desired result.
242 2 Define Input Stream. The InputStream is used to read data
from a source.
243 3 Define Output Stream. The OutputStream is used for writing
data to a destination.
244 4 What are the types of I / O streams? There are two types of I / O streams: byte
and character.
245 5 What are the main ancestors of I/O java.io.InputStream,java.io.OutputStream
Streams?
246 6 What do you understand by an IO The stream is a sequence of data that
stream? flows from source to destination. It is
composed of bytes. In Java, three streams
are created for us automatically.
251 11 What is the difference between FileInputStream reads the file byte by
FileInputStream and FileReader in Java byte and FileReader reads the file
IO? character by character.
252 12 What is the difference between BufferedReader is a Decorator that
BufferedReader and FileReader in Java? provides buffering for faster IO, while
FileReader is used to read data from File.
253 13 What is the difference between Scanner is normally used when we know
BufferedReader and Scanner in Java? input is of type string or of primitive
types and BufferReader is used to read
text from character streams while
buffering the characters for efficient
reading of characters.
254 14 What is the use of the PrintStream class PrintStream is used to write data on
in Java IO? Console
255 15 Explain the life cycle of an Applet. init,start,paint,stop,destroy
256 16 What is the difference between an Applets are executed within a java
Applet and a Java Application ? enabled browser, but a Java application is
a standalone Java program that can be
executed outside of a browser.
257 17 What Is The Order Of Method public void init() : Initialization method
Invocation In An Applet? called once by browser.
► public void start() : Method called
after init() and contains code to start
processing. If the user leaves the page
and returns without killing the current
browser session, the start () method is
called without being preceded by init ().
► public void stop() : Stops all processing
started by start (). Done if user moves off
page.
► public void destroy() : Called if current
browser session is being terminated.
Frees all resources used by applet.
258 18 What Are The Applets Life Cycle methods in the life cycle of an Applet:
Methods? Explain Them? ► init() method - called when an applet
is first loaded. This method is called only
once in the entire cycle of an applet. This
method usually intialize the variables to
be used in the applet.
► start( ) method - called each time an
applet is started.
► paint() method - called when the
applet is minimized or refreshed. This
method is used for drawing different
strings, figures, and images on the applet
window.
► stop( ) method - called when the
browser moves off the applet’s page.
► destroy( ) method - called when the
browser is finished with the applet.
259 19 What Is The Sequence For Calling The ► init()
Methods By Awt For Applets? ► start()
► paint()
260 20 When An Applet Is Terminated, what is
the Sequence Of Method Calls Takes ► stop()
Place? ► destroy()
261 21 Can We Pass Parameters To An Applet We can pass parameters to an applet
From Html Page To An Applet? How? using <param> tag in the following way:
► <param name=”param1″ value=”
value1″>
► <param name=”param2″ value=”
value2″>
Access those parameters inside the
applet is done by calling getParameter()
method inside the applet. Note that
getParameter() method returns String
value corresponding to the parameter
name.
262 22 Which Classes And Interfaces Does Applet class consists of a single class, the
Applet Class Consist? Applet class and three interfaces:
AppletContext, AppletStub, and AudioClip
263 23 What Is Appletstub Interface? The applet stub interface provides the
means by which an applet and the
browser communicate. Your code will not
typically implement this interface.
264 24 What Are The Steps Involved In Applet ► Create/Edit a Java source file. This file
Development? must contain a class which extends
Applet class.
► Compile your program using javac
► Execute the appletviewer, specifying
the name of your applet’s source file or
html file. In case the applet information is
stored in html file then Applet can be
invoked using java enabled web browser.
265 25 Which Method Is Used To Output A
String To An Applet? Which Function Is drawString( )
This Method Included In?
266 26 What Is The Difference Between A AWT components re heavy weight,
Swing And Awt Components? whereas Swing components are
lightweight.
Heavy weight components depend on the
local windowing toolkit.
267 27 What Are The Different Types Of Labels, Pushbuttons, Checkboxes, Choice
Controls In Awt? lists, Lists, Scroll bars, Text components
268 28 What Are The Benefits Of Swing Over Swing components are light weight.
V Awt? We can have a pluggable look and feel
feature which shows us how they appear
in other platforms.
We can add images to Swing
components. We have toolbars and
tooltips in Swing.
269 29 What Are The Component And A component is a graphical object.
Container Class? A few examples of components are:
Button
Canvas
Checkbox
Choice etc.
270 30 What Is The Use Of The Window Class? The window class can be used to create a
plain, bare bones window that does not
have a border or menu.
The window class can also be used to
display introduction or welcome screens.
271 31 What Is Clipping? Clipping is the process of confining paint
operations to a limited area or shape.
272 32 What Is The Difference Between The The paint() method supports painting via
Paint() And Repaint() Method? a Graphics object.
The repaint() method is used o cause
paint() to be invoked by the AWT painting
thread.
273 33 What Interface Is Extended By Awt The java.util.EventListener interface is
Event Listener? extended by all the AWT event listeners.
274 34 What Is A Container In A Gui? A Container contains and arranges other
components through the use of layout
managers, which use specific layout
policies to determine where components
should go as a function of the size of the
container.
275 35 What Is The Default Layout For Applet? The default layout manager for an Applet
is FlowLayout, and the FlowLayout
manager attempts to honor the preferred
size of any components.