Upload
pradip-kharbuja
View
657
Download
0
Embed Size (px)
DESCRIPTION
Softwarica Slides
Citation preview
Topic 02 : Genesis and Structure of JavaDDOOCP
Terminologies
› Interpreter
› Compiler
› Oak
› Bytecode
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
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 method.
› Class variable or class method in Java is declared using statickeyword.
› 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().
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
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.
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
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, inta)
› Color(float r, float g, float b)
› Color(float r, float g, float b, float a)
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. When a button is clicked, the background colour of the text field should change accordingly.
References
› http://docs.oracle.com/javase/7/docs/api/java/awt/Color.html