# 3415-Programming Language–III_VUsolutions.com by vufellows

VIEWS: 55 PAGES: 4

• pg 1
```									      ALLAMA IQBAL OPEN UNIVERSITY, ISLAMABAD
(Department of Computer Science)
Course: Programming Language–III (3415)                          Semester: Autumn, 2011
Level: BS (CS)                                                         Total Marks: 100
Pass Marks: 50
WARNING
1.   PLAGIARISM OR HIRING OF GHOST WRITER(S) FOR SOLVING
THE ASSIGNMENT(S) WILL DEBAR THE STUDENT FROM AWARD
OF DEGREE/CERTIFICATE, IF FOUND AT ANY STAGE.
2.   SUBMITTING ASSIGNMENTS BORROWED OR STOLEN FROM
OTHER(S) AS ONE’S OWN WILL BE PENALIZED AS DEFINED IN
“AIOU PLAGIARISM POLICY”.

ASSIGNMENT No. 1
(Units: 1–4)
Note: All questions are compulsory. Each question carries equal marks.
Q. 1 (a)     Write an application that reads five integers and determines and prints the
largest and smallest integers in the group.
(b)     Write an application that reads in two integers and determines and prints if
the first integer is a multiple of the second. (Hint: use the modulus operator).
Q. 2 Write an application that displays in the command window a box, an oval, an arrow
and a diamond using asterisks (*) as follows:

******                        ***                *                      *
*    *                  *           *           ***                 *       *
*    *                  *            *           *                 *         *
*    *                    *         *            *                  *       *
******                        ***                *                      *

Q. 3 (a)      Find the error in each of the following program statements and correct the
error.
a.     final int ARRAY_SIZE 5;
ARRAY_SIZE = 10;
b.     Assume int b[] = new int [10];
for ( int 1 = 0; I <= b. length; i++ )
a[1, 1] = 5;
(b)     Write java statements to accomplish each of the following:
a.     Display the value of the seventh element of character array f.
b.    Initialize each of the five elements of single-subscripted integer array g
to 8.
c.    Total the elements of floating-point array c of 100 elements.
d.    Copy 11-element array a into the first portion of array b, containing 34
elements.
Q. 4 (a)   Write a java application that utilizes looping to print the following table of
values:

N           10*N          100*N          1000*N
1           10            100            1000
2           20            200            2000
3           30            300            3000
4           40            400            4000
5           50            500            5000

(b)   How many control structures are used in java? What are the main differences
between them?
Q. 5 (a)   What happens to the flow of control when break and continue statements are
used? Explain with the help of example.
(b)   What is meant by multiple-selection? Is it possible to make multiple
selections without using switch statement? Give example to justify your

ASSIGNMENT No. 2
(Units: 5–8)
Total Marks: 100                                                          Pass Marks: 50

Note: All questions are compulsory. Each question carries equal marks.
Q. 1 (a)   Compare the access specifiers that are used in Java. What are the major
(b)   For what purpose Set and Get methods are used?
(c)   What is meant by final instance variable? Explain with the help of an
example.

Q. 2 (a)   What is data abstraction and information hiding? How it is implemented in
object oriented programming? Explain with the help of an example.
(b)   Demonstrate implicit and explicit use of this reference.

Q. 3 (a)   What is polymorphism? How it is implemented in java? Give one suitable
example.

2
(b)   What is the relationship between superclass objects and subclass objects?
How constructors and finalizers in subclasses call superclass suconstructors
or methods?

Q. 4 (a)    When exception handling should be used?
(b)    What is meant by catching and throwing an exception? Give an example to
show the sequence of events when an exception occurs?

(c)   For what purpose finally block is used?

Q. 5 (a)    Write an application that uses String method compareTo to compare two
strings input by the user. Output whether the first string is less than, equal to
or greater than the second.
(b)   Write an application that inputs a line of text, tokenizes the line with an
object of class String Tokenizer and outputs the tokens in reverse order.

Programming Language–III (3415)                                Credit Hours: 4(3+1)
Recommended Book:
JAVA, How to Program, By Deital & Deital 3rd Edition

Course Outlines:
Unit No. 1 Introduction to Java Applications
Introduction, Using Comments, Block of Codes, a Simple Java Program

Unit No. 2 Data Types & Arrays
Data Types, Declaring & Allocating Arrays,           References and Reference
Parameters, Searching Arrays, Multiple Subscripted Arrays

Unit No. 3 Control Structures-I
Selection Structure, while Repetition Structure

Unit No. 4 Control Structures-II
For Repetition Structure, Do/While Repetition Structure, Break and Continue,
Multiple Selection Structure

Unit No. 5 Object Oriented Programming-I
Introduction to Class, Class Scopes, Creating Packages, Constructors, Set & Get
Method, This Reference, Finalizer, Static Class Member

3
Unit No. 6 Object Oriented Programming-II
Super Class, Sub Classes, Protected Members, Inheritance, Polymorphism,
Dynamic Method Binding, Inner Class Definitions

Unit No. 7 Packages, Interfaces, and Exception Handling
Defining a package, Access Protection, Importing Packages, Interfaces, Exception-
Handling Fundamentals, Exception Types, Using Try & Catch, Java Built-In-
Exceptions

Unit No. 8 Strings & Characters
String Constructors, String comparing, String Methods, String Concatenating,
String Classes, String Methods

Unit No. 9 GUI
Graphics Context, Graphic Methods, Color and Font Control, Drawing Shapes,
Java 2d API, Java 2d Shapes, Swing Overview, Jlable, Event Handling Model,
Jbutton, Jtextfield, Jradiobutton, Jcheckbox, Jlist, Multiple Selection List, Mouse
Event Handling, Keyboard Event Handling, Layout Managers.

=========

4

```
To top