Object Oriented Programming - CS3391 - Question Bank and Important 2 Marks Questions With Answer
Object Oriented Programming - CS3391 - Question Bank and Important 2 Marks Questions With Answer
CSE
Home Mech
e
EEE
ECE
Physics
Basic for Engineering
Electrical and Data Structure
Problem Solving and Science Engineering
Electronics
Python Programming Object Oriented
Programming in C
Programming
Elective-Management
Professional Elective II
Professional Elective IV
www.Poriyaan.in
CS3391
OBJECT ORIENTED PROGRAMMING
Question Bank
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 1
www.Poriyaan.in
Vision of Institution
To build Jeppiaar Engineering College as an Institution of Academic Excellence in Technical
education and Management education and to become a World Class University.
Mission of Institution
To equip students with values, ethics and life skills needed to enrich their lives and
M3
enable them to meaningfully contribute to the progress of society
M4 To prepare students for higher studies and lifelong learning, enrich them with the
practical and entrepreneurial skills necessary to excel as future professionals and
contribute to Nation’s economy
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 2
www.Poriyaan.in
M3 To produce engineers with good professional skills, ethical values and life skills for the
betterment of the society.
PEO3 Apply ethical knowledge for professional excellence and leadership for the
betterment of the society.
PEO4 Develop life-long learning skills needed for better employment and
entrepreneurship
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 3
www.Poriyaan.in
An ability to understand the core concepts of computer science and engineering and to
PSO1 enrich problem solving skills to analyze, design and implement software and hardware
based systems of varying complexity.
To interpret real-time problems with analytical skills and to arrive at cost effective and
PSO2 optimal solution using advanced tools and techniques.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 4
www.Poriyaan.in
SYLLABUS
1. To understand Object Oriented Programming concepts and basics of Java programming language
2. To know the principles of packages, inheritance and interfaces
3. To develop a java application with threads and generics classes
4. To define exceptions and use I/O streams
5. To design and build Graphical User Interface Application using JAVAFX
Overview of OOP – Object oriented programming paradigms – Features of Object Oriented Programming
– Java Buzzwords – Overview of Java – Data Types, Variables and Arrays – Operators – Control
Statements – Programming Structures in Java – Defining classes in Java – Constructors-Methods -Access
specifiers - Static members- Java Doc comments
Overloading Methods – Objects as Parameters – Returning Objects –Static, Nested and Inner Classes.
Inheritance: Basics– Types of Inheritance -Super keyword -Method Overriding – Dynamic Method
Dispatch –Abstract Classes – final with Inheritance. Packages and Interfaces: Packages – Packages and
Member Access –Importing Packages – Interfaces.
Exception Handling basics – Multiple catch Clauses – Nested try Statements – Java’s Built-in Exceptions
– User defined Exception. Multithreaded Programming: Java Thread Model–Creating a Thread and
Multiple Threads – Priorities – Synchronization – Inter Thread Communication- Suspending –Resuming,
and Stopping Threads –Multithreading. Wrappers – Auto boxing.
I/O Basics – Reading and Writing Console I/O – Reading and Writing Files. Generics: Generic
Programming – Generic classes – Generic Methods – Bounded Types – Restrictions and Limitations.
Strings: Basic String class, methods and String Buffer Class.
JAVAFX Events and Controls: Event Basics – Handling Key and Mouse Events. Controls: Checkbox,
ToggleButton – RadioButtons – ListView – ComboBox – ChoiceBox – Text Controls – ScrollPane.
Layouts – FlowPane – HBox and VBox – BorderPane – StackPane – GridPane. Menus – Basics – Menu –
Menu bars – MenuItem.
COURSE OUTCOMES:
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 5
www.Poriyaan.in
On completion of this course, the students will be able to
CO1: Apply the concepts of classes and objects to solve simple problems
CO3: Make use of exception handling mechanisms and multithreaded model to solve real world problems
CO4: Build Java applications with I/O packages, string classes, Collections and generics concepts
CO5: Integrate the concepts of event handling and JavaFX components and controls for developing GUI
based applications
TOTAL: 45 PERIODS
TEXT BOOKS:
1. Herbert Schildt, “Java: The Complete Reference”, 11 th Edition, McGraw Hill Education, New
Delhi, 2019
REFERENCE:
1. Cay S. Horstmann, “Core Java Fundamentals”, Volume 1, 11 th Edition, Prentice Hall, 2018.
C205.1 Apply the concepts of classes and objects to solve simple problems.
C205.3 Make use of exception handling mechanisms and multithreaded model to solve real world
problems
C205.4 Build Java applications with I/O packages, string classes, Collections and generics concepts
Integrate the concepts of event handling and JavaFX components and controls for developing
C205.5
GUI based applications
INDEX
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 6
www.Poriyaan.in
UNIT – 1
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 7
www.Poriyaan.in
Class is a template for a set of objects that share a common structure and a C205.1 BTL 1
common behaviour. A class is a blueprint, or prototype, that defines the variables
1 and the methods common to all objects of a certain kind.
import java.util.Vector;
class Test {
Vector vector;
Test() {
vector = new Vector();
}
}
What is the default access to a member in a class? MAY/JUNE – 2011
Default is no access specifier. For classes, and interface declarations, the
default is package private. This falls between protected and private, allowing C205.1 BTL 1
only classes in the same package access. (protected is like this, but also allowing
3 access to subclasses outside of the package.
For interface members (fields and methods), the default access is public.
But note that the interface declaration itself defaults to package private.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 8
www.Poriyaan.in
things organized by placing related classes and interfaces into packages.
{ /**
Javadoc utility enables you to keep the code and the documentation in
sync easily. The javadoc utility lets you put your comments right next to your
code, inside your ".java" source files.
All you need to do after completing your code is to run the Javadoc utility to
create your HTML documentation automatically.
Java offers four access specifiers, listed below in decreasing accessibility: C205.1 BTL 1
public
protected
default (no specifier)
private
7 Private
Private methods and fields can only be accessed within the same class to
which the methods and fields belong. private methods and fields are not visible
within subclasses and are not inherited by subclasses. So, theprivate access specifier
is opposite to the public access specifier. It is mostly used for encapsulation: data are
hidden within the class and accessor methods are provided. An example, in which
the position of the upper-left corner of a square can be set or obtained by accessor
methods, but individual coordinates are not accessible to the user.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 9
www.Poriyaan.in
public setCorner(int x, int y) { // setting values of private fields
this.x = x;
this.y = y;
}
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 10
www.Poriyaan.in
methods?
The Object’s identity – How is the object distinguished from others
that may have the same behaviour and state
C205.1 BTL 1
14
An object has behavior (it can do things and can have things done to it).
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 11
www.Poriyaan.in
What is static and dynamic binding in java ? MAY/JUNE 2014
static binding
C205.1 BTL 1
When type of the object is determined at compiled time(by the compiler), it is known
as static binding.
17
If there is any private, final or static method in a class, there is static binding.
Dynamic binding
Java supports three types of comments. The first two are the // and the /*. C205.1 BTL 1
The third type is called a documentation comment. It begins with the character
sequence /**. It ends with*/.
18 In Java have javadoc tags
Tag Meaning
@author Identifies the author of a class
@deprecated Specifies that a class or member is deprecated
@param Documents a method’s parameter
@return Documents a method’s return value
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 12
www.Poriyaan.in
What are different types of access modifiers (Access specifiers)?
Access specifiers are keywords that determine the type of access to the
member of a class. These keywords are for allowing
C205.1 BTL 1
privileges to parts of a program such as functions and variables. These are:
public: Any thing declared as public can be accessed from anywhere.
24
Private: Any thing declared as private can’t be seen outside of its class.
Protected: Any thing declared as protected can be accessed by classes in the same
package
and subclasses in the other packages.
Default modifier: Can be accessed only to classes in the same
package.
What is an Object and how do you allocate memory to it?
Object is an instance of a class and it is a software unit that combines a structured set
25 of data with a set of operations for inspecting and manipulating that data. When an
C205.1 BTL 1
object is
created using new operator, memory is allocated to it.
What gives java it’s “write once and run anywhere” nature?
27 All Java programs are compiled into class files that contain bytecodes. These byte
codes can be run in any platform and hence java is said to be platform independent.
C205.1 BTL 1
What is static variable and static method?
Static variable is a class variable which value remains constant for the entire class.
28
Static method is the one which can be called with the class itself and can hold only
C205.1 BTL 1
the static variables.
PART B
1 (i) What is a constructor? What is the use of new method? (4) NOV/DEC
2010
Refer page no: 144 C205.1 BTL 1
(ii) Give the syntax for static method and its initialization. (4) NOV/DEC
2010
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 13
www.Poriyaan.in
Refer page no: 132
(iii) Explain arrays in java. (8)
NOV/DEC 2010
Refer page no:90
4 (ii) Define package. Explain the types of package with its importance. (8)
NOV/DEC 2011,
C205.1 BTL 1
What is package? How to add a class into a package? Give example. (8)
MAY/JUNE 2013
6 Write a java program for push and pop operations in stack using arrays in
classes and object. (16)
NOV/DEC 2011 C205.1 BTL 1
Refer page no:90
Write a java program to sort ten names in descending order. (16)
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 14
www.Poriyaan.in
7 MAY/JUNE 2012
Refer notes
Refer notes
9
What is meant by package? How it is created and implemented in JAVA. (8)
NOV/DEC 2013 C205.1 BTL 1
(ii) Write a JAVA program to find the smallest number in the given list. (8)
iv) Explain the term static fields and methods and explain its types with
examples (8) APR/ MAY 2015
12 Define array. What is array sorting and explain with an example? APR/
MAY 2015
C205.1 BTL 1
C205.1 BTL 1
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 15
www.Poriyaan.in
UNIT – 2
Inheritance – Super classes- sub classes –Protected members – constructors in sub classes- the Object
class – abstract classes and methods- final methods and classes – Interfaces – defining an interface,
implementing interface, differences between classes and interfaces and extending interfaces - Object
cloning -inner classes, Array Lists – Strings
test(no,name,t1,t2,t3) // parametized
constructor
st.no = no;
st.name = name;
m1 = t1;
m2 = t2;
m3 = t3;
};
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 16
www.Poriyaan.in
class is
written with the expectation that its concrete subclasses will
add to its
structure and behaviour, typically by implementing its
abstract operations.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 17
www.Poriyaan.in
This means that the Account class cannot be a superclass
and the OverdraftAccount class can no longer be its
subclass.
8 What is Interface?
NOV/DEC 2011
An interface is basically a kind of class. Like classes, C205.2 BTL 1
interfaces contain methods and variables but but with
a major difference.The difference is that interfaces define
only abstract methods and final fields. This means that
interfaces do not specify any code to implement these
methods and data fields contain only constants
9 What is object cloning? NOV/DEC 2011 , How to
object clone? MAY/JUNE 2013, What is meant by
object cloning? NOV/DEC 2013, MAY/JUNE 2014 C205.2 BTL 1
It is the process of duplicating an object so that two
identical objects will exist in the memory at the same
time.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 18
www.Poriyaan.in
11 What are the conditions to be satisfied while declaring
abstract classes? MAY/JUNE 2012, NOV/DEC 2014
An abstract class is a class that is incomplete, or to C205.2 BTL 1
be considered incomplete.
12
An inner class is a nested class whose instance exists within C205.2 BTL 1
an instance of its enclosing class and has direct access to the
instance members of its enclosing instance
class <EnclosingClass>
{
class <InnerClass>
{
}
}
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 19
www.Poriyaan.in
16 What is the difference between String and String
Buffer?
a) String objects are constants and immutable whereas C205.2 BTL 1
StringBuffer objects are not.
b) String class supports constant strings whereas
StringBuffer class supports growable
and modifiable strings.
17 What is the difference between this () and super ()?
This () can be used to invoke a constructor of the same class
whereas super() can be C205.2 BTL 1
used to invoke a super class constructor.
18 What are interface and its use?
Interface is similar to a class which may contain method’s
signature only but not C205.2 BTL 1
bodies and it is a formal set of method and constant
declarations that must be defined
by the class that implements it. Interfaces are useful for:
a) Declaring methods that one or more classes are expected
to implement
b) Capturing similarities between unrelated classes without
forcing a class
relationship. c) Determining an object’s programming
interface without
revealing the actual body of the class.
19 Can you have an inner class inside a method and what
variables can you access?
Yes, we can have an inner class inside a method and final C205.2 BTL 1
variables can be accessed.
20 What is the difference between abstract class and
interface?
a) All the methods declared inside an interface are abstract C205.2 BTL 1
whereas abstract class must have
at least one abstract method and others may be concrete or
abstract.
b) In abstract class, key word abstract must be used for the
methods whereas interface we
need not use that keyword for the methods.
c) Abstract class must have subclasses whereas interface
can’t have subclasses.
21 What is the difference between a static and a non-static
inner class?
A non-static inner class may have object instances that are C205.2 BTL 1
associated with instances of the class's outer class. A static
inner class does not have any object instances.
22 Define superclass and subclass?
Superclass is a class from which another class inherits.
Subclass is a class that inherits from one or more classes. C205.2 BTL 1
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 20
www.Poriyaan.in
23 What is reflection API? How are they implemented?
Reflection is the process of introspecting the features and
state of a class at runtime C205.2 BTL 1
and dynamically manipulate at run time. This is supported
using Reflection API with builtin
classes like Class, Method, Fields, and Constructors etc.
Example: Using Java Reflection
API we can get the class name, by using the
getName method.
24 What is the useful of Interfaces?
a) Declaring methods that one or more classes are expected
to implement C205.2 BTL 1
b) Capturing similarities between unrelated classes without
forcing a class relationship.
c) Determining an object’s programming interface without
revealing the
actual body of the class.
25 Define Protected members
Protected Access Modifier - Protected. Variables,
methods, and constructors, which are declared protected in C205.2 BTL 1
a superclass can be accessed only by the subclasses in other
package or any class within the package of the protected
members' class. The protected access modifier cannot be
applied to class and interfaces.
26 What is object cloning in java
clone() is a method in the Java programming language for
object duplication. In java, objects are manipulated through C205.2 BTL 1
reference variables, and there is no operator for copying an
object—the assignment operator duplicates the reference,
not the object. The clone() method provides this missing
functionality.
27 Write short notes on final classes and methods?
the final keyword in a method declaration to indicate that
the method cannot be overridden by subclasses. The Object C205.2 BTL 1
class does this—a number of its methods are final.
class ChessAlgorithm {
enum ChessPlayer { WHITE, BLACK }
...
final ChessPlayer getFirstPlayer() {
return ChessPlayer.WHITE;
}
...
}
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 21
www.Poriyaan.in
keyword is used for a class to implement a certain
interface, while Extends keyword is used for a subclass to
extend from a super class.
29 List out the types of inheritance in java
PART B
1 Explain with an example the following features of
Constructors: (16) MAY/JUNE 2011
(i) Overloaded constructors C205.2 BTL 1
(ii) A Call to another constructor with this operator
(iii) An object initialization block
(iv) A static initialization block
Refer page no: 144
2 How Strings are handled in java? Explain with code, the
creation of Substring, Concatenation and testing for
equality.(16) C205.2 BTL 1
MAY/JUNE 2011
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 22
www.Poriyaan.in
5 What is meant by constructor? Describe the types of constructors
supported by Java with example? NOV/DEC 2014
Refer page no: 144 C205.2 BTL 1
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 23
www.Poriyaan.in
UNIT – 3
Exceptions - exception hierarchy - throwing and catching exceptions – built-in exceptions, creating own
exceptions, Stack Trace Elements. Input / Output Basics – Streams – Byte streams and Character streams
– Reading and Writing Console – Reading and Writing Files
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 24
www.Poriyaan.in
Occurrence of any kind of exception in java
applications may result in an abrupt termination of
the JVM or simply the JVM crashes which leaves
the user unaware of the causes of such anomalous
conditions. However Java provides mechanisms to
handle such situations through its superb exception
handling mechanism. The Java programming
language uses Exception classes to handle such
erroneous conditions and exceptional events.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 25
www.Poriyaan.in
7 what are checked and unchecked exceptions in java?
The exceptions which occur at run time are called as C205.3 BTL 1
run time exceptions. These exceptions are unknown to
compiler. All sub classes of
java.lang.RunTimeException and java.lang.Error are
run time exceptions. These exceptions are unchecked
type of exceptions. For example,
NumberFormatException, NullPointerException,
ClassCastException,
ArrayIndexOutOfBoundException,
StackOverflowError etc.
9 There are three statements in a try block – statement1,
statement2 and statement3. After that there is a catch
block to catch the exceptions occurred in the try block. C205.3 BTL 1
Assume that exception has occurred in statement2.
Does statement3 get executed or not?
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 26
www.Poriyaan.in
11 What are Byte Stream in Java?
The byte stream classes provide a rich environment for
handling byte-oriented I/O. C205.3 BTL 1
List of Byte Stream classes
§ ByteArrayInputStream
§ ByteArrayOutputStream
§ FilteredByteStreams
§ BufferedByteStreams
12 How to read strings of text from a file ?
Open the file for reading by creating an object of
the class FileReader and an object of the class C205.3 BTL 1
BufferedReader associated to the FileReader
object we have just created;
2. Read the lines of text from the file by using the
readLine() method of the BufferedReader
object;
3.close the file when we are finished reading from
it.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 27
www.Poriyaan.in
block.
17 How is custom exception created? [2 Marks]
By extending the exception class or one of its
subclasses C205.3 BTL 1
Example
Class MyException extends Exception
{
Public MyException(){super();}
Public MyException(String s){super(s);}
}
18 Mention the stream I/O operations.
Stream I/O operations involve three steps:
1. Open an input/output stream associated with a C205.3 BTL 1
physical device (e.g., file, network, console/keyboard),
by constructing an appropriate I/O stream instance.
2. Read from the opened input stream until "end-of-
stream" encountered, or write to the opened output
stream (and optionally flush the buffered output).
3. Close the input/output stream.
19 What is stream?
A stream is a sequential and contiguous one-way flow
of data.Java does not differentiate between the various C205.3 BTL 1
types of data sources or sinks (e.g., file or network) in
stream I/O.
20 Mention the different ways to generate an
Exception?
There are two different ways to generate an C205.3 BTL 1
Exception.
1. Exceptions can be generated by the Java run-time
system.
Exceptions thrown by Java relate to fundamental
errors that violate the rules of the
Java language or the constraints of the Java execution
environment.
2. Exceptions can be manually generated by the code.
Manually generated exceptions are typically used to
report some error condition to
the caller of a method.
21 What is OutOfMemoryError in java?
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 28
www.Poriyaan.in
23 Give some examples to unchecked exceptions?
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 29
www.Poriyaan.in
// ArithmeticException
class ArithmeticException_Demo {
public static void main(String args[])
{
try {
int a = 30, b = 0;
int c = a / b; // cannot divide by zero
System.out.println("Result = " + c);
}
catch (ArithmeticException e) {
System.out.println("Can't divide a number by
0");
}
}
}
30 Give any two methods available in Stack trace Element
NOV/DEC 2010.
public final class StackTraceElement C205.3 BTL 1
extends Object
implements Serializable
PART B
1 (ii) Explain the exception hierarchy.
(8) NOV/DEC 2010
C205.3 BTL 1
Refer page no:553
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 30
www.Poriyaan.in
Refer page no:571
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 31
www.Poriyaan.in
UNIT – 4
Differences between multi-threading and multitasking, thread life cycle, creating threads, synchronizing
threads, Inter-thread communication, daemon threads, thread groups. Generic programming – Generic
classes – generic methods – Bounded Types – Restrictions and Limitations.
Timed waiting: A runnable thread can enter the timed waiting state
for a specified interval of time. A thread in this state transitions back
to the runnable state when that time interval expires or when the event
it is waiting for occurs.
Every Java object with a critical section of code gets a lock associated with
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 32
www.Poriyaan.in
the object. To
synchronized(object) {
// statements to be synchronized
3 Mention the two mechanisms for protecting a code block from concurrent
access. MAY/JUNE 2011
Java 5 introduces general purpose synchronizer classes, including C205.4 BTL 1
semaphores, mutexes, barriers, latches, and exchangers, which facilitate
coordination between threads. These classes are a apart of the
java.util.concurrent package
C205.4 BTL 1
A thread is a program's path of execution. Most programs written today run as a
single thread, causing problems when multiple events or actions need to occur
at the same time. Let's say, for example, a program is not capable of drawing
pictures while reading keystrokes. The program must give its full attention to
the keyboard input lacking the ability to handle more than one event at a time.
The ideal solution to this problem is the seamless execution of two or more
sections of a program at the same time.
5 What is multithreading. NOV/DEC 2011 , MAY/JUNE – 2012,
MAY/JUNE 2013, NOV/DEC 2014
Multithreading enables us to write very efficient programs that make C205.4 BTL 1
maximum use of the CPU, because idle time can be kept to a minimum.
wait( ): This method tells the calling thread to give up the monitor
and go to sleep until some other thread enters the same monitor and
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 33
www.Poriyaan.in
calls notify( ).
notify( ): This method wakes up the first thread that called wait( )
on the same object.
notifyAll( ): This method wakes up all the threads that called wait( )
on the same object.c The highest priority thread will run first.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 34
www.Poriyaan.in
12 What are the properties of a thread ? NOV/DEC 2014
runnable: the object whose run() method is run on the thread
C205.4 BTL 1
name: the name of the thread (used mainly for logging or other diagnostics)
id: the thread's id (a unique, positive long generated by the system when the
thread was created)
daemon: the thread's daemon status. A daemon thread is one that performs
services for other threads, or periodically runs some task, and is not expected to
run to completion.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 35
www.Poriyaan.in
16 How Generics works in Java ? What is type erasure ?
There are mainly 3 advantages of generics. They are as follows: C205.4 BTL 1
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 36
www.Poriyaan.in
Thread waiting on a condition variable MW - Thread waiting on a
monitor lock MS - Thread suspended waiting on a monitor lock
22 What method must be implemented by all threads? [2 Marks]
All tasks must implement the run() method, whether they are a subclass
of thread or implement the runnable interface. C205.4 BTL 1
23 Define Multitasking
Process-based Multitasking(Multiprocessing)
Thread-based Multitasking(Multithreading)
wait() sleep()
wait() method releases the lock sleep() method doesn't release the lock.
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 37
www.Poriyaan.in
30
How to perform single task by multiple threads?
C205.4 BTL 1
If you have to perform single task by many threads, have only one run() method.
For example:
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 38
www.Poriyaan.in
PART B
1 (i) What is a thread? Explain its states and methods. (8) NOV/DEC 2010 C205.4 BTL 1
Refer page no:716
(ii) Explain thread properties. (8) NOV/DEC 2010
Refer page no:733
2 (i) Explain the methods of interrupting threads in java. (8) C205.4 BTL 1
NOV/DEC 2010
(ii) What is Event-driven programming? Explain. (8)
NOV/DEC 2010, MAY/JUNE 2014
Refer page no:728
3 Explain the procedure for running a task in a separate thread and running C205.4 BTL 1
multiple threads. (16) MAY/JUNE 2011
Refer page no:731
4 Explain the states of threads and how the thread is interrupted? C205.4 BTL 1
MAY/JUNE 201, MAY/JUNE 2014, NOV/DEC 2014
5 (i) Explain how threads are created in Java. (8) NOV/DEC 2011 C205.4 BTL 1
(ii) Write about various threads states in Java. (8) NOV/DEC 2011
7 Explain the following (i) States of a thread with a neat diagram. [10] C205.4
MAY/JUNE 2012
(ii) Thread priorities. (6) MAY/JUNE 2012
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 39
www.Poriyaan.in
UNIT – 5
Graphics programming - Frame – Components - working with 2D shapes - Using color, fonts, and mages
- Basics of event handling - event handlers - adapter classes - actions - mouse events - AWT event
hierarchy - Introduction to Swing – layout management - Swing Components – Text Fields , Text Areas –
Buttons- Check Boxes – Radio Buttons – Lists- choices- Scrollbars – Windows –Menus – Dialog Boxes.
C205.5 BTL 1
• the JVM has no instantiations of generic types
• a generic type definition is compiled once only, and
a corresponding raw type is produced
– the name of the raw type is the same name but type
variables removed
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 40
www.Poriyaan.in
Ex: public class Pair<T>
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 41
www.Poriyaan.in
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 42
www.Poriyaan.in
getUIClassID()
Returns a string that specifies the name of the L&F class that
renders this component.
isDefaultButton()
isDefaultCapable()
paramString()
extends Object
implements WindowListener
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 43
www.Poriyaan.in
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 44
www.Poriyaan.in
Direct Known Subclasses:
AbstractColorChooserPanel, JSpinner.DefaultEditor
22 What is the function of
NOV/DEC 2010
a. Set Layout - The SetLayout function changes the C205.5 BTL 1
layout of a device context (DC).
b. Flow Layout
Button( )
Button( String str)
BorderLayout( )
BorderLayout(int horz, int vert)
The Font Class is used to render ‘glyphs’ - the characters you see C205.5 BTL 1
on the screen. FontMetrics encapsulates information about a
specific font on a specific Graphics object. (width of the characters,
ascent, descent)
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 45
www.Poriyaan.in
27 How would you create a button with rounded edges?
There’s 2 ways. The first thing is to know that a JButton’s edges C205.5 BTL 1
are drawn by a Border. so you can override the Button’s
paintComponent(Graphics) method and draw a circle or rounded
rectangle (whatever), and turn off the border. Or you can create a
custom border that draws a circle or rounded rectangle around any
component and set the button’s border to it.
29 What is an event and what are the models available for event
handling?
C205.5 BTL 1
An event is an event object that describes a state of change in a
source. In other words, event occurs when an action is generated,
like pressing button, clicking mouse, selecting a list, etc. There are
two types of models for handling events and they are: a) event-
inheritance model and b) event-delegation model
PART B
1 Explain about the concepts of creating and positioning of frame (8)
APR/MAY 2015
C205.5 BTL 1
2 Define Event handling write a program to handle a button event(8)
APR/MAY 2015 C205.5
BTL 1
3 Explain the classes under 2D shapes. Working with 2D Shapes
C205.5 BTL 1
4 Explain event handling with examples. EVENT HANDLING
C205.5
BTL 1
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 46
www.Poriyaan.in
5 Explain action event with an example. Actions
C205.5 BTL 1
6 What are the swing components? Explain. Swing Component
C205.5 BTL 1
7 Describe the AWT event hierarchy. The AWT Event Hierarchy
C205.5 BTL 1
8 Give the methods available in graphics for COLOR and FONTS
Color and fonts Using Color
C205.5 BTL 1
https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 47
Object Oriented Programming
Physics
Basic for Engineering
Electrical and Data Structure
Problem Solving and Science Engineering
Electronics
Python Programming Object Oriented
Programming in C
Programming
Elective-Management
Professional Elective II
Professional Elective IV