String and arrays related exercise questions..

.. without answers! Ha ha!


String Related Questions

String foo = "foo";
String foo = new String("foo");
  • How do you find out the length of..
    • a String?
    • an array?
  • What is the value of x in the following code?
String x = "012345678";
x = x.substring(0,5);
  • Why use StringBuilder?
  • Why use StringBuffer?
  • What is the default capacity of StringBuilder?


Array Related Questions

  • How do you declare an array?
  • How do you instantiate a..
    • one dimensional array?
    • two dimensional array?
    • three dimensional array?
  • How do you instantiate and initialize an array in one statement?
  • How do you instantiate and initialize an anonymous array?
  • Will a short go into a int[]
  • Given Dog extends Animal, will a Dog object go into an Animal[]?
  • Will the following compile & run?
int[] intArr = new int[1];
byte[] byteArr = new byte[1];
 
intArr = byteArr;
  • Will the following compile & run?
class Animal {}
class Dog extends Animal {}
class Test {
    {
        Dog[] dogs = new Dog[1];
        Animal[] animals = new Animal[3];
        animals = dogs;
    }
}