Download CUSTOMER_CODE SMUDE DIVISION_CODE SMUDE

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CUSTOMER_CODE
SMUDE
DIVISION_CODE
SMUDE
EVENT_CODE
Oct2016
ASSESSMENT_CODE BCA4020_Oct2016
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
72589
QUESTION_TEXT
a.
b.
SCHEME OF
EVALUATION
Addresses on WWW are represented in Java by URL objects. A URL
represents any type of information which has to be linked with web. The
URL is set up to perform certain activities when a connection is made to
it such as loading a web page or downloading a file. URLs are a bit more
user friendly to work with than the sockets. (2 marks)
a. The URL Class: The URL class transforms a URL string into an
object that can then be manipulated using associated methods. These
methods serve purposes such as getting the filename, protocol, and
hostname. URL also has methods that can open and maintain the data
connection of an input stream.
b. URLConnection Class: URL Connection Class is another abstract
class used to create and control a connection to a platform and firewall
Specific location. It is a simplified version of connection interface for the
URL class.
c. The URLEncoder Class: the URLEncoder Class takes a string a text
and turns it into the x-www-form-urlencoded format, which is a MIME
format. This can then be used in conjunction with the URL class.
d. The URLStreamHandler Class: The URLStreamHandler Class is an
abstract class. Its purpose is to create a format for opening a stream
connection to a specific URL. This class is concerned with the protocol of
the URL. If programmer wants to create a new URL stream protocol, it is
necessary to implement the methods specified in this abstract class.
(2 marks each)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
72590
QUESTION_TEXT
What is inheritance? Explain the types of relationships supported in
Java inheritance with example.
SCHEME OF
EVALUATION
Inheritance is one of the cornerstones of object-oriented programming,
because it allows the creation of hierarchical classifications. Using
What is an URL Object in java?
Explain the various URL objects.
inheritance, you can create a general class that defines traits common
to a set of related items. This class can then be inherited by other, more
specific classes, each adding those things that are unique to it. In the
terminology of Java, a class that is inherited is called a superclass. The
class that does the inheriting is called a subclass. Therefore, a subclass
is a specialized version of a superclass. It inherits all of the instance
variables and methods defined by the superclass and add its own,
unique elements. (1 mark)
Types of Relationships
Relationships are classified as follows:

A Kind-Of relationship

A Is-A relationship

A Part-Of-relationship

A Has-A relationship
(For each point with explanation and example – 2 marks)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
72593
QUESTION_TEXT
What are the various methods available in RemoteObject class.
*
*
*
*
*
SCHEME OF EVALUATION *
*
*
*
*
*
RemoteArray
RemoteBoolean
RemoteByte
RemoteChar
RemoteClass
RemoteDouble
RemoteField
RemoteFloat
RemoteInt
RemoteLong
RemoteShort
* RemoteString
* RemoteThread
* RemoteThreadGroup
* RemoteValue
Any 10 methods = 10 marks.
(1* 10 =Total 10 marks)
QUESTION_TYPE DESCRIPTIVE_QUESTION
QUESTION_ID
120578
QUESTION_TEXT
What is a package in Java? How do you define a package in Java?
Explain the class member access permissions in Java.
Java provides a mechanism for partitioning the class name space into
more manageable chunks. This mechanism is the package. The package is
both a naming and a visibility control mechanism. (1 Mark)
Defining a Package:
Include a package command as the first statement in a Java source file.
Any classes declared within that file will belong to the specified package.
The package statement defines a name space in which classes are stored.
If you omit the package statement, the class names are put into the default
package, which has no name. The general form of the package statement:
package pkg;
SCHEME OF
EVALUATION
Here, pkg is the name of the package
For example, the following statement creates a package called
MyPackage.
package MyPackage;
We can create a hierarchy of packages. To do so, simply separate each
package name from the one above it by use of a period
The general form of a multileveled package statement is :
package pkg1[.pkg2[.pkg3]];
For example, a package declared as package java.awt.image; needs to be
stored in java/awt/image, java\\awt\\image, or java:awt:image on your
UNIX, Windows, or Macintosh file system, respectively. (4 Marks)
Access Protection:
(5 marks)
QUESTION_TYPE DESCRIPTIVE_QUESTION
QUESTION_ID
120579
Briefly explain the various constants and methods used in
QUESTION_TEXT i.
ii.
i.
SCHEME OF
EVALUATION
ActionEvent class
AdjustmentEvent class
ActionEvent Class:
An ActionEvent is generated when a button is pressed, a list item is
double-clicked, or a menu item is selected. The ActionEvent class defines
four integer constants that can be used to identify any modifiers
associated with an action event: ALT_MASK, CTRL_MASK,
META_MASK, and SHIFT_MASK. In addition, there is an integer
constant, ACTION_PERFORMED, which can be used to identify action
events. (2 Marks
)
ActionEvent has these three constructors:
ActionEvent(Object src, int type, String cmd)
ActionEvent(Object src, int type, String cmd, int modifiers)
ActionEvent(Object src, int type, String cmd, long when, int modifiers)
Here, src is a reference to the object that generated this event. The type of
the event is specified by type, and its command string is cmd. The
argument modifiers indicates which modifier keys (ALT, CTRL, META,
and/or SHIFT) were pressed when the event was generated. The when
parameter specifies when the event occurred. You can obtain the
command name for the invoking ActionEvent object by using the
getActionCommand( ) method, shown here:
String getActionCommand( )
For example, when a button is pressed, an action event is generated that
has a command name equal to the label on that button. (3 marks)
ii.
AdjustmentEvent class
An AdjustmentEvent is generated by a scroll bar. The AdjustmentEvent
class defines integer constants that can be used to identify them.
(2 Marks)
In addition, there is an integer constant,
ADJUSTMENT_VALUE_CHANGED that indicates that a change has
occurred.
The constructor:
AdjustmentEvent(Adjustable src, int id, int type, int data)
src is a reference to the object that generated this event. The id equals
ADJUSTMENT_VALUE_CHANGED
The type of the event is specified by type, and its associated data is data.
The getAdjustable( ) method returns the object that generated the event.
The type of the adjustment event may be obtained by the
getAdjustmentType( ) method. (3 Marks)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
120581
a.
What are the rules for overriding a method in Java?
b.
Write any three uses of Inheritance.
QUESTION_TEXT
a.
1.
The method name and the order of arguments should be identical
to that of the superclass method.
2.
The return type of both the methods must be the same.
3.
The overriding method cannot be less accessible than the method
it overrides.
4.
An overriding method cannot raise more exceptions that those
raised by the superclass.
SCHEME OF
EVALUATION
b.
1.
Inheritance reduces redundancy in code. Code redundancy means
writing the same code in different places, leading to unnecessary
replication of code. Inheritance helps you to reuse the code.
2.
Maintain code easily, as the code resides at one place. Any
changes made to the superclass automatically change the behavior of
the subclass.
3.
Extend the functionality of an existing class by adding more
methods to the subclass.
(10 marks)