Java Questions

Q:

Which of the following is not the other name of attriibute?

A) Data member B) Instance variable
C) instance D) Data filed
 
Answer & Explanation Answer: C) instance

Explanation:

Instance is an object not an attribute

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2212
Q:

What is String Args in Java?

Answer

String Args (String []) is an array of parameters of type String.


In Java, 'args' contains the supplied command-line arguments as an array of String objects. In other words, if you run your program as 'java MyProgram Hello World' then 'args' will contain ["Hello", "World"]. When a java class is executed from the console, the main method is what is called.

Report Error

View answer Workspace Report Error Discuss

9 2211
Q:

Can a class be declared as protected?

Answer A class can't be declared as protected. only methods can be declared as protected.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2206
Q:

Can you access non static variable in static context ?

Answer

A static variable in Java belongs to its class and its value remains the same for all its instances. A static variable is initialized when the class is loaded by the JVM. If your code tries to access a non-static variable, without any instance, the compiler will complain, because those variables are not created yet and they are not associated with any instance.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2206
Q:

What are the basic interfaces of Java Collections Framework ?

Answer

Java Collections Framework provides a well designed set of interfaces and classes that support operations on a collections of objects. The most basic interfaces that reside in the Java Collections Framework are:


Collection, which represents a group of objects known as its elements.


Set, which is a collection that cannot contain duplicate elements.


List, which is an ordered collection and can contain duplicate elements.


Map, which is an object that maps keys to values and cannot contain duplicate keys.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 2201
Q:

What is final method?

Answer

Final method is a method defined in the super class with final modifier.


We cannot overriding final method of super class in the sub class.


EX:


 Class Sample {


   final void funOne() {


   }


   void funTwo() {


   }


}


Class Sub extends Sample {


  void funOne() { // overriding is not allowed


  }


  viod funTwo() { //overriding is allowed


  }


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2198
Q:

In a single virtual machine, the Java programming language passes arguments by

A) Refference B) Value
C) Both A and B D) None
 
Answer & Explanation Answer: B) Value

Explanation:

In single virtual machine,JVM passes arguments only by value.

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2187
Q:

What is the return type of the main() method?

Answer Main() method doesn't return anything hence declared void.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2173