Question
What changes are needed to make the following prg to compile?
import java.util.*;
class Ques{
public static void main (String args[]) {
String s1 = "abc";
String s2 = "def";
Vector v = new Vector();
v.add(s1);
v.add(s2);
String s3 = v.elementAt(0) + v.elementAt(1);
System.out.println(s3);
}
}

A) Declare Ques as public

B) Cast v.elementAt(0) to a String

C) Cast v.elementAt(1) to an Object.

D) Import java.lang

Answers

B) Cast v.elementAt(0) to a String   Your Comment




More Java Questions..
Can variables be used in Java without initialization?

What is the difference between java bean and enterprise java bean?

How does the java database connectivity (jdbc) work?

What are the advantages of threads in java?

What Is Java Api For Xml-based Rpc (jax-rpc)?

What is static synchronized method in JDBC API? Give an example?

Should we override finalize method

What is object cloning in Java?

What is difference between notify() and notfiyAll()

Describe java's security model.

Is there is any error if you have multiple main methods in the same class?

What is the name of the method used to schedule a thread for execution?

1) init();

2) start();

3) run();

4) resume();

5) sleep();

Can I import the same package/class twice? Will the JVM load the package twice at runtime?

What releases of Java technology are currently available? What do they contain?

What is asymmetric clustering in WebSphere?

What is pass by value and pass by reference?

What are the actions that can occur when a thread enters blocked state

How do I launch the browser using WebDriver

What is the use of Void(0)?

How does the native language C or C++ understand data types in JAVA



Search
Can you Answer!!
  • Q Which planet is known as the morning star or the evening star?
  • Q Which of the following conditions would create the physical exam findings below?
  • Q What will occur with the following code in SQL Server 2005 if executed by Alice?
  • Q Explain ipv4 and ipv6 address bit?
  • Q What will you do if you're not selected?
  • Q What are the problems and prospects of Liberalisation in Indian society?
  • Q write a program to add two matrix
  • Q 'Springing Tiger; A Study of a Revolutionary' is a biographical work on?
  • Q Name of which household object comes from Latin to wonder at
  • Q What are the scala variables?
  • Q How can one increase the longevity of an organization?