Wednesday, 16 August 2017

EXPT NO. 1



Echoing Command-Line Arguments
NON-NUMERIC
1.   class CommandLineExample{  
2.   public static void main(String args[]){  
3.   System.out.println("Your first argument is: "+args[0]);  
4.   }  
5.   }  

1.  compile by > javac CommandLineExample.java  
2.  run by > java CommandLineExample sonoo  

Output: Your first argument is: sonoo

1.  Public class A{  
2.  public static void main(String args[]){  
3.    
4.  for(int i=0;i<args.length;i++)  
5.  System.out.println(args[i]);  
6.    
7.  }  
8.  }  
compile by > javac A.java  
run by > java A bvcoe NM 1 3 abc  
 
Output: bvcoe
       NM
       1
       3
       abc

The Echo example displays each of its command-line arguments on a line by itself:

public class Echo {
    public static void main (String[] args) {
        for (String s: args) {
            System.out.println(s);
        }
    }
}

The following example shows how a user might run Echo. User input is in italics.
java Echo Drink Hot Java
Drink
Hot
Java
Note that the application displays each word — DrinkHot, and Java — on a line by itself. This is because the space character separates command-line arguments. To have DrinkHot, and Java interpreted as a single argument, the user would join them by enclosing them within quotation marks.
java Echo "Drink Hot Java"
Drink Hot Java


Parsing Numeric Command-Line Arguments
If an application needs to support a numeric command-line argument, it must convert a String argument that represents a number, such as "34", to a numeric value. Here is a code snippet that converts a command-line argument to an int:
int firstArg;
if (args.length > 0) {
    try {
        firstArg = Integer.parseInt(args[0]);
    } catch (NumberFormatException e) {
        System.err.println("Argument" + args[0] + " must be an integer.");
        System.exit(1);
    }
}
parseInt throws a NumberFormatException if the format of args[0] isn't valid. All of the Number classes — IntegerFloatDouble, and so on — have parseXXX methods that convert a String representing a number to an object of their type.

Downloading and Installing JDK Software

Check the following link for Lab session 1.



http://www.codejava.net/java-core/how-to-write-compile-and-run-a-hello-world-java-program-for-beginners

OOP WITH JAVA Laboratory S.E.(EXTC) CO-PO-PSO-MAPPING



Bharati Vidyapeeth College Of Engineering,Navi Mumbai

Electronics and Telecommunication Engineering Department

Course ECL308: OOP using JAVA laboratory S.E.(EXTC) DIV.( A & B) 
COURSE OBJECTIVES:

Sr. No.
Course Education Objectives (CEO)
1

To understand Object Oriented Programming and its principles.

2
To describe & explain keywords and Data types.
3
Able to implement Methods, Constructors, Arrays, Multithreading and Applet

4
To help students to understand how to use a programming language to resolve problems.


Course Outcomes:
At the end of the course student will be able to:
PO/ PSO
Bloom Level
ECL308.1
Students will be able to code a program using JAVA constructs.

PO1,  PO2, PO3, PO12,
PSO1,
L1-Remembering, L2-Understanding
ECL308.2
Students will be able to understand fundamental features of an object oriented language: object classes and interfaces, exceptions and libraries of object collections.

PO1,  PO2, PO3, PO12,
PSO1,
L1-Remembering, L2-Understanding,
L3-Applying
L4-Analyzing
ECL308.3
Students will be able to develop a program that efficiently implements the algorithm for given tasks.

PO1,  PO2, PO3, PO12,
PSO1,
L1-Remembering, L2-Understanding,
L3-Applying
L4-Analyzing

ECL308.4
Students will be able to utilize the knowledge acquired in this course to develop higher level algorithms.

PO1,  PO2, PO3, PO12,
PSO1,
L3-Applying



Mapping of CO with PO:
ECL308
PO1
PO2
PO3
PO4
PO5
PO6
PO7
PO8
PO9
PO10
PO11
PO12
PSO1
PSO2
PSO3
ECL308.1
3
3
3








2
3


ECL308.2
3
3
3








2
3


ECL308.3
3
3
3








2
3


ECL308.4


3





2


2
3


ECL308
3
3
3





2


2
3


ECL308 (SAR)
2.25
2.25
3





0.5


2
3


Correlation Levels:       1: Slightly             2: Moderately       3: Substantially