You are on page 1of 1

Python:

1.Array vs. list : array can hold only one type of data,while lists can hold mixed
types
2.
What does [::-1} do?
Ans: [::-1] is used to reverse the order of an array or a sequence.
For example:
import array as arr
My_Array=arr.array('i',[1,2,3,4,5])
My_Array[::-1]
Output: array(‘i’, [5, 4, 3, 2, 1])
[::-1] reprints a reversed copy of ordered data structures such as an array or a
list. the original array or list remains unchanged.
3.
How can you randomize the items of a list in place in Python?
Ans: Consider the example shown below:
from random import shuffle
x = ['Keep', 'The', 'Blue', 'Flag', 'Flying', 'High']
shuffle(x)
print(x)
The output of the following code is as below.
['Flying', 'Keep', 'Blue', 'High', 'The', 'Flag']
4.range and xrange : generate a random list of integers;range it generates the list
visibly,
while xrange in memory and access it with var[index];xrange returns an xrange
object which helps with memory,values generated with yielding

Java:
1.
JRE = Java runtime environment;set of software tools ;contains files and libraries
that JVM uses at runtime
2.
JDK = Java development kit;software development environment used for developing
java apps;JRE + development tools
3.
Explain public static void main(String args[]) in Java.
4.
main() in Java is the entry point for any Java program. It is always written as
public static void main(String[] args).
public: Public is an access modifier, which is used to specify who can access this
method. Public means that this Method will be accessible by any Class.
static: It is a keyword in java which identifies it is class-based. main() is made
static in Java so that it can be accessed without creating the instance of a Class.
In case, main is not made static then the compiler will throw an error as main() is
called by the JVM before any objects are made and only static methods can be
directly invoked via the class.
void: It is the return type of the method. Void defines the method which will not
return any value.
main: It is the name of the method which is searched by JVM as a starting point for
an application with a particular signature only. It is the method where the main
execution occurs.
String args[]: It is the parameter passed to the main method.

You might also like