CS-504D Wbut Questions
CS-504D Wbut Questions
t
t
p
:
/
/
q
p
a
p
e
r
.
w
b
u
t
.
a
c
.
i
n
Name :
Roll No. : ..
Invigilators Signature : ..
CS/ B. TECH (CSE) (N)/ SEM-5 / CS-5 0 4 D/ 2 0 1 2 -1 3
2 0 1 2
OBJ ECT ORIENTED PROGRAMMING
Time Allotted : 3 Hours Full Marks : 70
The figures in the margin indicate full marks.
Candidates are required to give their answers in their own words
as far as practicable.
GROUP A
( Mult iple Choic e Type Que s t ions )
1. Choose the correct alternatives for any ten of the following :
10 1 = 10
i) Which one of the following statements is wrong?
a) A base class reference can refer to an object of a
derived class
b) The dynamic method dispatch is not carried out at
the run time
c) The super( ) construct refers to the base class
constructor
d) The super.base-class-method-name( ) format can
be used only within a derived class.
5405 (N) [ Turn over
h
t
t
p
:
/
/
q
p
a
p
e
r
.
w
b
u
t
.
a
c
.
i
n
CS/B.TECH (CSE) (N)/SEM-5/CS-504D/2012-13
ii) A sub-class having more than one super class is called
a) category b) classification
c) combination d) partial participation.
iii) Out of the following which one is not correctly
mached?
a) Int 24 bits
b) Short 16 bits
c) Double 64 bits
d) Byte 8 bits.
iv) What is the correct ordering for the import, class and
package declarations when found in a single file ?
a) Package, import, class
b) Class, import, package
c) Import, package, class
d) Package, class, import.
v) Which one of the following statements is not correct?
a) An interface can inherit another interface.
b) The package name and subdirectory name need
not be identical.
c) Only the classes declared as public in a package
are accessible outside that package.
d) The import java.awt. ; directive will not import
classes in java.awt.event package.
5405 (N) 2
h
t
t
p
:
/
/
q
p
a
p
e
r
.
w
b
u
t
.
a
c
.
i
n
CS/B.TECH (CSE) (N)/SEM-5/CS-504D/2012-13
vi) What results from the following fragment of code ?
1. int x = 1 ;
2. String [ ] names = { Fred, Jim, Sheila } ;
3. names[ x ] + = . ;
4. for ( int i = 0 ; i < names. length ; i ++) {
5. system.out.println (names[ i ] ) ;
6. }
a) The ouput includes Fred. with a trailing period.
b) The output includes Jim. with a trailing period.
c) The output includes Sheila. with a trailing period.
d) None of the outputs shows a trailing period.
e) An ArrayIndexOutOfBoundsException is thrown.
vii) What is the output of this code fragment ?
1. int x = 3 ; int y = 10 ;
2. System.out.println ( y % x ) ;
a) 0 b) 1
c) 2 d) 3.
viii) Which of the following statements is correct ?
a) The try block should be followed by a catch
block.
b) The try block should be followed by a finally
block.
c) The try block should be followed by either a
catch block or a finally block.
d) The try block should be followed by at least two
catch blocks.
5405 (N) 3 [ Turn over
h
t
t
p
:
/
/
q
p
a
p
e
r
.
w
b
u
t
.
a
c
.
i
n
CS/B.TECH (CSE) (N)/SEM-5/CS-504D/2012-13
ix) The wait( ) and notify( ) methods are used to perform
a) Interthread communication
b) Synchronisation
c) Deadlock
d) all of these.
x) If a data-item is declared as a protected access
specifier then it can be accessed
a) anywhere in the program
b) by the base and derived classes
c) only by base classes
d) only by derived classes.
xi) Which one of the following is wrong ?
a) Runnable is a predefined interface.
b) The sleep( ) method instructs a thread to terminate
its execution.
c) The isAlive( ) method tells whether a thread has
not yet died.
d) MAX_PRIORITY represents the level 10.
xii) What type of following stream is used to read binary
data?
a) InputStream b) InputStreamReader
c) DataInputStream d) None of these.
5405 (N) 4
h
t
t
p
:
/
/
q
p
a
p
e
r
.
w
b
u
t
.
a
c
.
i
n
CS/B.TECH (CSE) (N)/SEM-5/CS-504D/2012-13
GROUP B
( Short Ans we r Type Que s t ions )
Answer any three of the following. 3 5 = 15
2. Write down a program to implement Command Line
arguments.
3. What are the main characteristics of OOP Language ?
Explain each.
4. How does string class differ from String buffer class ?
5. What are Implicate and Explicit Casting ? Explain with the
help of example. 2 + 3
6. What is the difference between error and exception ? What
are the benefits of organizing classes into packages ?
2
1
2
+ 2
1
2
GROUP C
( Long Ans we r Type Que s t ions )
Answer any three of the following. 3 15 = 45
7. a) What is mutable strings ?
b) What are the benefits of organising classes into
package?
c) How can you create your own package and add classes
in that ? Explain with the help of an example.
d) Explain with the help of an example, how java gets
benefited by using Interface ? 2 + 2 + ( 2 + 3 ) + 6
5405 (N) 5 [ Turn over
h
t
t
p
:
/
/
q
p
a
p
e
r
.
w
b
u
t
.
a
c
.
i
n
CS/B.TECH (CSE) (N)/SEM-5/CS-504D/2012-13
8. Write short notes on any three of the following : 3 5
a) Wrapper Class
b) Meta class
c) String Tokenizer Class
d) getCodeBase( ) methods.
9. a) Explain the life cycle of an Applet.
b) List various attributes of Applet tag used in HTML.
Explain the purpose of these attributes.
c) Write a Java program that uses the draw Polygon( )
metod of Graphics class to draw a triangle with
endpoints (25, 30 ) ; ( 75, 80 ) and ( 50, 50 ).
3 + ( 3 + 3 ) + 6
10. a) Why does Java have two ways to create child threads
(by extending Thread or implementing Runnable ) and
which approach is better ?
b) Define an exception called NotEqualException that is
thrown when a float value is not equals to 314 write a
program that uses that user defined exception.
c) Write a Multithreading program to generate the square
roots to the first 30 natural numbers using Runnable
interface.
d) What do you mean by Synchronization ? Why do we
need it ? 2 + 5 + 5 + 3
5405 (N) 6
h
t
t
p
:
/
/
q
p
a
p
e
r
.
w
b
u
t
.
a
c
.
i
n
CS/B.TECH (CSE) (N)/SEM-5/CS-504D/2012-13
11. a) How applet is different from frame and panel ? Explain.
b) How threads are made to communicate with each
other? Explain with example.
c) Explain any three events with suitable example.
5 + 5 + 5
5405 (N) 7 [ Turn over