Announcements

Sample Midterm Questions

posted May 17, 2012, 5:30 PM by Sukhjit Singh


Inner classes examples discussed on March 7th 2012

posted Mar 7, 2012, 8:00 PM by Sukhjit Singh   [ updated Mar 7, 2012, 8:00 PM ]


Questions on Scope Management discussed in class.

posted Feb 8, 2012, 8:02 PM by Sukhjit Singh

Scope Experiments

package p1;
class c1 {
    private static int x;
    protected static void setx(int x)
    {
        c1.x = x;

    }
}

package p1;
class c2 {
    protected c2() {
       c1.setx(10);
    }
}

//Is it possible to create another protected or public method called setx in c1 or c2? overloading or overriding (requires c1 or c2 to be a child).
//why should constructors be declared public for classes in a package.


package p2;
import p1.*;

class c3 extends c2 {
    private c2 blah;
    c3()
    {
        blah = new c2();
    }
}









brief talk on cloud computing

posted Dec 6, 2011, 8:04 PM by Sukhjit Singh

Exception Handling

posted Nov 22, 2011, 7:42 PM by Sukhjit Singh

Example covered in class

class FileSizeEx extends Exception {
    FileSizeEx() { }
    //can add remedy methods here.
    //can add exception tracing methods ..written to a file/db.
    void fixtheproblem() {
        try {
            Test1.openfile("abc.txt");
        }
        catch(Exception e)
        {
            System.out.println("We have really gone too far.");
        }
    }
}


import corejava.*;
import java.io.*;

class Test1 {
    static void openfile(String a) throws FileNotFoundException, FileSizeEx
    {

        if (a.length() > 10)
            throw new FileSizeEx();
        try
        {
            FileReader f1 = new FileReader(a);
            System.out.println("Opened file");

        }
        catch(FileNotFoundException e1)
        {
            System.out.println("Wrong FileName");
            a = corejava.Console.readLine("
Enter file name");           
        }

    }

    public static void main(String [] args)
    {
        String a1 = new String(args[0]);
        try {
            openfile(a1);
        }
        catch (FileSizeEx e1)
        {
            System.out.println("Wrong file size");
            e1.fixtheproblem();
        }
        catch (FileNotFoundException e1)
        {
            System.out.println("Wrong file name");
        }
        System.out.println("Yeah!!");
       
       
    }
}

Coding standards for assignments

posted Oct 20, 2011, 7:30 PM by Sukhjit Singh   [ updated Oct 20, 2011, 7:57 PM ]

Coding standards
>>Indent your code.
>>ordering your code
    instance variables, static variables
    instance methods, static methods.
>>put a main in each class - test it.
>>put one class per file. (unless you are using inner classes.
>>make all variables private
>>write public getter/setters
>>use protected as needed per requirement.
>>Package your code.

Inheritane Demo

posted Oct 18, 2011, 7:31 PM by Sukhjit Singh


Battery and Clock objects

posted Oct 11, 2011, 8:35 PM by Sukhjit Singh


Programming Exercise - Guessing Game from class.

posted Oct 4, 2011, 8:16 PM by Sukhjit Singh

Please see attached. A small exercise on looping, decision making construction and writing functions.

1-10 of 17