Given:
7. public interface Ndesit {
8. /* insert code here */ int score = 8;
9. }
Which 3 are valid on line 8? (Choose 3)
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
This is your world! It's not just Java
Monday, October 24, 2011
Quiz of the Day | OCPJP (35)
Posted by
Paiman
at
3:34 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Sunday, October 9, 2011
Quiz of the day | OCPJP (34)
Given:
3. class K {
4. String name = "kentang ";
5. String makeNoise() { return "ngentang"; }
6. }
7. class S extends K {
8. String name = "surikoyo ";
9. String makeNoise() { return "nyurikoyo"; }
10. }
11. public class ZK {
12. public static void main(String[] args) { new ZK().go(); }
13. void go() {
14. K k = new S();
15. System.out.println(k.name + k.makeNoise());
16. }
17. }
What is the result?
A. kentang nyurikoyo
B. surikoyo nyurikoyo
C. kentang ngentang
D. surikoyo ngentang
E. Compilation fails
F. An exception is thrown at runtime
3. class K {
4. String name = "kentang ";
5. String makeNoise() { return "ngentang"; }
6. }
7. class S extends K {
8. String name = "surikoyo ";
9. String makeNoise() { return "nyurikoyo"; }
10. }
11. public class ZK {
12. public static void main(String[] args) { new ZK().go(); }
13. void go() {
14. K k = new S();
15. System.out.println(k.name + k.makeNoise());
16. }
17. }
What is the result?
A. kentang nyurikoyo
B. surikoyo nyurikoyo
C. kentang ngentang
D. surikoyo ngentang
E. Compilation fails
F. An exception is thrown at runtime
Posted by
Paiman
at
4:27 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Saturday, October 8, 2011
Quiz of the day | OCPJP (33)
Given:
1. public class Tingting implements Ayu
{ public void doIt() { } }
2.
3. abstract class Phone1 extends Electronic { }
4.
5. abstract class Phone2 extends Electronic
{ public void doIt(int x) { } }
6.
7. class Phone3 extends Electronic implements Ayu
{ public void doStuff() { } }
8.
9. interface Device { public void doIt(); }
What is the result? (Choose all that apply.)
A. Compilation succeeds
B. Compilation fails with an error on line 1
C. Compilation fails with an error on line 3
D. Compilation fails with an error on line 5
E. Compilation fails with an error on line 7
F. Compilation fails with an error on line 9
DOWNLOAD the answer
1. public class Tingting implements Ayu
{ public void doIt() { } }
2.
3. abstract class Phone1 extends Electronic { }
4.
5. abstract class Phone2 extends Electronic
{ public void doIt(int x) { } }
6.
7. class Phone3 extends Electronic implements Ayu
{ public void doStuff() { } }
8.
9. interface Device { public void doIt(); }
What is the result? (Choose all that apply.)
A. Compilation succeeds
B. Compilation fails with an error on line 1
C. Compilation fails with an error on line 3
D. Compilation fails with an error on line 5
E. Compilation fails with an error on line 7
F. Compilation fails with an error on line 9
DOWNLOAD the answer
Posted by
Paiman
at
11:06 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Friday, October 7, 2011
Quiz of the day | OCPJP (32)
Given:
1. class Pocong {
2. public static void main(String[] args) {
3. doStuff(8);
4. doStuff(8,9);
5. }
6. // insert code here
7. }
Which, inserted independently at line 6, will compile? (Choose all that
apply.)
A. static void doStuff(int... doArgs) { }
B. static void doStuff(int[] doArgs) { }
C. static void doStuff(int doArgs...) { }
D. static void doStuff(int... doArgs, int y) { }
E. static void doStuff(int x, int... doArgs) { }
DOWNLOAD the answer
1. class Pocong {
2. public static void main(String[] args) {
3. doStuff(8);
4. doStuff(8,9);
5. }
6. // insert code here
7. }
Which, inserted independently at line 6, will compile? (Choose all that
apply.)
A. static void doStuff(int... doArgs) { }
B. static void doStuff(int[] doArgs) { }
C. static void doStuff(int doArgs...) { }
D. static void doStuff(int... doArgs, int y) { }
E. static void doStuff(int x, int... doArgs) { }
DOWNLOAD the answer
Posted by
Paiman
at
1:14 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Thursday, October 6, 2011
Quiz of the day | OCPJP (31)
Which method names follow the JavaBeans standard? (Choose all that apply.)
A. addBook
B. getProduct
C. deleteShirt
D. isThree
E. putBall
DOWNLOAD the answer
A. addBook
B. getProduct
C. deleteShirt
D. isThree
E. putBall
DOWNLOAD the answer
Posted by
Paiman
at
8:17 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Wednesday, October 5, 2011
Quiz of the day | OCPJP (30)
Given:
4. class WongJowo {
5. public static void main(String[] args) {
6. for(int __w = 0; __w < 5; __w++) ;
7. int #jw = 8;
8. long [] x [2];
9. Boolean []wj[];
10. enum Lanang { NGGANTENG, GAGAH, PINTER };
11. }
12. }
What is the result? (Choose all that apply.)
A. Compilation succeeds
B. Compilation fails with an error on line 6
C. Compilation fails with an error on line 7
D. Compilation fails with an error on line 8
E. Compilation fails with an error on line 9
F. Compilation fails with an error on line 10
DOWNLOAD the answer
4. class WongJowo {
5. public static void main(String[] args) {
6. for(int __w = 0; __w < 5; __w++) ;
7. int #jw = 8;
8. long [] x [2];
9. Boolean []wj[];
10. enum Lanang { NGGANTENG, GAGAH, PINTER };
11. }
12. }
What is the result? (Choose all that apply.)
A. Compilation succeeds
B. Compilation fails with an error on line 6
C. Compilation fails with an error on line 7
D. Compilation fails with an error on line 8
E. Compilation fails with an error on line 9
F. Compilation fails with an error on line 10
DOWNLOAD the answer
Posted by
Paiman
at
10:13 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Tuesday, October 4, 2011
Quiz of the day | OCPJP (29)
Given:
3. public class Bunga {
4. public enum Kembang { MAWAR, SETAMAN, DESA };
5. public static void main(String[] args) {
6. for(Kembang k : Kembang.values() )
7. ;
8. Kembang [] k2 = Kembang.values();
9. System.out.println(k2[2]);
10. }
11. }
What is the result? (Choose all that apply.)
A. SETAMAN
B. DESA
C. The output is unpredictable
D. Compilation fails due to an error on line 4
E. Compilation fails due to an error on line 6
F. Compilation fails due to an error on line 8
G. Compilation fails due to an error on line 9
DOWNLOAD the answer
3. public class Bunga {
4. public enum Kembang { MAWAR, SETAMAN, DESA };
5. public static void main(String[] args) {
6. for(Kembang k : Kembang.values() )
7. ;
8. Kembang [] k2 = Kembang.values();
9. System.out.println(k2[2]);
10. }
11. }
What is the result? (Choose all that apply.)
A. SETAMAN
B. DESA
C. The output is unpredictable
D. Compilation fails due to an error on line 4
E. Compilation fails due to an error on line 6
F. Compilation fails due to an error on line 8
G. Compilation fails due to an error on line 9
DOWNLOAD the answer
Posted by
Paiman
at
8:59 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Monday, October 3, 2011
Quiz of the day | OCPJP (28)
Given:
4. public class Kancil extends Kijang {
5. public static void main(String[] args) {
6. Short sikil = 4;
7. System.out.println(jumlah(sikil, 4));
8. }
9. }
10. class Kijang {http://www.blogger.com/img/blank.gif
11. int jumlah(int x, int y) { return x + y; }
12. }
What is the result?
A. 8
B. Compilation fails due to multiple errors
C. Compilation fails due to an error on line 6
D. Compilation fails due to an error on line 7
E. Compilation fails due to an error on line 11
4. public class Kancil extends Kijang {
5. public static void main(String[] args) {
6. Short sikil = 4;
7. System.out.println(jumlah(sikil, 4));
8. }
9. }
10. class Kijang {http://www.blogger.com/img/blank.gif
11. int jumlah(int x, int y) { return x + y; }
12. }
What is the result?
A. 8
B. Compilation fails due to multiple errors
C. Compilation fails due to an error on line 6
D. Compilation fails due to an error on line 7
E. Compilation fails due to an error on line 11
Posted by
Paiman
at
1:27 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Sunday, October 2, 2011
Quiz of the day | OCPJP (27)
Given two files:
1. package x;
2. public class J {
3. int a = 1;
4. protected int b = 2;
5. public int c = 3;
6. }
3. package y;
4. import x.*;
5. public class H {
6. public static void main(String[] args) {
7. J j = new J();
8. System.out.print(" " + j.a);
9. System.out.print(" " + j.b);
10. System.out.print(" " + j.c);
11. }
12. }
http://www.blogger.com/img/blank.gif
What is the result? (Choose all that apply.)
A. 1 2 3
B. 1 followed by an exception
C. Compilation fails with an error on line 7
D. Compilation fails with an error on line 8
E. Compilation fails with an error on line 9
F. Compilation fails with an error on line 10
DOWNLOAD the answer
1. package x;
2. public class J {
3. int a = 1;
4. protected int b = 2;
5. public int c = 3;
6. }
3. package y;
4. import x.*;
5. public class H {
6. public static void main(String[] args) {
7. J j = new J();
8. System.out.print(" " + j.a);
9. System.out.print(" " + j.b);
10. System.out.print(" " + j.c);
11. }
12. }
http://www.blogger.com/img/blank.gif
What is the result? (Choose all that apply.)
A. 1 2 3
B. 1 followed by an exception
C. Compilation fails with an error on line 7
D. Compilation fails with an error on line 8
E. Compilation fails with an error on line 9
F. Compilation fails with an error on line 10
DOWNLOAD the answer
Posted by
Paiman
at
10:02 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Saturday, October 1, 2011
Quiz of the day | OCPJP (26)
Given:
1. enum Kewan {
2. KIRIK("guk"), KUCING("meong"), WEDUS("mbek");
3. String suoro;
4. Kewan(String s) { suoro = s; }
5. }
6. class Enum {
7. static Kewan a;
8. public static void main(String [] args) {
9. System.out.println(a.KIRIK.suoro + " " + a.WEDUS.suoro);
10. }
11. }
What is the result?
A. guk mbek
B. Multiple compilation errors
C. Compilation fails due to an error on line 2
D. Compilation fails due to an error on line 3
E. Compilation fails due to an error on line 4
F. Compilation fails due to an error on line 9
DOWNLOAD the answer
1. enum Kewan {
2. KIRIK("guk"), KUCING("meong"), WEDUS("mbek");
3. String suoro;
4. Kewan(String s) { suoro = s; }
5. }
6. class Enum {
7. static Kewan a;
8. public static void main(String [] args) {
9. System.out.println(a.KIRIK.suoro + " " + a.WEDUS.suoro);
10. }
11. }
What is the result?
A. guk mbek
B. Multiple compilation errors
C. Compilation fails due to an error on line 2
D. Compilation fails due to an error on line 3
E. Compilation fails due to an error on line 4
F. Compilation fails due to an error on line 9
DOWNLOAD the answer
Posted by
Paiman
at
9:50 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Quiz of the day | OCPJP (22)
Posted by
Paiman
at
9:50 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Friday, September 30, 2011
Quiz of the day | OCPJP (25)
Which is true? (Choose all that apply.)
A. "C extends I" is correct if and only if C is a class and I is an interface
B. "C extends I" is correct if and only if C is an interface and I is a class
C. "C extends I" is correct if C and I are either both classes or both interfaces
D. "C extends I" is correct for all combinations of C and I being classes and/or interfaces
DOWNLOAD the answer
A. "C extends I" is correct if and only if C is a class and I is an interface
B. "C extends I" is correct if and only if C is an interface and I is a class
C. "C extends I" is correct if C and I are either both classes or both interfaces
D. "C extends I" is correct for all combinations of C and I being classes and/or interfaces
DOWNLOAD the answer
Posted by
Paiman
at
8:53 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Thursday, September 29, 2011
Quiz of the day | OCPJP (24)
3. public class J {
4. public static void main(String[] args) {
5. int j = 7;
6. assert(++j > 7);
7. assert(++j > 8): "Jakarta";
8. assert(j > 10): j=12;
9. assert(j==12): macet();
10. assert(j==12): new J();
11. }
12. static void macet() { }
13. }
Which are true? (Choose all that apply.)
A. Compilation succeeds
B. Compilation fails due to an error on line 6
C. Compilation fails due to an error on line 7
D. Compilation fails due to an error on line 8
E. Compilation fails due to an error on line 9
F. Compilation fails due to an error on line 10
DOWNLOAD the answer
4. public static void main(String[] args) {
5. int j = 7;
6. assert(++j > 7);
7. assert(++j > 8): "Jakarta";
8. assert(j > 10): j=12;
9. assert(j==12): macet();
10. assert(j==12): new J();
11. }
12. static void macet() { }
13. }
Which are true? (Choose all that apply.)
A. Compilation succeeds
B. Compilation fails due to an error on line 6
C. Compilation fails due to an error on line 7
D. Compilation fails due to an error on line 8
E. Compilation fails due to an error on line 9
F. Compilation fails due to an error on line 10
DOWNLOAD the answer
Posted by
Paiman
at
7:59 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Wednesday, September 28, 2011
Quiz of the day | OCPJP (23)
Given:
3. class A {
4. public void a() { System.out.print("A "); }
5. }
6. class B extends A {
7. public void b() { System.out.print("B "); }
8. public void a() { System.out.print("a "); }
9. }
10. public class C {
11. public static void main(String[] args) { new C().c(); }
12. void c() {
13. new B().a();
14. ((A) new B()).a();
15. ((A) new B()).b();
16. }
17. }
What is the result? (Choose all that apply.)
A. a a B
B. a A B
C. a a followed by an exception
D. a A followed by an exception
E. Compilation fails with an error at line 14
F. Compilation fails with an error at line 15
DOWNLOAD the answer
3. class A {
4. public void a() { System.out.print("A "); }
5. }
6. class B extends A {
7. public void b() { System.out.print("B "); }
8. public void a() { System.out.print("a "); }
9. }
10. public class C {
11. public static void main(String[] args) { new C().c(); }
12. void c() {
13. new B().a();
14. ((A) new B()).a();
15. ((A) new B()).b();
16. }
17. }
What is the result? (Choose all that apply.)
A. a a B
B. a A B
C. a a followed by an exception
D. a A followed by an exception
E. Compilation fails with an error at line 14
F. Compilation fails with an error at line 15
DOWNLOAD the answer
Posted by
Paiman
at
9:43 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Tuesday, September 27, 2011
Quiz of the day | OCPJP (22)
Given:
1. enum Menu {HOME, ABOUT, CONTACT};
2. public class Main {
3. public static void main(String[] args) {
4. Main m = new Main();
5. Menu[] v = Menu.values();
6. v = Menu.getValues();
7. for(Menu me: Menu.values()) m.getEnum(me);
8. for(int x = 0; x < Menu.values().length; x++) m.getEnum(v[x]);
9. for(int x = 0; x < Menu.length; x++) m.getEnum(v[x]);
10. for(Menu me: v) m.getEnum(me);
11. }
12. public void getEnum(Menu e) {
13. System.out.print(e + " ");
14. } }
Which line(s) of code will cause a compiler error? (Choose all that apply.)
A. line 1
B. line 5
C. line 6
D. line 7
E. line 8
F. line 9
G. line 10
H. line 12
DOWNLOAD the answer
1. enum Menu {HOME, ABOUT, CONTACT};
2. public class Main {
3. public static void main(String[] args) {
4. Main m = new Main();
5. Menu[] v = Menu.values();
6. v = Menu.getValues();
7. for(Menu me: Menu.values()) m.getEnum(me);
8. for(int x = 0; x < Menu.values().length; x++) m.getEnum(v[x]);
9. for(int x = 0; x < Menu.length; x++) m.getEnum(v[x]);
10. for(Menu me: v) m.getEnum(me);
11. }
12. public void getEnum(Menu e) {
13. System.out.print(e + " ");
14. } }
Which line(s) of code will cause a compiler error? (Choose all that apply.)
A. line 1
B. line 5
C. line 6
D. line 7
E. line 8
F. line 9
G. line 10
H. line 12
DOWNLOAD the answer
Posted by
Paiman
at
10:29 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Monday, September 26, 2011
Quiz of the day | OCPJP (21)
Given:
3. public class Sep26 {
4. public static void main(String[] args) {
5. short f4 = 4;
6. new Sep26().go(f4);
7. new Sep26().go(new Integer(8));
8. }
9. void go(Short s) { System.out.print("S "); }
10. void go(Long l) { System.out.print("L "); }
11. void go(int i) { System.out.print("i "); }
12. void go(Number n) { System.out.print("N "); }
13. }
What is the result?
A. i L
B. i N
C. S L
D. S N
E. Compilation fails.
F. An exception is thrown at runtime.
DOWNLOAD the answer
3. public class Sep26 {
4. public static void main(String[] args) {
5. short f4 = 4;
6. new Sep26().go(f4);
7. new Sep26().go(new Integer(8));
8. }
9. void go(Short s) { System.out.print("S "); }
10. void go(Long l) { System.out.print("L "); }
11. void go(int i) { System.out.print("i "); }
12. void go(Number n) { System.out.print("N "); }
13. }
What is the result?
A. i L
B. i N
C. S L
D. S N
E. Compilation fails.
F. An exception is thrown at runtime.
DOWNLOAD the answer
Posted by
Paiman
at
8:12 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Sunday, September 25, 2011
Quiz of the day | OCPJP (20)
Given:
2. public class X {
3. private int g = 3;
4. public static void main(String[] args) {
5. new X().xii();
6. }
7. void xii() {
8. int x = 6;
9. Y y = new Y();
10. class Y {
11. void yii() { System.out.println(g + x); }
12. }
13. y.yii();
14. }
15. }
What is the result? (Choose all that apply.)
A. Compilation succeeds.
B. Compilation fails due to an error on line 3.
C. Compilation fails due to an error on line 8.
D. Compilation fails due to an error on line 9.
E. Compilation fails due to an error on line 10.
F. Compilation fails due to accessing x on line 11.
G. Compilation fails due to accessing y on line 11.
DOWNLOAD the answer
2. public class X {
3. private int g = 3;
4. public static void main(String[] args) {
5. new X().xii();
6. }
7. void xii() {
8. int x = 6;
9. Y y = new Y();
10. class Y {
11. void yii() { System.out.println(g + x); }
12. }
13. y.yii();
14. }
15. }
What is the result? (Choose all that apply.)
A. Compilation succeeds.
B. Compilation fails due to an error on line 3.
C. Compilation fails due to an error on line 8.
D. Compilation fails due to an error on line 9.
E. Compilation fails due to an error on line 10.
F. Compilation fails due to accessing x on line 11.
G. Compilation fails due to accessing y on line 11.
DOWNLOAD the answer
Posted by
Paiman
at
9:56 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Saturday, September 24, 2011
Quiz of the day | OCPJP (19)
Given:
3. public class O {
4. private int a = 2;
5. protected int s = 3;
6. private static int d = 4;
7. protected static int f = 5;
8. public static void main(String[] args) {
9. int a = 6; int s = 7;
10. int d = 8; int f = 9;
11. new O().new P().p();
12. }
13. class P {
14. void p() { System.out.println(a + " " + s + " " + d + " " + f); }
15. } }
What is the result?
A. 2 3 4 5
B. 2 7 4 9
C. 6 3 8 4
D. 6 7 8 9
E. Compilation fails due to multiple errors.
F. Compilation fails due only to an error on line 11.
G. Compilation fails due only to an error on line 14.
DOWNLOAD the answer
3. public class O {
4. private int a = 2;
5. protected int s = 3;
6. private static int d = 4;
7. protected static int f = 5;
8. public static void main(String[] args) {
9. int a = 6; int s = 7;
10. int d = 8; int f = 9;
11. new O().new P().p();
12. }
13. class P {
14. void p() { System.out.println(a + " " + s + " " + d + " " + f); }
15. } }
What is the result?
A. 2 3 4 5
B. 2 7 4 9
C. 6 3 8 4
D. 6 7 8 9
E. Compilation fails due to multiple errors.
F. Compilation fails due only to an error on line 11.
G. Compilation fails due only to an error on line 14.
DOWNLOAD the answer
Posted by
Paiman
at
8:41 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Friday, September 23, 2011
Quiz of the day | OCPJP (18)
Given:
2. interface A { void a(); }
3. // insert code here
Which code, inserted independently at line 3, will compile? (Choose
all that apply.)
A. interface B extends A { }
B. interface B extends A { void a(); }
C. interface B extends A { void doA(); }
D. interface B extends A { void a() { ; } }
E. interface B extends A { protected void a(); }
F. interface B extends A { void a(); void doA(); }
DOWNLOAD the answer
2. interface A { void a(); }
3. // insert code here
Which code, inserted independently at line 3, will compile? (Choose
all that apply.)
A. interface B extends A { }
B. interface B extends A { void a(); }
C. interface B extends A { void doA(); }
D. interface B extends A { void a() { ; } }
E. interface B extends A { protected void a(); }
F. interface B extends A { void a(); void doA(); }
DOWNLOAD the answer
Posted by
Paiman
at
8:21 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Thursday, September 22, 2011
Quiz of the day | OCPJP (17)
Which are valid command-line switches when working with assertions? (Choose all that apply.)
A. -ea
B. -da
C. -dsa
D. -eva
E. -enableassertions
DOWNLOAD the answer
A. -ea
B. -da
C. -dsa
D. -eva
E. -enableassertions
DOWNLOAD the answer
Posted by
Paiman
at
8:53 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Wednesday, September 21, 2011
Quiz of the day | OCPJP (16)
Given:
2. import java.text.*;
3. import java.util.*;
4. public class DF {
5. public static void main(String[] args) {
6. DateFormat df1 = DateFormat.getInstance();
7. DateFormat df2 = DateFormat.getInstance(DateFormat.SHORT);
8. DateFormat df3 = DateFormat.getDateInstance(DateFormat.FULL);
9. DateFormat df4 = DateFormat.getDateInstance(DateFormat.EXTENDED);
10. } }
Which are true? (Choose all that apply.)
A. Line 2 is not necessary.
B. Line 3 is not necessary.
C. Compilation fails due to an error on line 6.
D. Compilation fails due to an error on line 7.
E. Compilation fails due to an error on line 8.
F. Compilation fails due to an error on line 9.
DOWNLOAD the answer
2. import java.text.*;
3. import java.util.*;
4. public class DF {
5. public static void main(String[] args) {
6. DateFormat df1 = DateFormat.getInstance();
7. DateFormat df2 = DateFormat.getInstance(DateFormat.SHORT);
8. DateFormat df3 = DateFormat.getDateInstance(DateFormat.FULL);
9. DateFormat df4 = DateFormat.getDateInstance(DateFormat.EXTENDED);
10. } }
Which are true? (Choose all that apply.)
A. Line 2 is not necessary.
B. Line 3 is not necessary.
C. Compilation fails due to an error on line 6.
D. Compilation fails due to an error on line 7.
E. Compilation fails due to an error on line 8.
F. Compilation fails due to an error on line 9.
DOWNLOAD the answer
Posted by
Paiman
at
8:24 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Tuesday, September 20, 2011
Quiz of the day | OCPJP (15)
Given:
2. public class X {
3. static int x = 1;
4. public static void main(String[] args) {
5. int x = 2;
6. for(int i=0; i< 3; i++) {
7. if(i==1) System.out.print(x + " ");
8. }
9. go();
10. System.out.print(x + " " + i);
11. }
12. static void go() { int x = 3; }
13. }
What is the result?
A. 1 2 2
B. 2 2 2
C. 2 2 3
D. 2 3 2
E. Compilation fails.
F. An exception is thrown at runtime.
DOWNLOAD the answer
2. public class X {
3. static int x = 1;
4. public static void main(String[] args) {
5. int x = 2;
6. for(int i=0; i< 3; i++) {
7. if(i==1) System.out.print(x + " ");
8. }
9. go();
10. System.out.print(x + " " + i);
11. }
12. static void go() { int x = 3; }
13. }
What is the result?
A. 1 2 2
B. 2 2 2
C. 2 2 3
D. 2 3 2
E. Compilation fails.
F. An exception is thrown at runtime.
DOWNLOAD the answer
Posted by
Paiman
at
11:33 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Monday, September 19, 2011
Quiz of the day | OCPJP (14)
1. import java.util.*;
2. public class BCA {
3. public static void main(String[] args) {
4. List desk = new ArrayList();
5. desk.add("b"); desk.add("c"); desk.add("a");
6. Collection.sort(desk);
7. System.out.print(desk.indexOf("b"));
8. Collection.reverse(desk);
9. System.out.print(" " + desk.indexOf("c"));
10. System.out.println(" " + desk.indexOf("a"));
11. } }
What is the result?
A. 1 2 0
B. 2 2 1
C. 2 0 2
D. 1 0 2
E. Compilation fails.
F. An exception is thrown at runtime.
DOWNLOAD the answer
2. public class BCA {
3. public static void main(String[] args) {
4. List
5. desk.add("b"); desk.add("c"); desk.add("a");
6. Collection.sort(desk);
7. System.out.print(desk.indexOf("b"));
8. Collection.reverse(desk);
9. System.out.print(" " + desk.indexOf("c"));
10. System.out.println(" " + desk.indexOf("a"));
11. } }
What is the result?
A. 1 2 0
B. 2 2 1
C. 2 0 2
D. 1 0 2
E. Compilation fails.
F. An exception is thrown at runtime.
DOWNLOAD the answer
Posted by
Paiman
at
8:08 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Sunday, September 18, 2011
Quiz of the day | OCPJP (13)
2. class Parent {
3. static String parent = "";
4. void doStuff() { parent += "parent "; }
5. }
6. public class Child extends Parent {
7. public static void main(String[] args) {
8. new Child().go();
9. }
10. void go() {
11. Parent p = new Child();
12. Child c = (Child)p;
13. // insert code here
14. }
15. void doStuff() { parent += "child "; }
16. }
If the rest of the code compiles, which line(s) of code, inserted independently at line 13, compile? (Choose all that apply.)
A. c.doStuff();
B. p.doStuff();
C. this.doStuff();
D. super.doStuff();
E. c.super.doStuff();
F. p.super.doStuff();
G. this.super.doStuff();
H. There are other errors in the code.
DOWNLOAD the answer
3. static String parent = "";
4. void doStuff() { parent += "parent "; }
5. }
6. public class Child extends Parent {
7. public static void main(String[] args) {
8. new Child().go();
9. }
10. void go() {
11. Parent p = new Child();
12. Child c = (Child)p;
13. // insert code here
14. }
15. void doStuff() { parent += "child "; }
16. }
If the rest of the code compiles, which line(s) of code, inserted independently at line 13, compile? (Choose all that apply.)
A. c.doStuff();
B. p.doStuff();
C. this.doStuff();
D. super.doStuff();
E. c.super.doStuff();
F. p.super.doStuff();
G. this.super.doStuff();
H. There are other errors in the code.
DOWNLOAD the answer
Posted by
Paiman
at
12:15 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Saturday, September 17, 2011
Quiz of the day | OCPJP (12)
3. public class C {
4. public static void main(String[] c) {
5. int i = 23;
6. Integer i2;
7. Integer i3;
8. i2 = i.intValue();
9. i3 = i.valueOf(23);
10. System.out.println((i == i2) + " " + (i == i3));
11. } }
What is the result?
A. true true
B. true false
C. false true
D. false false
E. Compilation fails.
F. An exception is thrown at runtime.
DOWNLOAD the answer
4. public static void main(String[] c) {
5. int i = 23;
6. Integer i2;
7. Integer i3;
8. i2 = i.intValue();
9. i3 = i.valueOf(23);
10. System.out.println((i == i2) + " " + (i == i3));
11. } }
What is the result?
A. true true
B. true false
C. false true
D. false false
E. Compilation fails.
F. An exception is thrown at runtime.
DOWNLOAD the answer
Posted by
Paiman
at
8:52 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Friday, September 16, 2011
Quiz of the day | OCPJP (11)
3. class P {
4. P play() { System.out.print("p "); return new P(); }
5. P play(int x) { System.out.print("p x "); return new P(); }
6. }
7. class Q extends P {
8. Q play() { System.out.print("q "); return new Q(); }
9. P play(int x) { System.out.print("r "); return new P(); }
10.
11. public static void main(String[] args) {
12. new Q().play();
13. new Q().play(7);
14. super.play(7);
15. new P().play();
16. P s = new Q();
17. s.play();
18. } }
What is the result?
A. q r r p p
B. q r p x p r
C. q r p x p q
D. Compilation fails due to a single error.
E. Compilation fails due to errors on more than one line.
DOWNLOAD the answer
4. P play() { System.out.print("p "); return new P(); }
5. P play(int x) { System.out.print("p x "); return new P(); }
6. }
7. class Q extends P {
8. Q play() { System.out.print("q "); return new Q(); }
9. P play(int x) { System.out.print("r "); return new P(); }
10.
11. public static void main(String[] args) {
12. new Q().play();
13. new Q().play(7);
14. super.play(7);
15. new P().play();
16. P s = new Q();
17. s.play();
18. } }
What is the result?
A. q r r p p
B. q r p x p r
C. q r p x p q
D. Compilation fails due to a single error.
E. Compilation fails due to errors on more than one line.
DOWNLOAD the answer
Posted by
Paiman
at
9:46 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Thursday, September 15, 2011
Quiz of the day | OCPJP (10)
2. interface A { }
3. interface B { }
4. abstract interface C extends A, B {
5. void c();
6. }
7. class D implements C {
8. public void c() { System.out.print("c "); }
9. }
10. class E implements C extends D {
11. public void c() { System.out.print("c x "); }
12. }
13. public class F extends D implements C, B { }
What is the result? (Choose all that apply.)
A. Compilation succeeds.
B. Compilation fails because of error(s) in C.
C. Compilation fails because of error(s) in D.
D. Compilation fails because of error(s) in E.
E. Compilation fails because of error(s) in F.
DOWNLOAD the answer
3. interface B { }
4. abstract interface C extends A, B {
5. void c();
6. }
7. class D implements C {
8. public void c() { System.out.print("c "); }
9. }
10. class E implements C extends D {
11. public void c() { System.out.print("c x "); }
12. }
13. public class F extends D implements C, B { }
What is the result? (Choose all that apply.)
A. Compilation succeeds.
B. Compilation fails because of error(s) in C.
C. Compilation fails because of error(s) in D.
D. Compilation fails because of error(s) in E.
E. Compilation fails because of error(s) in F.
DOWNLOAD the answer
Posted by
Paiman
at
11:34 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Wednesday, September 14, 2011
Quiz of the day | OCPJP (9)
Which are true about a method-local inner class? (Choose all that apply.)
A. It must be marked final
B. It can be marked abstract
C. It can be marked public
D. It can be marked static
E. It can access private members of the enclosing class
DOWNLOAD the answer
A. It must be marked final
B. It can be marked abstract
C. It can be marked public
D. It can be marked static
E. It can access private members of the enclosing class
DOWNLOAD the answer
Posted by
Paiman
at
11:01 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Tuesday, September 13, 2011
Quiz of the day | OCPJP (8)
Given:
1. public class MyOffice {
2. public static void main(String[] args) {
3. String name = "PT";
4. name.concat("Time");
5. name = go(name);
6. System.out.println(name);
7. }
8. static String go(String name) {
9. name.concat("Excelindo");
10. return name;
11. } }
What is the result?
A. Time
B. PT
C. TimeExcelindo
D. PTTime
E. PTExcelindo
F. PTTimeExcelindo
G. Compilation fails.
DOWNLOAD the answer
1. public class MyOffice {
2. public static void main(String[] args) {
3. String name = "PT";
4. name.concat("Time");
5. name = go(name);
6. System.out.println(name);
7. }
8. static String go(String name) {
9. name.concat("Excelindo");
10. return name;
11. } }
What is the result?
A. Time
B. PT
C. TimeExcelindo
D. PTTime
E. PTExcelindo
F. PTTimeExcelindo
G. Compilation fails.
DOWNLOAD the answer
Posted by
Paiman
at
8:31 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Monday, September 12, 2011
Quiz of the day | OCPJP (7)
Given:
public class TimeExcelindo extends Thread {
public static void main(String[] args) {
Thread t = new Thread(new TimeExcelindo());
Thread t2 = new Thread(new TimeExcelindo());
t.start();
t2.start();
}
public static void run() {
for(int i = 0; i < 2; i++)
System.out.print(Thread.currentThread().getName() + " ");
}
}
Which are true? (Choose all that apply.)
A. Compilation fails.
B. No output is produced.
C. The output could be Thread-1 Thread-3 Thread-1 Thread-2
D. The output could be Thread-1 Thread-3 Thread-1 Thread-3
E. The output could be Thread-1 Thread-1 Thread-2 Thread-2
F. The output could be Thread-1 Thread-3 Thread-3 Thread-1
G. The output could be Thread-1 Thread-3 Thread-1 Thread-1
DOWNLOAD the answer
public class TimeExcelindo extends Thread {
public static void main(String[] args) {
Thread t = new Thread(new TimeExcelindo());
Thread t2 = new Thread(new TimeExcelindo());
t.start();
t2.start();
}
public static void run() {
for(int i = 0; i < 2; i++)
System.out.print(Thread.currentThread().getName() + " ");
}
}
Which are true? (Choose all that apply.)
A. Compilation fails.
B. No output is produced.
C. The output could be Thread-1 Thread-3 Thread-1 Thread-2
D. The output could be Thread-1 Thread-3 Thread-1 Thread-3
E. The output could be Thread-1 Thread-1 Thread-2 Thread-2
F. The output could be Thread-1 Thread-3 Thread-3 Thread-1
G. The output could be Thread-1 Thread-3 Thread-1 Thread-1
DOWNLOAD the answer
Posted by
Paiman
at
9:01 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Sunday, September 11, 2011
Quiz of the day | OCPJP (6)
Given:
interface Beautiful { public void makeUp(); }
Which will compile? (Choose all that apply.)
A. public class Girl implements Beautiful { public void makeUp() { } }
B. public class Girl implements Beautiful { public void makeUp(int x) { } }
C. public class Girl implements Beautiful {
public void makeUp() { System.out.println("The girl is beautiful..."); }
}
D. public abstract class Girl implements Beautiful {
public void makeUp(int x) { }
}
E. public abstract class Girl implements Beautiful {
public void makeUp(int x) ;
}
DOWNLOAD the answer
interface Beautiful { public void makeUp(); }
Which will compile? (Choose all that apply.)
A. public class Girl implements Beautiful { public void makeUp() { } }
B. public class Girl implements Beautiful { public void makeUp(int x) { } }
C. public class Girl implements Beautiful {
public void makeUp() { System.out.println("The girl is beautiful..."); }
}
D. public abstract class Girl implements Beautiful {
public void makeUp(int x) { }
}
E. public abstract class Girl implements Beautiful {
public void makeUp(int x) ;
}
DOWNLOAD the answer
Posted by
Paiman
at
7:12 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Saturday, September 10, 2011
Quiz of the day | OCPJP (5)
Given:
class Ca { }
class Cb { }
interface Ia { }
interface Ib { }
class Aa extends Cb implements Ia { }
class Ab implements Ia implements Ib { }
class Ba implements Ca { }
class Bb extends Ca, implements Ib { }
class Ca extends Ia, Ib { }
class Cb implements Ia, Ib { }
What is the result? (Choose all that apply.)
A. Class Aa does not compile.
B. Class Ab does not compile.
C. Class Ba does not compile.
D. Class Bb does not compile.
E. Class Ca does not compile.
F. Class Cb does not compile.
G. Compilation succeeds for all of the classes.
DOWNLOAD the answer
class Ca { }
class Cb { }
interface Ia { }
interface Ib { }
class Aa extends Cb implements Ia { }
class Ab implements Ia implements Ib { }
class Ba implements Ca { }
class Bb extends Ca, implements Ib { }
class Ca extends Ia, Ib { }
class Cb implements Ia, Ib { }
What is the result? (Choose all that apply.)
A. Class Aa does not compile.
B. Class Ab does not compile.
C. Class Ba does not compile.
D. Class Bb does not compile.
E. Class Ca does not compile.
F. Class Cb does not compile.
G. Compilation succeeds for all of the classes.
DOWNLOAD the answer
Posted by
Paiman
at
6:39 PM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Friday, September 9, 2011
Quiz of the day | OCPJP (4)
Given:
2. class A { }
3. public class B extends A {
4. public static void main(String[] args) {
5. A a = new A();
6. B b = new B();
7. // insert code here
8. }
9. }
Which, inserted independently at line 7, compile? (Choose all that apply.)
A. if(b instanceof a) System.out.print("a ");
B. if(b.instanceof(a)) System.out.print("b ");
C. if(b instanceof A) System.out.print("c ");
D. if(b instanceOf A) System.out.print("d ");
E. if(b.instanceof(A)) System.out.print("e ");
DOWNLOAD the answer
2. class A { }
3. public class B extends A {
4. public static void main(String[] args) {
5. A a = new A();
6. B b = new B();
7. // insert code here
8. }
9. }
Which, inserted independently at line 7, compile? (Choose all that apply.)
A. if(b instanceof a) System.out.print("a ");
B. if(b.instanceof(a)) System.out.print("b ");
C. if(b instanceof A) System.out.print("c ");
D. if(b instanceOf A) System.out.print("d ");
E. if(b.instanceof(A)) System.out.print("e ");
DOWNLOAD the answer
Posted by
Paiman
at
11:05 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Thursday, September 8, 2011
Quiz of the day | OCPJP (3)
2. public class P {
3. private int p = 1;
4. public static void main(String[] args) {
5. protected int p = 3;
6. new P().new Q().q();
7. }
8. class Q {
9. void q() { System.out.println("number " + p); }
10. }
11. }
Which are true? (Choose all that apply.)
A. Compilation succeeds.
B. The output is "number 1".
C. The output is "number 3".
D. Compilation fails due to an error on line 5.
E. Compilation fails due to an error on line 6.
F. Compilation fails due to an error on line 9.
DOWNLOAD the answer
3. private int p = 1;
4. public static void main(String[] args) {
5. protected int p = 3;
6. new P().new Q().q();
7. }
8. class Q {
9. void q() { System.out.println("number " + p); }
10. }
11. }
Which are true? (Choose all that apply.)
A. Compilation succeeds.
B. The output is "number 1".
C. The output is "number 3".
D. Compilation fails due to an error on line 5.
E. Compilation fails due to an error on line 6.
F. Compilation fails due to an error on line 9.
DOWNLOAD the answer
Posted by
Paiman
at
10:46 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Wednesday, September 7, 2011
Quiz of the day | OCPJP (2)
Given:
2. public class X {
3. public static void main(String[] args) {
4. String result = "";
5. int x = 4, y = 5;
6. if(x == 0) { result += "5"; }
7. else if (x > 6) { result += "6"; }
8. else if (y < 6) { result += "7"; }
9. else if (x == 4) { result += "8"; }
10. else { result += "9"; }
11. System.out.println(result);
12. }
13. }
What is the result? (Choose all that apply.)
A. 789
B. 7
C. 78
D. 79
E. Compilation fails due to an error on line 5.
F. Compilation fails due to errors on lines 8 and 9.
G. Compilation fails due to errors on lines 7, 8, and 9.
DOWNLOAD the answer
2. public class X {
3. public static void main(String[] args) {
4. String result = "";
5. int x = 4, y = 5;
6. if(x == 0) { result += "5"; }
7. else if (x > 6) { result += "6"; }
8. else if (y < 6) { result += "7"; }
9. else if (x == 4) { result += "8"; }
10. else { result += "9"; }
11. System.out.println(result);
12. }
13. }
What is the result? (Choose all that apply.)
A. 789
B. 7
C. 78
D. 79
E. Compilation fails due to an error on line 5.
F. Compilation fails due to errors on lines 8 and 9.
G. Compilation fails due to errors on lines 7, 8, and 9.
DOWNLOAD the answer
Posted by
Paiman
at
10:16 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Tuesday, September 6, 2011
Quiz of the day | OCPJP (1)
Given:
public class A extends B {
A() {
System.out.println("a ");
}
public static void main(String[] args) {
new A();
}
}
class B extends C {
B() {
System.out.print("b ");
}
private B(String b) {
}
}
abstract class C {
C() {
System.out.print("c ");
}
}
What is the result?
A. a
B. a b
C. b a
D. a b c
E. c b a
F. Compilation fails due to a single error in the code.
G. Compilation fails due to multiple errors in the code.
DOWNLOAD the answer
public class A extends B {
A() {
System.out.println("a ");
}
public static void main(String[] args) {
new A();
}
}
class B extends C {
B() {
System.out.print("b ");
}
private B(String b) {
}
}
abstract class C {
C() {
System.out.print("c ");
}
}
What is the result?
A. a
B. a b
C. b a
D. a b c
E. c b a
F. Compilation fails due to a single error in the code.
G. Compilation fails due to multiple errors in the code.
DOWNLOAD the answer
Posted by
Paiman
at
10:14 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
OCPJP
Saturday, February 5, 2011
Java Tutorial: BufferedReader Example
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author paiman
*/
public class HelloBufferedReader {
public static void main( String[] args ) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader( System.in) );
String name;
System.out.print("Please Enter Your Name: ");
name = br.readLine();
System.out.println("Hello, " + name +"! Thank you for visiting my blog :)");
}
}
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author paiman
*/
public class HelloBufferedReader {
public static void main( String[] args ) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader( System.in) );
String name;
System.out.print("Please Enter Your Name: ");
name = br.readLine();
System.out.println("Hello, " + name +"! Thank you for visiting my blog :)");
}
}
Posted by
Paiman
at
11:37 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
BufferedReader,
Input Data,
Java Basic,
Java Tutorial
Java Tutorial: Thread Example
Two ways of Creating Thread
1. Extending from Thread class
2. Implementing Runnable
- Extends a class from the Thread class
- Override the run( )
- Create an instance of the above class
- Start the Thread
/**
*
* @author paiman
*/
class DispThread extends Thread{
String msg;
public DispThread(String msg) {
this.msg = msg;
}
@Override
public void run(){
for(int i=0; i<5;i++){
System.out.println(msg);
}
}
}
/**
*
* @author paiman
*/
public class ThreadTest {
public static void main (String[]args){
DispThread dt1 = new DispThread("Thread");
DispThread dt2 = new DispThread("Example");
dt1.start();
dt2.start();
}
}
- Implement Runnable on a class
- Implement the run( ) of the Runnable interface
- Create an instance of the above class
- Create a Thread object by passing the Runnable object as parameter
- Start the Thread
/**
*
* @author paiman
*/
public class DispThread2 implements Runnable{
String msg;
public DispThread2(String msg) {
this.msg = msg;
}
@Override
public void run(){
for(int i=0; i<5;i++){
System.out.println(msg);
}
}
}
/**
*
* @author paiman
*/
public class ThreadTest2 {
public static void main (String[]args){
DispThread2 dt1 = new DispThread2("Thread");
DispThread2 dt2 = new DispThread2("Example");
Thread t1 = new Thread(dt1);
Thread t2 = new Thread(dt2);
t1.start();
t2.start();
}
}
Posted by
Paiman
at
2:36 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
Java Basic,
Java Thread,
Java Tutorial
Java Tutorial: Array Example
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
*
* @author paiman
*/
public class AverageValue {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
double[] nilai = new double[4];
System.out.print("Value A : ");
nilai[0] = Double.parseDouble(in.readLine());
System.out.print("Value B : ");
nilai[1] = Double.parseDouble(in.readLine());
System.out.print("Value C : ");
nilai[2] = Double.parseDouble(in.readLine());
nilai[3] = (nilai[0] + nilai[1] + nilai[2])/3;
System.out.println("\nAverage value = " + nilai[3]);
}
}
Posted by
Paiman
at
1:13 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
Array,
Java Basic,
Java Tutorial
Java Tutorial: Scanner Example
import java.util.Scanner;
/**
*
* @author paiman
*/
public class HelloScanner {
public static void main(String[] args) {
Scanner input = new Scanner( System.in );
System.out.print ("What is your name? ");
String name = input.nextLine();
System.out.println("Hello, "+name+"! Welcome to my blog :)");
}
}
import java.util.Scanner;
/**
*
* @author paiman
*/
public class RectangleWide {
public static void main(String[] args) {
Scanner input = new Scanner( System.in );
System.out.print ("Input long: ");
int l = input.nextInt();
System.out.print ("Input width: ");
int w = input.nextInt();
System.out.println("Rectangle wide: "+l*w);
}
}
import java.util.Scanner;
/**
*
* @author paiman
*/
public class CircumferenceOfACircle {
public static void main(String[] args) {
Scanner input = new Scanner( System.in );
System.out.print ("Input radius: ");
double r = input.nextDouble();
double pi = 3.142857143;
double circumference = 2*pi*r;
System.out.println("The circumference of a Circle with radius "+r+" is "+circumference);
}
}
Posted by
Paiman
at
12:16 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
Input Data,
Java Basic,
Java Tutorial,
Scanner
Leave a Message
Blog Archive
-
▼
2011
(40)
-
▼
October
(11)
- Quiz of the Day | OCPJP (35)
- Quiz of the day | OCPJP (34)
- Quiz of the day | OCPJP (33)
- Quiz of the day | OCPJP (32)
- Quiz of the day | OCPJP (31)
- Quiz of the day | OCPJP (30)
- Quiz of the day | OCPJP (29)
- Quiz of the day | OCPJP (28)
- Quiz of the day | OCPJP (27)
- Quiz of the day | OCPJP (26)
- Quiz of the day | OCPJP (22)
-
►
September
(25)
- Quiz of the day | OCPJP (25)
- Quiz of the day | OCPJP (24)
- Quiz of the day | OCPJP (23)
- Quiz of the day | OCPJP (22)
- Quiz of the day | OCPJP (21)
- Quiz of the day | OCPJP (20)
- Quiz of the day | OCPJP (19)
- Quiz of the day | OCPJP (18)
- Quiz of the day | OCPJP (17)
- Quiz of the day | OCPJP (16)
- Quiz of the day | OCPJP (15)
- Quiz of the day | OCPJP (14)
- Quiz of the day | OCPJP (13)
- Quiz of the day | OCPJP (12)
- Quiz of the day | OCPJP (11)
- Quiz of the day | OCPJP (10)
- Quiz of the day | OCPJP (9)
- Quiz of the day | OCPJP (8)
- Quiz of the day | OCPJP (7)
- Quiz of the day | OCPJP (6)
- Quiz of the day | OCPJP (5)
- Quiz of the day | OCPJP (4)
- Quiz of the day | OCPJP (3)
- Quiz of the day | OCPJP (2)
- Quiz of the day | OCPJP (1)
-
▼
October
(11)
Labels
- About Java (2)
- Ajax (1)
- Animation (1)
- Array (1)
- BufferedReader (1)
- C# (1)
- C++ (1)
- Certification (5)
- Cryptography (1)
- Download (37)
- Eclipse (1)
- EJB (2)
- Game (3)
- Hibernate (3)
- Input Data (2)
- J2ME (1)
- Java 2D (1)
- Java 3D (1)
- Java Advance (1)
- Java Basic (6)
- Java Networking (1)
- Java RMI (1)
- Java Secrets (1)
- Java Swing (3)
- Java Thread (2)
- Java Tutorial (4)
- JavaFX (3)
- JDBC (1)
- JMS (1)
- JSP (1)
- Linux (1)
- MySQL (1)
- OCPJP (34)
- Opinion (2)
- Oracle (1)
- PHP (1)
- Scanner (1)
- SCJP (1)
- SCWCD (1)
- Silverlight (1)
- Spring (1)
- Tutorial (2)
- Web Service (1)
- Wireless (1)
Powered by Blogger.