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 :: Packages

Home > JAVA Programming > Packages > General Questions

1. Name the access modifier which when used with a method, makes it available to all the classes in the same package and to all the subclasses of the class.

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!

2. Which of the following are legal identifier names in Jav Select the correct answers.

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

Answer: Option B

Explanation:

Java identifier name cannot begin with a digit.

Workspace

Tags:

No Tags on this question yet!

3. You have a class file name Test.class inside javaproject directory.

Test.java source code is :
import javutil.Properties;
class Test {
public static void main (String[] args){
Properties p = System.getProperties();
System.out.println(p.getProperty("key1"));
}
}
you have issued below commands from command prompt.
cd javaproject
java -D key1=value1 Test
What is the output ?

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

Answer: Option D

Explanation:

name=value pair must follow immediately, no spaces allowed. In this case there is space between -D and key1=value1 So javlang.NoClassDefFoundError:
key1=value1.

Workspace

Tags:

No Tags on this question yet!

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

Answer: Option A

Explanation:

HashMap can be synchronized by Map m = Collections.synchronizeMap(hashMap);

Workspace

Tags:

No Tags on this question yet!

5. What is the output for the below code ?

package bean;
public class Abc {
public static int index_val = 10;
}
package com;
import static bean.Abindex_val;
public class Test1 {
public static void main(String... args) {
System.out.println(index_val);
}
}

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

Answer: Option A

Explanation:

The static import construct allows unqualified access to static members without inheriting from the type containing the static members. J2SE 5.0 onwards it allows static import like import static bean.Abindex_val; and can be use directly System.out.println(index_val);

Workspace

Tags:

No Tags on this question yet!

6. What is the output for the below code ?

1. public class D {
2. int i;
3. int j;
4. public D(int i,int j){
5. this.i=i;
6. this.j=j;
7. }
8. public void printName() {
9. System.out.println("Name-D");
10. }
11. }
12. public class Test{ 13. public static void main (String[] args){
14. D d = new D();
15. d.printName();
16. }
17. }

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

Answer: Option B

Explanation:

Since there is already a constructor in this class (public D(int i,int j)), the compiler won't supply a default constructor. If you want a no-argument constructor to overload the with arguments version you already have, you have to define it by yourself. The constructor D() is undefined in class D. If you define explicit constructor then default constructor will not be available. You have to define explicitly like public D(){ } then the above code will work. If no constructor into your class , a default constructor will be automatically generated by the compiler.

Workspace

Tags:

No Tags on this question yet!