Paul's Programming Progress
I am new to programming. This blog is a place to keep track of notes and projects as I learn.
Search This Blog
Wednesday, January 18, 2012
Friday, January 13, 2012
Friday, September 9, 2011
Sunday, July 10, 2011
Number Systems NOTES
Appendix A - Number Systems
1. Some commonly used terms
A bit - All information inside a computer is represented using 0s and 1s. The two symbols 0 and 1 are called binary digits, bits for short.
A byte - A group of 8 bits is called a byte.
A kilobyte - A group of 1024 ( = 210) bytes is called a kilobyte (denoted K or KB).
A megabyte - A group 1,048,576 ( = 220) bytes is called a megabyte (denoted MB). Sometimes called a meg.
A gigabyte - A group of 1,073,741,824 ( = 230) is called a gigabyte (denoted G). Sometimes called a gig.
Microprocessor - A microprocessor is a chip that holds the electronic circuit that performs overall supervision of the operations of the computer. A microprocessor is the brain of the computer. A microprocessor will also contain a small number of areas to hold instructions and data. These holding areas are called registers. Intel and Motorola are two of the companies that manufacture microprocessors commonly used in PCs.
Memory - The area within a computer where information is stored as bits is called memory of the computer. Computer memory can be thought of as a large collection of post-office box like locations, with each location having a unique address. The address is just a number. The size of each box is one byte. A byte is the smallest addressable unit of memory. The electronic circuitry will enable the microprocessor to fetch data in memory locations using their addresses.
1. Some commonly used terms
A bit - All information inside a computer is represented using 0s and 1s. The two symbols 0 and 1 are called binary digits, bits for short.
A byte - A group of 8 bits is called a byte.
A kilobyte - A group of 1024 ( = 210) bytes is called a kilobyte (denoted K or KB).
A megabyte - A group 1,048,576 ( = 220) bytes is called a megabyte (denoted MB). Sometimes called a meg.
A gigabyte - A group of 1,073,741,824 ( = 230) is called a gigabyte (denoted G). Sometimes called a gig.
Microprocessor - A microprocessor is a chip that holds the electronic circuit that performs overall supervision of the operations of the computer. A microprocessor is the brain of the computer. A microprocessor will also contain a small number of areas to hold instructions and data. These holding areas are called registers. Intel and Motorola are two of the companies that manufacture microprocessors commonly used in PCs.
Memory - The area within a computer where information is stored as bits is called memory of the computer. Computer memory can be thought of as a large collection of post-office box like locations, with each location having a unique address. The address is just a number. The size of each box is one byte. A byte is the smallest addressable unit of memory. The electronic circuitry will enable the microprocessor to fetch data in memory locations using their addresses.
JAVA Basics NOTES to REMEMBER
What is Java?
Java is a new object oriented programming language, developed by James Gosling at Sun Microsystems.
Java is a general-purpose higher-level programming language.
Java development started in 1991.
Java constructs and language features are similar to those of C++.
Java is a simple language with powerful built-in tools.
Java and C++
Note: Unlike C++,
Java does not have user-manipulated pointers.
Java programs do not have global data; all variables must be part of a class.
Java programs do not have global functions; all functions must be part of a class.
Java does not support templates.
Java does not support operator overloading.
Java does automatic garbage collection.
In Java arrays are objects.
In Java strings are objects.
Java provides several built-in data structures: Vector, Stack, Hashtable.
In Java objects are reference variables.
Compilers and interpreters
A program consists of English-like words and phrases put together following the rules of a particular programming language. Such a program is called a source code. The source code consists of English-like words in order to make programmers understand the statements. The processor itself does not understand the source code.
Each processor understands only its native language called the machine language.
When the source code is submitted to the computer, a program called compiler translates the source program into a machine language program so that the processor can understand and execute the program. The translated code is called the object code.
In some situations, the source code is not translated into the machine language, instead a program, called an interpreter, directly executes the statements of the source program in a sequence, one after the other. In such cases, an object code may not be generated. Programming languages that support an interpreter are sometimes called scripting languages.
Generally, compiled programs run faster than interpreted programs.
Java bytecode and Java interpreter
A Java compiler does not translate a Java source code into the machine language. Instead, a Java compiler translates a Java source code into an intermediate code called Java bytecode.
This bytecode is independent of the machine. Once the bytecode is generated, you need an interpreter on your system to execute it.
Thus, a Java compiler translates a Java program into a platform independent bytecode, which can then be moved to any platform and executed using a platform dependent interpreter.
Web browsers such as Netscape (version 4.0 or more recent) and Internet Explorer (version 4.0 or more recent) are Java enabled, meaning that they interpret Java bytecode.
When you install Java package provided by Sun Microsystems, an interpreter will be available to you. The Java Virtual Machine (JVM) is an environment in which a Java bytecode can be executed.
Just-in-time (JIT) compiler
As discussed earlier, a Java compiler translates a Java source code into Java bytecode. A Java interpreter executes bytecode directly without converting the code into machine language. This process tends to be slow because the bytecode is interpreted and interpreted execution is always slow.
A JIT compiler is a program that translates the bytecode program into machine language on the fly. This process generally enables faster execution of the program.
For a technical discussion on JIT compilers see: http://www.answers.com/topic/just-in-time-compilation
Java Software Development Kit (JSDK)
A Java compiler and other related software is provided free by Sun Microsystems as a package called Java Software Development Kit. Formerly the package was called Java Development Kit (JDK). The current version of JSDK is Java 2 Platform Standard Edition Version 1.3 (J2SE1.3).
You can download the latest version from Sun's website: http://java.sun.com/j2se/1.5.0/download.jsp.
The kit includes, a Java compiler (javac), a Java interpreter (java), a program to view Java applets (appletviewer), and a debugger (jdb). The Windows version contains a Symantec Just-in-Time (JIT) compiler.
The kit does not include an editor. You can use any editor to create your Java source program.
Java development environment
There are many commercial packages that integrate editor, compiler and other utilities to make Java development convenient. Such packages are called Integrated Development Environment (IDE).
JDK, on the other hand, works in DOS environment. You can use JDK and DOS environment to compile and execute Java programs. Once you learn Java, it is easy to switch over to any integrated environment.
In this course we will not be using the DOS environment, instead use an IDE.
An appendix introduces a couple of IDEs. You can use any one of them. Read the appendix before you start writing Java programs.
The following is a list of some of the leading Java IDEs:
Product Name
Company
Forte for Java
Sun
Jbuilder
Borland
Visual Café
WebGain
Jdeveloper
Oracle
CodeWarrior
Metrowerks
Visual J++
Microsoft
1. True or False: Generally compiled programs run faster than interpreted programs
True
2. When you compile a Java program you get a file with ____
bytecode
3. Java programs must be saved with file extension ____
.java
4. When you compile sample.java you will get a file called ________
sample.class
5. True or False: Java is case sensitive
True
6. True or False: Java bytecode is platform dependent
False
7. Convert 1011001 to decimal
89
8. Convert decimal 93 to 8-bit binary
01011101
9. Convert hexadecimal 2F to 8-bit binary
00101111
10. Convert octal 136 to decimal
94
Java is a new object oriented programming language, developed by James Gosling at Sun Microsystems.
Java is a general-purpose higher-level programming language.
Java development started in 1991.
Java constructs and language features are similar to those of C++.
Java is a simple language with powerful built-in tools.
Java and C++
Note: Unlike C++,
Java does not have user-manipulated pointers.
Java programs do not have global data; all variables must be part of a class.
Java programs do not have global functions; all functions must be part of a class.
Java does not support templates.
Java does not support operator overloading.
Java does automatic garbage collection.
In Java arrays are objects.
In Java strings are objects.
Java provides several built-in data structures: Vector, Stack, Hashtable.
In Java objects are reference variables.
Compilers and interpreters
A program consists of English-like words and phrases put together following the rules of a particular programming language. Such a program is called a source code. The source code consists of English-like words in order to make programmers understand the statements. The processor itself does not understand the source code.
Each processor understands only its native language called the machine language.
When the source code is submitted to the computer, a program called compiler translates the source program into a machine language program so that the processor can understand and execute the program. The translated code is called the object code.
In some situations, the source code is not translated into the machine language, instead a program, called an interpreter, directly executes the statements of the source program in a sequence, one after the other. In such cases, an object code may not be generated. Programming languages that support an interpreter are sometimes called scripting languages.
Generally, compiled programs run faster than interpreted programs.
Java bytecode and Java interpreter
A Java compiler does not translate a Java source code into the machine language. Instead, a Java compiler translates a Java source code into an intermediate code called Java bytecode.
This bytecode is independent of the machine. Once the bytecode is generated, you need an interpreter on your system to execute it.
Thus, a Java compiler translates a Java program into a platform independent bytecode, which can then be moved to any platform and executed using a platform dependent interpreter.
Web browsers such as Netscape (version 4.0 or more recent) and Internet Explorer (version 4.0 or more recent) are Java enabled, meaning that they interpret Java bytecode.
When you install Java package provided by Sun Microsystems, an interpreter will be available to you. The Java Virtual Machine (JVM) is an environment in which a Java bytecode can be executed.
Just-in-time (JIT) compiler
As discussed earlier, a Java compiler translates a Java source code into Java bytecode. A Java interpreter executes bytecode directly without converting the code into machine language. This process tends to be slow because the bytecode is interpreted and interpreted execution is always slow.
A JIT compiler is a program that translates the bytecode program into machine language on the fly. This process generally enables faster execution of the program.
For a technical discussion on JIT compilers see: http://www.answers.com/topic/just-in-time-compilation
Java Software Development Kit (JSDK)
A Java compiler and other related software is provided free by Sun Microsystems as a package called Java Software Development Kit. Formerly the package was called Java Development Kit (JDK). The current version of JSDK is Java 2 Platform Standard Edition Version 1.3 (J2SE1.3).
You can download the latest version from Sun's website: http://java.sun.com/j2se/1.5.0/download.jsp.
The kit includes, a Java compiler (javac), a Java interpreter (java), a program to view Java applets (appletviewer), and a debugger (jdb). The Windows version contains a Symantec Just-in-Time (JIT) compiler.
The kit does not include an editor. You can use any editor to create your Java source program.
Java development environment
There are many commercial packages that integrate editor, compiler and other utilities to make Java development convenient. Such packages are called Integrated Development Environment (IDE).
JDK, on the other hand, works in DOS environment. You can use JDK and DOS environment to compile and execute Java programs. Once you learn Java, it is easy to switch over to any integrated environment.
In this course we will not be using the DOS environment, instead use an IDE.
An appendix introduces a couple of IDEs. You can use any one of them. Read the appendix before you start writing Java programs.
The following is a list of some of the leading Java IDEs:
Product Name
Company
Forte for Java
Sun
Jbuilder
Borland
Visual Café
WebGain
Jdeveloper
Oracle
CodeWarrior
Metrowerks
Visual J++
Microsoft
1. True or False: Generally compiled programs run faster than interpreted programs
True
2. When you compile a Java program you get a file with ____
bytecode
3. Java programs must be saved with file extension ____
.java
4. When you compile sample.java you will get a file called ________
sample.class
5. True or False: Java is case sensitive
True
6. True or False: Java bytecode is platform dependent
False
7. Convert 1011001 to decimal
89
8. Convert decimal 93 to 8-bit binary
01011101
9. Convert hexadecimal 2F to 8-bit binary
00101111
10. Convert octal 136 to decimal
94
Sunday, June 12, 2011
Multi-Class
So...the name program, I came up with while I was playing around was actually on a tutorial: http://www.youtube.com/watch?v=7MBgaF8wXls&feature=channel_video_title
Except that this tutorial showed us how to use multiple classes to get the same results that the name program that I came up with produced. Which was cool because it outlined how to incorporate different classes....
Main Class
Other Class
Building off of that, here is the Cheeky Name Game:
Main Class
Other Class
Except that this tutorial showed us how to use multiple classes to get the same results that the name program that I came up with produced. Which was cool because it outlined how to incorporate different classes....
Main Class
import java.util.Scanner; public class projectx { public static void main(String args[]){ Scanner input = new Scanner (System.in); projecty projectyObject = new projecty(); System.out.println("Enter Your Name Here: "); String name = input.nextLine(); projectyObject.HereWeGo(name); } } |
Other Class
public class projecty { public void HereWeGo(String name){ System.out.println("Hello " + name); } } |
Building off of that, here is the Cheeky Name Game:
Main Class
import java.util.Scanner; public class projectx { public static void main(String args[]){ Scanner input = new Scanner (System.in); projecty projectyObject = new projecty(); System.out.println("Enter the name of your most recent EX Here: "); String cheeky = input.nextLine(); projectyObject.setName(cheeky); projectyObject.saying(); } } |
Other Class
public class projecty { private String theName; public void setName(String name){ theName=name; } public String getName(){ return theName; } public void saying(){ System.out.printf("%s will be your new step parent", getName()); } } |
Subscribe to:
Comments (Atom)