Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Java Basic Programming Question

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

LARA TECHNOLOGIES NEW BATCH 7-9AM

1. Program class Hello { public static void main(String args[]) { System.out.println("Hello World!"); } } 2. Program class HelloAgainAndAgain { public static void main(String[] args) { System.out.println("Hello World!"); System.out.println("Hello World!"); System.out.println("Hello World!"); System.out.println("Hello World!"); } } 3. Program class A { public static void main(String[] args) { System.out.println("Hello World!"); System.out.println(100); System.out.println(20.909); System.out.println(true); System.out.println(30 + 20); System.out.println(30 == 30); } } 4. Program class B { public static void main(String[] args) { inti = 10; System.out.println(i); } } 5. Program class B { public static void main(String[] args){ int j; System.out.println(j); } } 6. Program class C { public static void main(String[] args) { inti = 10; System.out.println(i); i = 20; System.out.println(i); i = 30; System.out.println(i); } }

201 2

7. Program class D { public static void main(String[] args) { inti; i = 10; System.out.println(i); } } 8. Program class E { public static void main(String[] args) { inti; System.out.println(i = 10); System.out.println(i); } } 9. Program class G { public static void main(String[] args) { inti, j; i = 0; j = 20; System.out.println(i + j); } } 10. Program class I { public static void main(String[] args) { int k = 1; System.out.println(k++); System.out.println(k); } } 11. Program class J { public static void main(String[] args){ inti = 1; System.out.println(++ i); System.out.println(i); } } 12. Program class K { public static void main(String[] args) { inti = 1; System.out.println(i ++); System.out.println(i); i = 2; System.out.println(i --); System.out.println(i);

www.laratechnology.com

Page 1

LARA TECHNOLOGIES NEW BATCH 7-9AM


i = 3; System.out.println(++ i); System.out.println(i); i = 4; System.out.println(-- i); System.out.println(i); } } 13. Program class L { public static void main(String[] args) { inti = 1; int j = i ++; System.out.println(i); System.out.println(j); } } 14. Program class N { public static void main(String[] args) { inti = 0; int j = i ++ + i; System.out.println(i); System.out.println(j); } } 15. Program class P { public static void main(String[] args) { inti = 0; int j = i++ + ++i + i++ + ++i; System.out.println(i); System.out.println(j); } } 16. Program class T { public static void test() { System.out.println("test"); } public static void main(String[] args) { System.out.println("Hello World!"); } } 17. Program class W { static void test() { System.out.println("from test");

201 2

} public static void main(String[] args) { System.out.println("Hello World!"); test(); } } 18. Program class X { static void test(){ System.out.println("from test"); } public static void main(String[] args){ System.out.println("------"); test(); test(); test(); System.out.println("------"); } } 19. Program class B { public static void main(String[] args) { System.out.println("Hello World!"); test(10); } static void test(inti) { System.out.println(i); } } 20. Program class D { public static void main(String[] args) { inti; int j; i = 10; j = 20; System.out.println("i value:" + i + ", j value is:" + j); } } 21. Program class F { public static void main(String[] args) { inti = 20; test(i); System.out.println("done:" + i); }

www.laratechnology.com

Page 2

LARA TECHNOLOGIES NEW BATCH 7-9AM


static void test(int k) { k = 30; } } 22. Program class G { public static void main(String[] args) { inti = 10; System.out.println("main1:" + i); test(i); System.out.println("main2:" + i); } static void test(inti) { i = 40; } } 23. Program class H { static int test() { return 20; } public static void main(String[] args) { inti = 10; System.out.println("1:" + i); i = i + test(); System.out.println("2:" + i); System.out.println("3:" + test()); } } 23. Program class I { public static void main(String[] args) { inti = 10; System.out.println(test(i)); System.out.println(i); } static int test(inti) { return i++; } } 24. Program class J { public static void main(String[] args) { inti = 0;

201 2
int j = i++ + test(i) + i; System.out.println(i); System.out.println(j); } static int test(inti) return i++; } {

} 25. Program class A { static inti; public static void main(String[] args) { System.out.println(i); } } 26. Program class B { static inti; static void test() { System.out.println("from test:" + i); } public static void main(String[] args) { System.out.println("from main:" + i); } } 27. Program class C { static inti = 10; public static void main(String[] args) { System.out.println(i); } } 28. Program class D { static void test() { System.out.println("from test:" + i); } static inti; public static void main(String[] args) { System.out.println("from main:" + i); i = 10; test(); }

www.laratechnology.com

Page 3

LARA TECHNOLOGIES NEW BATCH 7-9AM


} 29. Program class E { static inti = 10, j; public static void main(String[] args) { System.out.println(i); System.out.println(j); } } 30. Program class F { static inti, j = 10; static int k; public static void main(String[] args) { System.out.println(i); System.out.println(j); System.out.println(k); System.out.println(m); System.out.println(n); System.out.println(p); } static int m, n = 30, p; } 31. Program class G { static inti; public static void main(String[] args) { System.out.println(i); i = 10; System.out.println(i); inti = 20; System.out.println(i); i = 30; System.out.println(i); } } 32. Program class H { static inti; public static void main(String[] args) { System.out.println(i); System.out.println(H.i); i = 10; System.out.println(i); System.out.println(H.i); H.i = 20; System.out.println(i);

201 2
System.out.println(H.i); }

} 33. Program class X { static inti; public static void main(String[] args) { inti = 10; System.out.println(i); System.out.println(X.i); i = 20; X.i = 30; System.out.println(X.i); System.out.println(i); } } 34. Program class A { static inti = 10; static int j = i; public static void main(String[] args) { System.out.println(i); System.out.println(j); } } 35. Program class D { static inti = j; static int j = 10; public static void main(String[] args) { System.out.println(i); System.out.println(j); } } 36. Program class E { static inti = 10; static int j = i; static int k = m; static int m = j; public static void main(String[] args) { System.out.println(i); System.out.println(j); System.out.println(k); System.out.println(m); }

www.laratechnology.com

Page 4

LARA TECHNOLOGIES NEW BATCH 7-9AM


} 37. Program class G { static inti = test(); static int test() { return 10; } public static void main(String[] args) { System.out.println(i); } } 38. Program class H { static inti = test(); static int j = 10; static int test() { return j; } public static void main(String[] args) { System.out.println(i); System.out.println(j); } } 38. Program class J { static int x = test(); static int test() { System.out.println("A:" + x); return 10; } public static void main(String[] args) { System.out.println("B:" + x); } } 39. Program class N { static { System.out.println("SIB"); } } 40. Program class A { public static void main(String[] args) { System.out.println("Hello World!"); } static {

201 2
System.out.println("SIB"); }

} 41. Program class B { static

{ System.out.println("SIB1");

} public static void main(String[] args) { System.out.println("Hello World!"); } static { System.out.println("SIB2"); } } 42. Program class C { static

{ main(null);

} public static void main(String[] args) { System.out.println("Hello World!"); } } 43. Program class D { static { System.out.println(1); main(null); System.out.println(3); } public static void main(String[] args) { System.out.println("from main"); } } 44. Program class E { static inti = test(); static int test() { main(null); return 20; } public static void main(String[] args) {

www.laratechnology.com

Page 5

LARA TECHNOLOGIES NEW BATCH 7-9AM


System.out.println("main:" + i); } } 45. Program class G { static inti = 10; static { System.out.println(i); } public static void main(String[] args) { System.out.println(i); } } 46. Program class H { static inti = 20; static { i = 10; } public static void main(String[] args) { System.out.println(i); } } 47. Program class I { static { x = 10; } static int x = 20; public static void main(String[] args) { System.out.println(x); } } 48. Program class A { inti; public static void main(String[] args) { A a1 = new A(); System.out.println(a1.i); } } 49. Program class H { inti; public static void main(String[] args) { H obj = new H();

201 2
System.out.println(obj.i); obj.i = 10; System.out.println(obj.i);

} } 50. Program class J { int x, y = 10, z; public static void main(String[] args) { J obj1 = new J(); System.out.println(obj1.x); System.out.println(obj1.y); System.out.println(obj1.z); } } 51. Program class K { inti; public static void main(String[] args) { K k1 = new K(); k1.i = 10; K k2 = new K(); k2.i = 20; System.out.println(k1.i); System.out.println(k2.i); } } 52. Program class B { inti; double d; boolean b; public static void main(String[] args) { B b1 = new B(); System.out.println(b1.i); System.out.println(b1.d); System.out.println(b1.b); } } 53. Program class C { inti; int j = 10; C() { i = 20; } public static void main(String[] args) {

www.laratechnology.com

Page 6

LARA TECHNOLOGIES NEW BATCH 7-9AM


C c1 = new C(); System.out.println(c1.i); System.out.println(c1.j); } } 54. Program class E { E() { System.out.println("E()"); } public static void main(String[] args) { E e1 = new E(); System.out.println("----"); E e2 = new E(); } } 55. Program class J { J(int x) { System.out.println("X(int x)"); } J(byte y) { System.out.println("X(int y)"); } public static void main(String[] args) { J obj = new J(90); System.out.println("done"); } } 56. Program class Q { Q(inti) { this(); System.out.println("Q()"); } Q() { this(20); System.out.println("Q(int)"); } } 57. Program class R { R() { this(10); System.out.println("R()"); } R(inti) { System.out.println("R(int)"); } } 58. Program class S { S() {

201 2

System.out.println("S()"); } { System.out.println("IIB"); } public static void main(String[] args) { S s1 = new S(); System.out.println("------"); S s2 = new S(); System.out.println("------"); } } 58. Program class A { A() { System.out.println("A()"); } { System.out.println("IIB1"); } { System.out.println("IIB2"); } public static void main(String[] args) { A a1 = new A(); System.out.println("-----"); A a2 = new A(); System.out.println("-----"); } } 59. Program class C { { System.out.println("IIB1"); } public static void main(String[] args) { C c1 = new C(); System.out.println("-----"); C c2 = new C(); System.out.println("-----");

www.laratechnology.com

Page 7

LARA TECHNOLOGIES NEW BATCH 7-9AM


} } 60. Program class D { static { System.out.println("SIB"); } { System.out.println("IIB"); } public static void main(String[] args) { D d1 = new D(); System.out.println("-----"); D d2 = new D(); System.out.println("-----"); } } 61. Program class F { F() { System.out.println("F()"); } { System.out.println("IIB"); } F(inti) { this(); System.out.println("F(int)");

201 2
B b1 = new B(); System.out.println(b1.i); System.out.println(b1.j);

} } 63. J2SE stands for? 64.JDK stands for? 65. How many classes can be in a java source file? 66.Is it possible to make empty java source file? 67.How many maximum public classes can be in one java source file? 68.Which command is used to compile java source file? 69.Which command is used to run java programs? 70.How to represent current directory in the windows Operating System? 71.By using which command we can update any environment variable for command prompt wise? 72.What is the default value to local variable? 73.What is the default value to global variable of type Boolean? 74.What is the process of passing variable to another method (by value/by reference)? 75.Is it possible to keep a method name as a class name itself? 76.Is it possible to execute something before main method execution? 77.Is it possible to keep super calling statemenet from any place of the constructor body? 78.By using which key word, we can make a sub class from the existing class? 79.How to call another constructor of the same class from the constructor body? 80. Javac command is there inside a lib folder of jdk installation(T/F)? 81. cd stands for? 82. . . represents?

} public static void main(String[] args) { F f1 = new F(); System.out.println("-----"); F f2 = new F(20); System.out.println("-----"); } } 62. Program class A { inti; } class B extends A { int j; public static void main(String[] args) {

www.laratechnology.com

Page 8

LARA TECHNOLOGIES NEW BATCH 7-9AM


83.Which is the mandatory to install jdk? 84. How many ways are there to set a path? 85. Is it possible to use localvarible without initialization? 86. args is an identifier(T/F)? 87. String is a keyword(Y/N)? 88. class is identifier(T/F)? 89. public is a keyword(Y/N)? 90. What is the argument of a main method? 91. Is it possible to develop a java program outside of a jdk installation(Y/N)? 92. How many steps should be taken ,in order to compose a simple helloworld program? 93. static is a keyword(T/F)? 94. Object is storing in heap(T/F)? 95.true is a keyword(T/F)? 96.null is a keyword(T/F)? 97.local variable is storing in heap(T/F)? 98. Which keyword used for differentiating local and global variable? 99. Is it possible to access static members from the non-static members? 100. What is the super class of all classes?

201 2

www.laratechnology.com

Page 9

You might also like