Utpal Kumar

Greenhorn
+ Follow
since Jan 19, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Utpal Kumar

Hi, i have the below piece of code for swapping.


Now when i use List backed by Integer array like below



It works fine and gives output as [2,1]

but i use List backed by int array like below



throws ArrayIndexOutOfBounds exception. Little help please
interface AB{}

class D {}

class C{}

public class InstanceTest
{
public static void main(String[] args)
{
D d = new D();
System.out.println(d instanceof AB);  // returns false;
               System.out.println(d instanceof C); // compilation error due to different types.

}
}

Question: Why for interface, compiler didn't throw error ? There is no relation between Class D and Interface AB.
yes, i copied correctly from book. Bitwise operator is used in example not the short circuit operator.
pardon me for being silly. I understand it now that command line input is only live2. Not whole "java Fork live2". java Fork is just calling the .class file.
Hi guys, i am preparing for oca 8, and going through books OCA java SE 8 by kathy Sierra and Bert Bates. I found this problem at page no. 264. Please have a look and answer my question.




And the command-line invocation:

java Fork live2

Ideally if i consider "java Fork live2" as input in one go the output of above program is "production java", but as per book it's arrayindexoutofbounds excepiton. Which will only come if we enter only one word at runtime through command prompt such as either java, Fork, or live2.

So my question is, in exam if questions are asked like this how we distinct whether it is taking one word at runtime or complete sentence.
Hi guys, could you help me out with below questions.

1) What happens to super() call to Object class constructor. I mean constructor whether it's no-arg or arg, executes parent to child. So Object being Super class of all, how Object class defines or execute it's no-arg or arg constructor.

2) void nameMe() { return; } ----> It is allowed as method return type is void so "return;" make sense. what about constructor? We know constructor have not return type, still we can write "return;" inside constructor like this.

class A{
  A() {
     return;
  }
}

question here is, why is that? "void" in constructor is not allowed but "return;" is allowed.
I could find toString() method overloaded in any collection class or Interface , so why collection object shows all the content inside it simply when we print it.

like: - SortedSet<Integer> sortedSet = new TreeSet<Integer>();
sortedSet.add(5);
sortedSet.add(2);
sortedSet.add(9);
sortedSet.add(1);
sortedSet.add(6);

System.out.println(sortedSet); // [1, 2, 5, 6, 9]

1 year ago