1) What does bytebuffer.wrap() do?
ByteBuffer.wrap takes an existing byte[] and creates a ByteBuffer from it exposing methods that correspond to buffer relation actions such as getShort().
2) If i put bytes like this: bytebuffer.wrap(bytes), what will happen?
You will fill the ByteBuffer with the contents of bytes instead of arr, arguably since arr is assigned to bytes just previously this will be an okay action. Although taking a copy of it is a good idea if you intended to use bytes as an original value later but that isn't present in this code.
3) What is getshort() method? What does it do?
The buffer contains a constant stream of bytes and a current location. When you getShort() you read two bytes from the current position and put them into the short structure. As present in the comments below your question
If two byte values are hex 0x95,0x24, decimal -107,36, then short is
hex 0x9524, decimal -27356
These are appended as shown 0x9524 and then read out as if it was a short in structure, not two bytes. This removes one of the sign bits and treats it as a data bit which gives you a large negative value if the first value is negative.
4) What does "num" value represent?
That's hard to answer without saying the obvious. It represents the first two bytes composed as one short of data. In your first example you use
byte[] arr = { 0x00, 0x01 };
Which when appended is the short 0x0001 giving you the value 1. Commonly this "num" variable you have created is used like this in Network I/O Packet Structures and it usually represents the number of bytes in the packet after the first short or the packet type such as "Game Data" or similarily.
byte[] arr={127,12,-74,85,-3,0,-112,104,.........}
In this case it will read the first to bytes 127 and 12. These correspond to 0x7F and 0x0C which will give "num" = 0x7F0C = 32524. When you call this method with different byte arrays only the first two numbers are accounted for in num.
5) Is "num" representing single integer value of entire byte array of size 1024?
No, it represents only the first two bytes as shown in previous questions. The size of the array as long as it is bigger than 2 (sizeof(short) = 2 on normal systems) doesn't matter.