Topic 02 : Genesis and
Structure of Java
DDOOCP
Terminologies
› Interpreter
› Compiler
› Oak
› Bytecode
The Java Language
› Java has a block structure
› Java is strongly typed language.
› Java allows the programmer to create t...
Test Class
Test Class
static Modifiers
› A variable or method that is shared by all instances of a class is
called a class variable or class met...
static Modifier Example
Math class
1. PI
1. abs
2. acos
3. asin
4. atan
5. ceil
6. cos
7. exp
8. floor
9. max
10. min
11. pow
12. random
13. rint
...
String class
1. charAt
2. compareTo
3. compareToIgnoreCase
4. concat
5. endsWith
6. equals
7. equalsIgnoreCase
8. indexOf
...
Color Class
› java.awt.Color
› static members
1. BLACK / black
2. BLUE / blue
3. WHITE / white
4. GREEN / green
5. YELLOW ...
Questions
› Generate and display 20 random integers in the range 200 to 500.
› WAP to display following output.
Solution contd…
Questions
› Build a GUI to include three JButtons and a JTextField. Set their
titles to Red, Green and Blue respectively. ...
References
› http://docs.oracle.com/javase/7/docs/api/java/awt/Color.html
Upcoming SlideShare
Loading in …5
×

Topic 02: Genesis and Structure of Java

1,995 views

Published on

Softwarica Slides

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,995
On SlideShare
0
From Embeds
0
Number of Embeds
921
Actions
Shares
0
Downloads
82
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Topic 02: Genesis and Structure of Java

  1. 1. Topic 02 : Genesis and Structure of Java DDOOCP
  2. 2. Terminologies › Interpreter › Compiler › Oak › Bytecode
  3. 3. The Java Language › Java has a block structure › Java is strongly typed language. › Java allows the programmer to create their own data types. › Java is platform independent. › Instancing a class
  4. 4. Test Class
  5. 5. Test Class
  6. 6. static Modifiers › A variable or method that is shared by all instances of a class is called a class variable or class method. › Class variable or class method in Java is declared using static keyword. › A class variable/method can be referred either through an instance of the class (like a normal instance variable) or through the full class name e.g. classname.variable or classname.method().
  7. 7. static Modifier Example
  8. 8. Math class 1. PI 1. abs 2. acos 3. asin 4. atan 5. ceil 6. cos 7. exp 8. floor 9. max 10. min 11. pow 12. random 13. rint 14. round 15. sin 16. sqrt 17. tan 18. toDegrees 19. toRadians • java.lang.Math • All methods and properties in Math class are static. • Automatically imported.
  9. 9. String class 1. charAt 2. compareTo 3. compareToIgnoreCase 4. concat 5. endsWith 6. equals 7. equalsIgnoreCase 8. indexOf 9. lastIndexOf 10. length 11. matches 12. replace 13. replaceAll 14. replaceFirst 15. split 16. startsWith 17. substring 18. toCharArray 19. toLowerCase 20. toString 21. toUpperCase 22. trim 23. valueOf
  10. 10. Color Class › java.awt.Color › static members 1. BLACK / black 2. BLUE / blue 3. WHITE / white 4. GREEN / green 5. YELLOW / yellow 6. ORANGE / orange 7. RED / red 8. PINK / pink 9. GRAY / gray 10.LIGHT_GRAY › Constructor › Color(int r, int g, int b) › Color(int rgb) › Color(int r, int g, int b, int a) › Color(float r, float g, float b) › Color(float r, float g, float b, float a)
  11. 11. Questions › Generate and display 20 random integers in the range 200 to 500. › WAP to display following output.
  12. 12. Solution contd…
  13. 13. Questions › Build a GUI to include three JButtons and a JTextField. Set their titles to Red, Green and Blue respectively. When a button is clicked, the background colour of the text field should change accordingly.
  14. 14. References › http://docs.oracle.com/javase/7/docs/api/java/awt/Color.html

×