In: Computer Science
AUse the following questions as guides to self-reflection during this week: Briefly describe what programming you did this week. Describe any problems you have had and how you solved your problems. Describe any feedback you received in class and discuss how it was or was not helpful. What skills and knowledge do you recognize that you are gaining, and how will these skills and knowledge be useful in school and as a professional after school?Learning Objectives for the Week: Apply sound program design techniques including flowcharting or pseudocode and naming conventions. Implement basic executable programs. Apply object-oriented design notions, classes, and methods in designing and implementing programs. Apply programming constructs including assignments, loops, and conditions. Write a complete structured program that includes methods.
In recent week I have done object oriented programming using Java language.Every time when I do programming,faced new challenges.I think it is a good practice to make the programming better.In recent week when I was performing Object class methods such as equals,tostring,hashcode etc. I had problem during implementation of them so I have searched for it over the internet and read book that is complete java reference,it helped me a lot.Programming is just about practicing,reading,surfing and experiments.This knowledge really helps me to easily study and understand other programming languages.This is because every programming language has same basic techniques,criteria and especially object oriented languages are so relatable with each other so learning one language really makes it easy to learn other ones.
Here following am sharing two java programs which covers different concepts such as class,object,methods,loops.
1) public class Demo
{
int id;
String name;
public void set(int id,String name)
{
this.id=id;
this.name=name;
}
int getid()
{
return id;
}
String getname()
{
return name;
}
public static void main(String[] args) {
Demo d=new Demo();
d.set(1, "abc");
System.out.println("Id="+d.getid());
System.out.println("name="+d.getname());
}
}
2) public class Exceptiondemp
{
int arr[]={2,5,7,8,9};
void show()
{
try
{
for (int i = 0; i <5 ;
i++)
{
System.out.println(arr[i]);
}
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("array size is greter or smaller");
}
}
public static void main(String[] args) {
Exceptiondemp e=new
Exceptiondemp();
e.show();
}
}