0% found this document useful (0 votes)
5 views

javaofflinesample

The document is an examination paper for a B.Sc.(H) Computer Science course focusing on programming in Java. It includes instructions for candidates, a compulsory Section A with various questions on Java concepts, and Section B with additional topics related to object-oriented programming and exceptions. The paper tests knowledge on Java's features, error handling, multithreading, and method overloading, among other topics.

Uploaded by

KASHISH MADAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

javaofflinesample

The document is an examination paper for a B.Sc.(H) Computer Science course focusing on programming in Java. It includes instructions for candidates, a compulsory Section A with various questions on Java concepts, and Section B with additional topics related to object-oriented programming and exceptions. The paper tests knowledge on Java's features, error handling, multithreading, and method overloading, among other topics.

Uploaded by

KASHISH MADAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Name of the Paper : Programming in JAVA

Name of the Course B.Sc.(H) Computer Science (CBCS)


Semester
Maximum Marks:75
Duration 3 Hours

Instructions for Candidates


1. Write your Roll No. on the top immediately on receipt of this question paper.
2. Section A is compulsory.
Section B
3. Attempt any four questions from

SECTION A

1. 2)
a) Why JAVA is called platform independent language?
(5)
b. What are the features of Java programming languag?

main(String[] args). mean? 2)


c) .What does each term in "public státie void.

code: (2x4)
d Give output ofthe following
i public class A
public static voidmain(String args[ })
String sl = "abc";
"

String s2= "def";


String s3 = s2,

s2 "ghi"
System.out.println(s1 + s2 + s3);
(2.)

ii. class BoolTest

public static void main(String args[ })

Boolean bl =
new Boolean("false");
boolean b2:
b2 b1.boolean Value():
if(!b2)
b2 true
System.out.print("x ");

if(bl & b2)

System.out.print("y "):

System.out.println("z");

.
ii. public class X

public static void main(String args[ })

try

badMethod()
System.out.print("A"):

catch (Exception ex)

System.out.print(B");.

finally
System.out.print("C");

System.out.print("D");

public static void badMethod()


throw new RuntimeException();
(3)

iv. classA

static int s;
public static void main(String args[ })

Test p new Test():


p.start()
System.out.println(s);

void start()

int x= 7;
twice(x);
System.out.print(x + " ");

void twice(int x)

x x*2;

e) How will JAVA handBe convérsion between two incompatible primitive data
types?ExpBain with Example.. (4)

f What are the several type promötion rules that apply to expressions?
.
(2)
g) What is the purpose of the unsigned right shift operator? Give Example (2)

h) How does the JAVA for-each loop works? (2)

in the following code: (2x4)


i) Point out error
.i. class A

public A(int x){}

cass B extends A { }
(u)

public class test

public static void main (String args| })

A a = new B():

System.out.println("complete"):

ii. class A

static int X,
boolean catch()
R
Xt+;
return true;

public static void main(String args[ })

x=0;
if(catch()|catch()) || catch())
Xt+;
System.out.println(x);

ii. class P

public static void main(String args[})


'

ry
int a=0;
intb-21/a:

catch(Exception e)

System.out.printIn( "exception caught" );

catch(ArithmeticException e)

);
System.out.println( "Finally exception catch"
(5)

iv. class Q

public static void main(String args[ ])

byte x = 50;

byte y = 50;

byte z = 100;

y =y 2;
int g =X y/z;

SECTION B

(3)
concepts example.
with
2. a) Explain the oops (4)
b) What is the use of super keyword? Give Example
two different
(1+2)
List the
c) What is Multithreaded programming?
types of multitasking

(5)
between final, finally and finalize?
3. a) What are the difference (3)
and Unboxing?
b) Define Autoboxing (2)
cass?
c) Define Type Wrapper
(1+2)
the ambiguities that can arise
by varags? VWhat
are
4 a) What do you.mean method?,
. when we overload the varags .
class with
methods. where distance
to reate a distance
b): Write a program make
of feet and inehes.ceate object ofclass and
is computed in terms
use of this pointer. (2)
c) Define Annotations
(2x3)
the following
5. a) Differentiate between
throws
i. throw and
Interface
ii. abstract and (4)
four of them.
Unchecked Exceptions? List any
b) What are
(5)
Explain with a help of an example. (5)
Chained Exception. switch takes place
6. a) Define determine when will a context
the rules that
b) List and expBain
(6)

7. a) Define dynamic method dispatch with an example" (5)

b) Write the output of the following: (5)


Class A

public void methodA()

System.out.println("method of Class A"):

Class B extends A

public void methodB()

System.out.println("method of Class B"):

Class C extends A

public void methodC(0

System.out.println("nmethod of Class C"):

Class D extends A

public void methodD) ...

System.out.println("method of Class D");

Class MyClass
public void methodB)

System.out.println("method of Class B")

public static void main(Stringargs[ })


B objl = new BO;
C obj2 = new C();
D obj3 new DO;
objl.methodA();

obj2.methodA();
obj3.methodA0;

You might also like