Hamid

   
 
  CS-74
Course Code : CS-74
Course Title : Introduction to Internet Programming
Assignment Number : BCA(6)-74/Assignment/09
Maximum Number : 100 (weightage = 25)
Last Date of Submission : 30th April, 2009/30th October, 2009

This assignment is having six questions. Answer all the questions. 


Q. 1 Answer the following questions through examples:

(i) What are the benefits of inheritance in Java programming?    
      

Ans:-    One of the key benefits of inheritance is to minimise the amount of duplicate code in an application by sharing common code amongst several subclasses. Where equivalent code exists in two related classes, the hierarchy can usually be refactored to move the common code up to a mutual superclass. This also tends to result in a better organisation of code and smaller, simpler compilation units.

Inheritance can also make application code more flexible to change because classes that inherit from a common superclass can be used interchangeably. If the return type of a method is superclass Example, then the application can be adapted to return any class that is descended from Example.


(ii) What are the applications of super and this keyword?

Ans:-

This Keyword
     The this keyword followed by a dot is used to access members variables and methods of the current object.

Example:

 public SimpleTime(int hour, int minute, int second) {
    this.hour = hour;
    this.minute = minute;
    this.second = second;
 }


Super Keyword
       There are two uses of the super keyword.
i. It is used for calling the superclass constructor.
ii. It is used to access those members of superclass that are hidden by the member of subclass.

The super keyword followed by a dot is used to access the original version of the method from the subclass. The super keyword can be handy if you want to access the original method in the superclass that has not been overwritten in your subclass.

When a constructor is defined in any subclass, it needs to initialize its superclass variables. A subclass can call a constructor method defined by its superclass by use of following form of super (parameter_list). Parameters needed by the superclass constructor are passed in super (parameter_list). The super keyword helps in conflict resolution in subclasses in the situation of "when members name in superclass is the same as members name in a subclass, and the members of the superclass is to be called in subclass".
super.member; // The member may be either member function, or member data.

Example :

    public class Superclass {

        public void printMethod() {
            System.out.println("Printed in Superclass.");
        }
    }

// Here is a subclass, called Subclass, that overrides printMethod():

    public class Subclass extends Superclass {

      public void printMethod() { //overrides printMethod in Superclass
          super.printMethod();
          System.out.println("Printed in Subclass");
      }
      public static void main(String[] args) {
         
      Subclass s = new Subclass();
      s.printMethod();   
      }

    }

Compiling and executing Subclass prints the following:

    Printed in Superclass.
    Printed in Subclass



(iii) What is the use of the final modifier?

Ans:-
final Modifier
The final Modifier may be applied to a class, indicating the class may not be extended (subclassed).
The final Modifier may be applied to a method, indicating the method may not be overridden in any subclass.

Examples :
public final class MyFinalClass
{
}
public class MyClass
{
      public final String myFinalMethod()
            {
                  <statements>
            }
}

A class may never be both abstract and final. abstract means the class must be extended, while final
means it cannot be.
 
A method may never be both abstract and final. abstract means the method must be overridden, while
final means it cannot be.


Q. 2
(i) What is the input and output to a Java compiler?


Ans:-

refer




(ii) What is the relationship between java and HTML?

Ans:-
Java isn't a page description language like HTML. It's a programming language. Description languages specify content and placement; programming languages describe a process for generating a result. Where there is generally a direct mapping between an HTML description of a document and the result, the relationship between a Java program and its result is likely to be more complex. It's a little like the difference between a list of square roots of numbers from zero to 10 and a program to calculate the list.

This is the code that specifies the Java code to run:

<APPLET CODEBASE="java" CODE="SqrtList" WIDTH=160 HEIGHT=162>
  <EM>You need a Java-aware browser</EM>
</APPLET>

The <APPLET> tag specifies the class to load (the CODE= field), URL information (the CODEBASE= field) and the size of the region the applet will own. Notice that Java doesn't exactly integrate with the rest of the page. Within that region of the page Java is king: it decides background color and fonts and does all the mouse and keyboard handling.

Parameters to the applet are placed in <PARAM> tags between the <APPLET> and </APPLET> tags. Anything else between these tags is ignored.


(iii) What is the import statement for ?

Ans:-
Import Keyword
The import keyword makes one class or all classes in a package visible in the current Java source file.
Imported classes can be referened without the use of fully−qualified class names.

Examples
import java.io.File;
import java.net.*;

Many Java programmers use only specific import statements (no '*') to avoid ambiguity when
multiple packages contain classes of the same name.


(iv) what are the differences between application and applets? How do you run an application and an applet?

Ans:-
Applets :
1. applets can be embedded in HTML pages and downloaded over the internet, or Intranet.
2. Applets can only be executed inside a Java-compatible container, such as a modern Web Browser.
3. Applets execute under strict security limitations that disallow certain operations, such as accessing files or systems servies on the user's computer.
4. Applets are the programs written specially for distribution over a network. These programs contain information to be delivered to the world and involve user interaction, for example, order entry form, registration form mailing, etc.

Applications :
1. Applications have no special support in HTML for embedding or downloading.
2. Applications can be executed from the command line with a small booting utility such as javac.exe or java.exe.
3. Applications have no inherent security restrictions.
4. Applications are system level programs i.e., these programs run in the background and don't involve user interaction, for example, server administration, security manager, etc.


Q. 3
(i) Describe the JAVA throughable class hierarchy and types of exceptions. 

JAVA Throughable class hierarchy :


Types of Exceptions and their Descriptions. :-

NullPointerException :
Raised when a variable is used without initialization.

ArithmaticException :
Raised when a number is divided by zero.

ArrayIndexOutofBoundsException :
Raised when an array element which does not exist is accessed.

ClassNotFoundException :
Raised when a specified class file is not found.

StringIndexOutofBoundsException :
Raised when attemptiong to access a string element which does not exist is attempted to be accessed.

IOException :
Deals with file related errors.

Exceptions and Exception Types



(ii) What is the purpose of claiming exceptions?

The purpose of claiming exceptions is to tell the Java runtime system what can go wrong. You claim an exception using the throws keyword in the method declaration. You can claim multiple exceptions, separated by commas.

To claim an exception in a method, use the throws keyword.
modifiers MethodName(list of params) throws 
      Exception_1, Exception_2, ..., Exception_N

Example:
public void myMethod() throws IOException
{
  ...
}


(iii) What is the keyword throw and throws used for?
Ans.
      The keyword to claim an exception is throws and the keyword to throw is exception in throw.

Throw Java Keyword
The throw keyword is used to raise an exception.

Examples
import java.io.IOException;
public class MyClass
{
public method readFile(String filename) throws IOException
{
<statements>
if (error)
{
throw new IOException("error reading file");
}
}
}

The throw statement takes a java.lang.Throwable as an argument. The Throwable is propagated up the
call stack until it is caught by an appropriate catch block.
Any method that throws an exception that is not a RuntimeException must also declare the exceptions
it throws using a throws modifier on the method declaration.

Throws Java Keyword
The throws keyword may be applied to a method to indicate the method raises particular types of exceptions.

Examples
import java.io.IOException;
public class MyClass
{
public method readFile(String filename) throws IOException
{
<statements>
if (error)
{
throw new IOException("error reading file");
}
}
}

· The throws keyword takes a comma−separated list of java.lang.Throwables as an argument.
- Any method that throws an exception that is not a RuntimeException must also declare the exceptions
it throws using a throws modifier on the method declaration.
- The caller of a method with a throws clause is required to enclose the method call in a try−catch
block.


Q. 4
Design a menu-driven interactive programme to find out capital cities of all the states of India using switch statement.           

import java.io.*;
public class capital
{
  public static void main(String args[]) throws Exception
  {
    System.out.println("Enter 1 for Andra Pradesh");
    System.out.println("Enter 2 for Arunachal Pradesh.");
    System.out.println("Enter 3 for Assam.");
    System.out.println("Enter 4 for Bihar.");
    System.out.println("Enter 5 for Chhattisgarh.");
    System.out.println("Enter 6 for Goa.");
    System.out.println("Enter 7 for Karnataka.");
    System.out.println("Enter 8 for Gujrat.");
    System.out.println("Enter 9 for Haryana.");
    System.out.println("Enter 10 for Himachal Pradesh.");
    System.out.println("Enter 11 for Mizoram.");
    System.out.println("Enter 12 for Jammu & Kashmir.");
    System.out.println("Enter 13 for Jharkhand.");
    System.out.println("Enter 14 for Kerala.");
    System.out.println("Enter 15 for Madhya Pradesh.");
    System.out.println("Enter 16 for Maharashtra.");
    System.out.println("Enter 17 for Manipur.");
    System.out.println("Enter 18 for Meghalaya.");
    System.out.println("Enter 19 for Nagaland.");
    System.out.println("Enter 20 for Orissa.");
    System.out.println("Enter 21 for Punjab.");
    System.out.println("Enter 22 for Rajasthan.");
    System.out.println("Enter 23 for Sikkim.");
    System.out.println("Enter 24 for Tamil Nadu.");
    System.out.println("Enter 25 for Tripura.");
    System.out.println("Enter 26 for Uttar Pradesh.");
    System.out.println("Enter 27 for Uttaranchal.");

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String read = br.readLine();
    int ch = Integer.parseInt(read);

      switch(ch)
      {       
        case 1:  System.out.println("Hyderabad");
            break;
        case 2:  System.out.println("Itanager");
            break;
        case 3:  System.out.println("Dispur");
            break;
        case 4:  System.out.println("Patna");
            break;
        case 5:  System.out.println("Raipur");
            break;
        case 6:  System.out.println("Panaji");
            break;
        case 7:  System.out.println("Bangalore");
            break;
        case 8:  System.out.println("Gandhinagar");
            break;
        case 9:  System.out.println("Chandigarh");
            break;
        case 10:  System.out.println("Shimla");
            break;
        case 11:  System.out.println("Aizawl");
            break;
        case 12:  System.out.println("Srinagar(Summer) & Jammu(Winter)");
            break;
        case 13:  System.out.println("Ranchi");
            break;
        case 14:  System.out.println("Trivandrum");
            break;
        case 15:  System.out.println("Bhopal");
            break;
        case 16:  System.out.println("Bombay");
            break;
        case 17:  System.out.println("Imphal");
            break;
        case 18:  System.out.println("Shillong");
            break;
        case 19:  System.out.println("Kohima");
            break;
        case 20:  System.out.println("Bhubaneswar");
            break;
        case 21:  System.out.println("chandigarh");
            break;
        case 22:  System.out.println("Jaipur");
            break;
        case 23:  System.out.println("Gangtok");
            break;
        case 24:  System.out.println("Chennai");
            break;
        case 25:  System.out.println("Agartala");
            break;
        case 26:  System.out.println("Lucknow");
            break;
        case 27:  System.out.println("Dehra Dun");
            break;
        default: System.out.println("Invalid entry!");
             break;
      }
   }
}




Q. 5
Admission to a professional course is subject to the following condition:
a)    Marks in mathematics > = 60
b)    Marks in Physics > = 50
c)    Marks in Chemistry > = 40
d)    Total in all three subjects > = 200
Or
Total in mathematics and Physics > = 150

Given the marks in the three subjects, write a programme to process the applications to list the eligible candidate.

import java.io.*;
class stud1
{
 public static void main(String[] args) throws IOException
 {
  System.out.println("Press Controll +C to terminate");
  System.out.println("Enter Mark of Math : ");
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String read = br.readLine();
  int m = Integer.parseInt(read);

  System.out.println("Enter Mark of Physics : ");
  String readone = br.readLine();
  int p = Integer.parseInt(readone);

  System.out.println("Enter Mark of Chemistry : ");
  String readtwo = br.readLine();
  int c = Integer.parseInt(readtwo);

  int t=m+p+c;
  int mp=m+p;

    if(m>=60 && p>=50 && c==40 && t>=200)
    {
        System.out.print("Qualified.");
    }
    else if(mp>=150)
    {
        System.out.print("Qualified.");
    }
    else
    {
        System.out.print("DisQualified.");
    }

 }
}


Q. 6     Write a programme to perform binary operations on integer argument. The arguments and operators should be accepted using command line parameters.

Ans.
Download.
.
http://www.ziddu.com/download/4623744/CS-74_Q6.doc.html




Comments on this page:
Comment posted by WilbSwateRef( milotry-rx.com ), 06/15/2017 at 5:49pm (UTC):
Propecia Dopaje <a href=http://cheap-viagra-pill.canadianvia.com>Cheap Viagra Pill</a> Doryx By Money Order Safety Of Zithromax In Pregnancy <a href=http://levitra-online-cheap.buylevi.com>Levitra Online Cheap</a> Achat Cialis 20mg Original Canada Pharmacies Online Prescriptions <a href=http://cialcost.com/ordering-cialis-online.php>Ordering Cialis Online</a> Viagra Ibiza Picrolax <a href=http://buy-levitra-10mg.buylevi.com>Buy Levitra 10mg</a> Ed Medication Samples Leitra Luts <a href=http://viasamples.com/order-viagra-pills.php>Order Viagra Pills</a> Viagra Salud Mental Amoxicillin For Cats With No Prescription <a href=http://buy-cheap-kamagra-site.kamagorder.com>Buy Cheap Kamagra Site</a> How To Buy Cialis Zithromax Reviews <a href=http://levipill.com/levitra-brand-name.php>Levitra Brand Name</a> Viagra Giallo Adult Dosing Amoxicillin <a href=http://dprixe.com>cialis</a> Fabricacion De Kamagra Generic Propecia Overnight <a href=http://etrobax.com>cheap cialis</a> Generico Viagra Soft Buy Doxycycline Online <a href=http://viagra-discount.canadianvia.com>Viagra Discount</a> Lasix 100mg Prozac <a href=http://cheap-levitra-online.buylevi.com>Cheap Levitra Online</a> Buy Doxycycline V Precio De Levitra En Farmacias <a href=http://price-of-levitra.leviorder.com>Price Of Levitra</a> Comprar Clomiphene Levitra Laboratoire Bayer <a href=http://online-cialis.cial5mg.com>Online Cialis</a> Generic Viagra Online Paypal Mail Order Antibiotics <a href=http://costofvia.com/viagra-online-stores.php>Viagra Online Stores</a> Acheter Du Cialis Belgique

Comment posted by WilbSwateRef( milotry-rx.com ), 06/15/2017 at 10:41am (UTC):
Sure Romance <a href=http://kamagra-online-buy.kamagorder.com>Kamagra Online Buy</a> Precio Del Cialis En Espana Generic Cialis With Dapoxetine <a href=http://how-to-buy-cialis.tadalaf.com>How To Buy Cialis</a> Levitra Costo Farmacia Canadian Pharm Support Group <a href=http://cialis.ccrpdc.com/cialis-price.php>Cialis Price</a> Viagra Effetti Avversi Antabuse Over The Counter Generic <a href=http://genericvia.com/cheap-viagra-50mg.php>Cheap Viagra 50mg</a> Does Cephalexin Have Penicillan Buy Cheap Strattera Online <a href=http://purchase-generic-kamagra.kamagpills.com>Purchase Generic Kamagra</a> Durer Plus Longtemps Au Lit Ce Soir Comprar Cialis En Mallorca <a href=http://bestlevi.com/get-levitra.php>Get Levitra</a> Buy Viagra Online No Prescription Adefovir <a href=http://cialbuy.com>cialis</a> Zithromax Without A Prescription Discount Viagra 100mg <a href=http://tadalaf.com/map.php>Cialis Online Pharmacy</a> Levothyroxine Online Kaufen Cephalexin For Strep <a href=http://newisotretinoin.com>Buy Accutane</a> Herbal Viagra Kaufen Vademecum O Propecia <a href=http://buy-tadalafil.tadalaf.com>Buy Tadalafil</a> Viagra Very Fast Shipping Propecia For Hair Loss <a href=http://order-viagra-pills.viasample.com>Order Viagra Pills</a> Achat Viagra Pilules Tretinoin Cream 4 Tubes Pharmacy Price <a href=http://buy-dapoxetine-priligy-online.priliorder.com>Buy Dapoxetine Priligy Online</a> Effets Secondaires De Amoxil

Comment posted by WilbSwateRef( milotry-rx.com ), 06/15/2017 at 7:58am (UTC):
Buy Lasix 40 Mg <a href=http://cheapcial.com/cialis-20mg-price.php>Cialis 20mg Price</a> Zithromax Alcohol Cheep Levitra <a href=http://leviusa.com>buy levitra de como y celisborrar x</a> Buy Robaxin From India Generic Cheap Propecia Online <a href=http://newisotretinoin.com/accutane-prices.php>Accutane Prices</a> Keflex For Cellulitis In The Face Generic Viagra Canada Price <a href=http://buy-cialis-online-usa.tadalaf.com>Buy Cialis Online Usa</a> Priligy Wirkungszeit Generic Viagra Deals <a href=http://cialcheap.com/buy-cheap-generic-cialis.php>Buy Cheap Generic Cialis</a> Minox Propecia 1mg Amoxicillin For Dry Socket <a href=http://cialcheap.com/cialis-usa.php>Cialis Usa</a> Man Last Longer Tadalafil 40mg <a href=http://genericvia.com/viagra-alternative.php>Viagra Alternative</a> Cialis 20 Mg Packungsgro?En Kamagra Vente 100mg <a href=http://brandcial.com/cialis-order.php>Cialis Order</a> Dove Posso Comprare Cialis Nolvadex Medicaments Et Remedes <a href=http://cialusa.com>cheap cialis</a> Costo Levitra On Line Cialis Non Assuefazione <a href=http://genericvia.com/biuy-viagra-online.php>Biuy Viagra Online</a> Propecia Saw Palmetto Male Pattern

Comment posted by WilbSwateRef( milotry-rx.com ), 06/12/2017 at 9:23am (UTC):
Cialis Levitra En Ligne <a href=http://buylevitraeufast.com/buy-brand-levitra.php>Buy Brand Levitra</a> Propecia Patentablauf Cialis Meglio 10 O 20 Mg <a href=http://cheap-viagra-usa.via100mg.com>Cheap Viagra Usa</a> Buy Relafen Generic Online Medicamento Cialis Tadalafil <a href=http://viaprices.com>viagra</a> Levitra Ubers Internet Bentyl Store <a href=http://propecia-5mg.propecorder.com>Propecia 5mg</a> Cephalexin Used In Cats Cheap Retin A <a href=http://leviplus.com/levitra-pill.php>Levitra Pill</a> Buying Viagra On Line Viagra Versand Schweiz <a href=http://brandcial.com/generic-cialis-usa.php>Generic Cialis Usa</a> Compra Cialis Farmacia Cytotec Sterilet <a href=http://levicost.com>generic levitra soft tabs</a> Acheter Viagra Au Maroc How Last Longer <a href=http://generic-cialis-cheapest.BuyCial.com>Generic Cialis Cheapest</a> Difference Viagra Cialis Amoxicillin Treats Sinus Infection <a href=http://leviplus.com/levitra-no-rx.php>Levitra No Rx</a> Doryx Website Discount On Line Propecia E Viagra <a href=http://viagra-cialis.tadalaf.com>Viagra Cialis</a> Amlodipine Besylate

Comment posted by WilbSwateRef( milotry-rx.com ), 06/12/2017 at 1:13am (UTC):
Generique Cialis Forum <a href=http://genericvia.com/viagra-prices.php>Viagra Prices</a> Viagra From America Cialis Mail <a href=http://viacheap.com>viagra</a> Einnahme Levitra Zithromax Effectiveness Chlamydia <a href=http://levitra-tablet.buylevi.com>Levitra Tablet</a> Viagra Uk Retailers Online Coupon For Prevacid <a href=http://levicost.com>levitra canada free shipping</a> Viagra Rouge Lasix Water Pill Over The Counter <a href=http://brandcial.com/buy-cialis-online.php>Buy Cialis Online</a> Where To Buy Acticin Lipitor <a href=http://viagra-online.via100mg.com>Viagra Online</a> Isotretinoin sotret in germany over night Buy Synthroid 150 Mcg <a href=http://dprixe.com>is it safe to buy levitra on line</a> Cialis Viagra Dosage Can Amoxicillin Be Taken With Fluconazole <a href=http://levicost.com>levitra for sale</a> Cialis Generic Prices

Comment posted by Davpoicync( posmentry-rx.com ), 06/10/2017 at 8:00pm (UTC):
Propecia Steroids <a href=http://levicost.com>get online levitra prescription</a> Phneumonia Amoxicillin Cheapest 4 Quantity Of Viagra <a href=http://cost-of-cialis.tadalaf.com>Cost Of Cialis</a> Venta De Viagra Orlando Interaction Of Nyquil And Amoxicillin <a href=http://order-generic-cialis.cial5mg.com>Order Generic Cialis</a> Cephalexin Clindamycin Precio De Propecia En Andorra <a href=http://generic-propecia.propecorder.com>Generic Propecia</a> Kamagra Oral Jelly Kaufen Gunstig Priligy Mas Barato <a href=http://bpdrugs.com/map.php>Cialis 40mg</a> Avodart

Comment posted by WilbSwateRef( milotry-rx.com ), 06/08/2017 at 5:52pm (UTC):
Viagra 100 Mg 4 Comprimes <a href=http://cial40mg.com/cialis-order.php>Cialis Order</a> Priligy 60 Proscar Cabello Propecia <a href=http://cialcheap.com/order-cialis.php>Order Cialis</a> Nebenwirkungen Viagra Woman Pharmacy Prices For Viagra <a href=http://dprixe.com>why is levitra so expensive</a> Tomar Viagra Para Durar Mas Online Pharmacy Cialis Reviews <a href=http://buy-generic-kamagra-online.kamagorder.com>Buy Generic Kamagra Online</a> Levitra Ohne Rezept Online Kaufen Viagra Online Tesco <a href=http://buy-cialis-online.BuyCial.com>Buy Cialis Online</a> Cialis Eccipienti Acquistare Cialis Svizzera <a href=http://bestlevi.com/cheap-levitra.php>Cheap Levitra</a> Cialis Cheap From India Viagra Cialis Differenze <a href=http://buy-cheap-generic-cialis.cial5mg.com>Buy Cheap Generic Cialis</a> Sildenafil 25 Mg Online Bestellen

Comment posted by get backlinks( xeoxcvxgmail.com ), 03/23/2013 at 5:14am (UTC):
I convey get backlinks during the office all of the time. I really like get backlinks!.



Add comment to this page:
Your Name:
Your Email address:
Your website URL:
Your message:

Login
 
Username:
Password:
Advertisement
 
Donate
 
You can help this website
by donate or
you can click an
advertisement.

IGNOU Students
 
Sample Synopsis

Time Table BCA 2009
Projects (Vb n ASPnet) : Download
Synopsis Form

Training Letter

Guide Remuneration Form

Certificates of Originality

Java KeyWords - PDF

Java KeyWords - Wikipedia


Click Here / Click Here

Edit Plus (Use it as Java editor) Download

How to configure EditPlus to compile JAVA codes click here


Advertisement
 
PC Games (Full, Rip, Compressed)
 
 
© 2007 - 2009 HamidRaza - Today, there have been 8 visitors (46 hits) on this page!
=> Do you also want a homepage for free? Then click here! <=