Bachelor of Computer Application (BCA) Community Share and Help

Solved Question Paper BCA303

Internet Technologes and Programming


Gujarat University TY BCA Solved Question Papper of April 2009 : Total Marks 70 Duration : 3 hrs
1 Answer the following. 14
(A) Attempt any two 6
1 Write short note on thread life cycle.
Answer:
There are different states in thread life cycle.
   newborn
   runnable
   running
   blocked
   dead
Newborn
   When a thread is created, it is in a newborn state. In this state the thread will not be executed.
Runnable
   When the start() method is called on the thread object, the thread is in runnable state. A runnable thread can not necessarily be executed by CPU. A runnable thread joins the collection of threads that are ready for execution. Which runnable thread takes up the CPU is determined by the underlying operating system.
Running
   A thread currently being executed by the CPU is in running state.
Blocked
   A running thread may go to a blocked state due to any of the following condition
      Wait method is called by the thread.
      The thread performs the I/O operation.
      Sleep method is called by the thread.
Dead
   A thread becomes dead on two occasions. In the first case, a thread completes its task, exits the running state and becomes dead.
2 Explain various methods of thread class.
Answer:
String getName()
   Returns the name of the invoking thread object.
Bollean isAlive()
   Returns true if the thread has started and has not yet terminated.
Void join()
   Waits for a thread to terminate.
Void run()
   Contains the statements that are to be executed in a thread.
Void start()
   Starts a thread by calling the run() method.
Void sleep(long ms)
   Makes the currently executing thread to sleep for ms milli seconds.
3 Explain the concept of thread priorities in Java.
Answer:
   The priorities are used by the operating system to find out which runnable thread is to be given the CPU time. There are three pre-defined priorities.
      MIN_PRIORITY with a value 1
      NORM_PRIORITY with a value 5
      MAX_PRIORITY with a value 10
(B) Answer the following (Any one) 4
1 Explain various access modifiers and their visibility.
Answer:
   One of the key features of java language is its encapsulation. This feature helps to protect data and method to extent you want. Such a feature is not available in non-oop languages. This feature in java is implemented through access modifiers.
   Access modifiers and their visibility:
   Modifiers                 Visibility
   Private               Visible only to the class
   Protected          Visible to the subclasses in any package and to all classes in the same.
   Public                Visible to the subclasses in any package and to all classes in the same.
   Default              Visible only to the same package.
2 Answer the following 14
(A) Answer the following (Any two) 8
1 Write a short note on data types of Java.
Answer:
   Java supports eight basic types. The eight basic types fall under the following four groups:
      Integer
      Floating point numbers
      Characters
      Boolean
Integer Types
   Integers in java are handled in four basic types:
      Byte
      int
      short
      long
   Byte
      Byte is the lowest size integer. Byte is signed and is 8-bit width. It has a range from 128 to 127. Byte variables are declared by the keyword byte.
      Ex. Byte a, buff;
   int
      The int type is a signed integer of 32-bit width. It takes up the value from -2147483648 to 247483647.
      Ex. Int n, numb;
   short
      Short type is 16-bit width and is signed. It takes the value from -32768 to 32767. The short type integers are declared by the keyword short.
      Ex. Short Sn, num;
   long
   The long type is a signed integer of 64-bit width. It takes up the value from -9229972036854775808 to 9229972036854775807.
   Ex. Long factorial, star count;
Floating point types
   Numbers with fractional values are called floating point numbers and are known as real numbers in older languages like FORTRAN. The floating point numbers are represented in two forms:
      Float
      Double
   Float
      In float type, the numbers are specified in 32-bit width. It takes value from 3.43e-038 to 3.4e+038.
      Ex. Float x, area;
   Double
      The double type floating point numbers are represented in 64-bit width. This is a double precision representation. It takes value from 1.7e-308 to 1.7e+308.
      Ex. Double volume, average;
Character type:
   Single characters are handled by char type. It is a 16-bit code. It can represent 65,536 distinct characters. This 16-bit representation of characters is called Unicode.
      Ex. Char choice, flag;
Boolean type:
   The logical values true and false are handled by Boolean type. The Boolean values true and false are not associated with any numerical value.
      Ex. Boolean flag, full, empty;
3 Write short note on bitwise operators of Java.
Answer:
Bitwise operators
   Bitwise operators are used to multipulate individual bits of a data item. There are situations where individual bits of a data are to be modified. Java provides a set of bitwise operators.
   Operation                     Operator symbol
   Private                   Visible only to the class
   Protected          Visible to the subclasses in any package and to all classes in the same.
   Public                Visible to the subclasses in any package and to all classes in the same.
   Default              Visible only to the same package.
(B) Answer the following (Any three) 8
1 Explain any two feature of Java.
Answer:
Platform independent and portable:
The most significant contribution of java over other languages is its portability java programs can be easily moved from one computer system to another, any where and anytime.
Object – oriented:
Java is a true object oriented language. Almost everything in java is an object. All programs code and data reside within objects & classes. The object model in java is simple and easy to extend.
2 Explain the terms bytecode and JVM.
Answer:
byte code
Java compiler produces an intermediate code known as byte code for a machine that does not exist. This machine is called java virtual machine and it exists only inside the computer memory. It is a simulated computer within the computer and dose all major functions of a real computer.
JVM
The Java object frame work acts as the intermediary between the user program sand the virtual machine which is in turn acts as the intermediary between the operating system and the java object framework.
5 Explain various types of comments supported by Java.
Answer:
Single line comment //
Multiline comments /* */
3 Answer the following. 14
(A) Attempt any two 6
2 Write a short note on Random Access File class.
     The Random Access File class supported by the Java.io package allows us to create files that can be used for reading and writing data with random access. That is, we can “jump around” in the file while using the file. Such files are known as random access files.
    Random access files support a pointer known as file pointer that can be moved to arbitrary positions in the file prior to reading or writing. The file pointer is moved using the method seek() in the Random Access File class
4 Answer the following. 14
(A) Attempt any two : 6
1 Explain final class, abstract class and super class.
Answer:
Final class
    Inheritance allows creation of subclasses. However, if need arise, inheritance can be prevented by declaring a class as final. A class declared as final can not have subclasses.
Abstract class
    Java allows defining of methods without body and such methods are called abstract methods. Abstract methods are defined with a key word abstract. Classes containing at least one abstract method are called abstract class.
    When abstract class is defined, a subclass of the abstract class must give a concrete method. Otherwise, the subclass also becomes an abstract class.
Super class
    It is a generalization of another class. Like X is a super class of Y if Y inherits variables and methods from X.
(C) Fill in the blanks. 5
1 New operator is used to create an array.
2 Static method can be called without the instance of a class.
3 When an interface method is implemented in a class. it must be declared asPublic .
5 Answer the following . 14
(A) Attempt any five : 10
1 Give the class hierarchy of an Applet class.
 
2 Explain the start() and stop() methods of applet life cycle.
Answer:
start()
Applet enters the running state when the system calls the start() of applet class.
stop()
Used to terminate the thread.
4 Give the exception hierarchy of Java.
Answer:
  Try
      {statement}
   catch (exception-type e)
       { statement}
5 Explain the use of throw and throws keywords.
Answer:
In java throw is used to inform that an error is occurred.
7 What is delegation event model?
Answer:
The modem approach is based on delegation event model, which defines standard and consistent mechanism to create and process events.