Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

JAVA Programming :: Basic Concepts

Home > JAVA Programming > Basic Concepts > General Questions

41. What is the output for the below code?

public class Test {
public static void main(String[] args){ int i = 010;
int j = 07;
System.out.println(i);
System.out.println(j);
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

By placing a zero in front of the number is an integer in octal form. 010 is in octal form so its value is 8.

Workspace

Tags:

No Tags on this question yet!

42. What is the output for the below code?

1. public class Test {
2. public static void main(String[] args){
3. byte b = 6;
4. b+=8;
5. System.out.println(b);
6. b = b+7;
7. System.out.println(b);
8. }
9. }

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

int or smaller expressions always resulting in an int. So compiler complain about Type mismatch: cannot convert from int to byte for b = b+7; But b += 7;
because +=, -=, *=, and /= will all put in an implicit cast. b += 7 is same as b = (byte)b+7.

Workspace

Tags:

No Tags on this question yet!

43. What is the output for the below code?

public class Test {
public static void main(String[] args){
String value = "abc";
changeValue(value);
System.out.println(value);
}
public static void changeValue(String {
a = "xyz";
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Java pass reference as value. passing the object reference, and not the actual object itself. The parameter is essentially a local variable.

Workspace

Tags:

No Tags on this question yet!

44. What is the output for the below code?

public class Test {
public static void printValue(int i, int j, int k){
System.out.println("int");
}
public static void printValue(byte...b){
System.out.println("long");
}
public static void main(String... args) {
byte b = 9;
printValue(b,b,b);
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Primitive widening uses the smallest method argument possible.

Workspace

Tags:

No Tags on this question yet!

45. You have a java file name Test.java inside src folder of javaproject directory.
You have also classes folder inside javaproject directory.
you have issued below command from command prompt.
cd javaproject
Which of the below command puts Test.class file inside classes folder ?

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

The -d option lets you tell the compiler in which directory to put the .class file it generates (d for destination)

Workspace

Tags:

No Tags on this question yet!

46. What is the result of compiling and running the following program.
public class test {
public static void main(String args[]) {
String str1="abc";
String str2="def";
String str3=str1.concat(str2);
str1.concat(str2);
System.out.println(str1);
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

47. What is the Output o the below code:

public class Base {
public void method(int i) {
System.out.println("Base class Value is" + i);
}
}
public class Sub extends Base {
public void method(int j) {
System.out.println("Sub class Value is" + j);
}

public static void main(String args[]) {
Base b1 = new Base();
Base b2 = new Sub();
b1.method(5);
b2.method(6);
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

48. Which of these classes defined in javio and used for file-handling are abstract. Select the two correct answers.

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

50. What is the output of the below code:

public class Example {
int x = 50;
int y = 100;
public static void main(String args[]) {
int x = 0, y = 10;
Example ex = new Example();
while(x < {
x++; y--;
}
System.out.println("X = "+x+",Y ="+y);
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

x = 3, y = 7

Workspace

Tags:

No Tags on this question yet!