Monday 19 September 2011

Esoteric programming language

An esoteric programming language (sometimes shortened to esolang) is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke. There is usually no intention of the language being adopted for mainstream programming, although some esoteric features such as visuospatial syntax have inspired practical applications in the arts. Such languages are often popular among hackers and hobbyists. This use of esoteric is meant to distinguish these languages from more popular programming languages.
Usability is rarely a high priority for such languages; often quite the opposite. The usual aim is to remove or replace conventional language features while still maintaining a language that is Turing-complete, or even one for which the computational class is unknown.

A sample program in java2k

FOR-1 07=119 TO-/12 4DO/*/_\/12 4=13 2=*+*.+_.\+119 =11 6=*+_.+13 2/*/_\..
16  /125 =119 =125 =11 6=*+_.+_.+125 /13 2/*/_\/_\.+125 /131 /119 /125 /11 6/*/_\/_\/
125 =13 2=*+_.+_.\/119 =125 =11 6=*+_.+_.+125 /13 2/*/_\/_\.\/131 =119 =125 =11 6=*+_
.+_.+125 /13 2/*/_\/_\.+131 /119 /125 /11 6/*/_\/_\/125 =13 2=*+_.+_.\/131 =119 =125 
=11 6=*+_.+_.+125 /13 2/*/_\/_\.+131 /119 /125 /11 6/*/_\/_\/125 =13 2=*+_.+_.\/131 =
119 =125 =11 6=*+_.+_.+125 /13 2/*/_\/_\.+119 /125 /11 6/*/_\/_\/125 =13 2=*+_.+_.\.\
.\.\./837=119 /12 4/*/_\/12 4=13 2=*+*.+_.\+119 /12 4/*/_\/12 4=13 2=*+*.+_.\.\
1 1 =*+837/119 /12 4/*/_\/12 4=13 2=*+*.+_.\/119 /12 4/*/_\/12 4=13 2=*+*.+_.\\.

Obligatory hello-world program in Java2k

1 1 /125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2
/*/_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2
/*/_\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\
\\\\\\\/*\1 1 /125 /119 /11 6/*/_\/13 2/*/_\\/
125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\
/125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\
\\\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\
\\\\\\\/*\1 1 /125 /131 /119 /125 /11 6/*/_\/_\
/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\/
125 /13 2/*/_\/_\\\/125 /131 /119 /125 /11 6/*/
_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/
_\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\
/125 /13 2/*/_\/_\\\\/125 /131 /119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/
_\/125 /13 2/*/_\/_\\\\\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_
\/125 /13 2/*/_\/_\\\\\\\\\\/*\1 1 /125 /131 /
119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\/125 /
131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/
131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/
119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\\/
125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\
\\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\\
\\\\\\/*\1 1 /125 /119 /11 6/*/_\/13 2/*/_\\/
125 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/
125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\
/125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\
\\/125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*
/_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*
/_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*
/_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*
/_\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_
\\\\\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\
\\\\\\\\\\\/*\1 1 /125 /131 /119 /125 /11 6/*/_
\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\/
125 /13 2/*/_\/_\\\/125 /131 /119 /125 /11 6/*/
_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/
_\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\
/125 /13 2/*/_\/_\\\\/131 /119 /125 /11 6/*/_\/
_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\/
_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\/
_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\/
_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\/
125 /13 2/*/_\/_\\\\\\\\/*\1 1 /131 /119 /125 /
11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /
11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /
11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /
11 6/*/_\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\\\\\/*\1 1 /125 /
119 /11 6/*/_\/13 2/*/_\\/125 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/125 /131 /119 /125 /
11 6/*/_\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\\/125 /131 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/119 /125 /
11 6/*/_\/_\/125 /13 2/*/_\/_\\\\\/131 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/119 /125 /
11 6/*/_\/_\/125 /13 2/*/_\/_\\\\\\\\\\\/*\
1 1 /125 /119 /11 6/*/_\/13 2/*/_\\/125 /119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/125 /131 /
119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\/125 /
131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/
131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/
119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\\/
125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\
\\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\\
\\\\\\\\/*\1 1 /125 /119 /125 /11 6/*/_\/_\/
125 /13 2/*/_\/_\\/125 /131 /119 /125 /11 6/*/_
\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_
\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_
\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\/
125 /13 2/*/_\/_\\\\\/125 /131 /119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/
*/_\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/
_\/125 /13 2/*/_\/_\\\\\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*
/_\/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_
\/125 /13 2/*/_\/_\\\\\\\\\\/*\1 1 /125 /131 /
119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/119 /
125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\/125 /
131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/
131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\/
119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\\/
125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\
\\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/
_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\\
\\\\\\/*\1 1 /125 /131 /119 /125 /11 6/*/_\/_\/
125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\/125 /
13 2/*/_\/_\\\/125 /131 /119 /125 /11 6/*/_\/_\
/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\/_\
/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\/_\
/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\/_\
/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\/
125 /13 2/*/_\/_\\\\\\/131 /119 /125 /11 6/*/_\
/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\
/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\
/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\
/_\/125 /13 2/*/_\/_\\/131 /119 /125 /11 6/*/_\
/_\/125 /13 2/*/_\/_\\/119 /125 /11 6/*/_\/_\/
125 /13 2/*/_\/_\\\\\\\\\/*\

Test instruction in java2k

ZIRO-IQUALZ-11 6/*/_\-RIGHT

Test your Java language skills – Quiz 1

1.  Which of the following is not a specific GUI component (control or
widgit)?
a)String.
b)Label.
c)Menu.
d) List.

2.  Which of the following is not a valid constructor for a JLabel?
a)JLabel( int, horizontalAlignment, Icon image );
b)JLabel(Icon image );
c)JLabel( String text, Icon image, int horizontalAlignment );
d)JLabel( String text, int horizontalAlignment );

3.  Which of the following is not necessary to use the event
delegation model?
a) An event listener must be registered.
b)An event handler must be implemented.
c) The appropriate interface must be implemented.
d)The appropriate interface must be registered.

4.  Which of the following is a MouseMotionListener method?    
a) mousePressed.
b) mouseExited.
c)mouseDragged.
d)mouseClicked.

5.  The layout manager that allows alignment to be controlled is:
a) FlowLayout. 
b) BorderLayout. 
c)GridLayout.  
d)None of the above.

6.  Which of the following GridBagConstraints specifies the number of
columns a component will  occupy?
a)  gridwidth.   
b)gridheight.  
c) weightx.   
d)weighty.

7.  A JFrame supports three operations when the user closes the
window. Which of the choices below is not one of the three:
a) DISPOSE_ON_CLOSE.  
b)DO_NOTHING_ON_CLOSE.  
c)LOWER_ON_CLOSE. 
d)HIDE_ON_CLOSE.

8.  To create a fixed space between all components using BoxLayout,
use the method:
a) createVerticalStrut().
b)createHorizontalStrut().
c)createGlue().
d)createRigidArea().

9.  Which layout manager is the default for JFrame?
a) FlowLayout.
b)BorderLayout.
c)GridLayout.
d)None of the above. 

10.  When a JComboBox is clicked on:
a)An ItemEvent is generated. 
b)A scrollbar is always generated.
c)An ActionEvent is generated.  
d)The JComboBox expands to a list.


CLICK HERE FOR QUIZ 2

Test your Java language skills – Quiz 1 Answers

1.    A
2.    A
3.    B
4.    C
5.    D
6.    A
7.    C
8.    D
9.    B
10.    C

Test your Java language skills – Quiz 2

Question No. 1: What is the result of compiling and running the following code?

class PrintTest{

public static void main(String[] args) {
double d=222.4578;
System.out.printf(“% .2f”,d);
}

}

A.Does not compile
B.Throws IllegalFormatConversionException
C.Prints 222.46
D.Prints 222.45
E.Prints 2.224578
F.Prints .2224578


Question No. 2
What is the result of compiling and running the following code, assuming that the file bb.txt does not exist?

class WriterTest{

public static void main(String[] args) throws IOException{
Writer w=new BufferedWriter(new FileWriter(“bb.txt”)); // Line1
w.write(1); // Line2
w.close();

}

}

A.Compiler error
B.FileNotFoundException thrown at line 1
C.IOException thrown at line 2
D.None of these


Question No. 3
Which of the following statements are true about the default implementation of the public int hashCode() method of the Object class?

A.The Object class does not provide any implementation for the hashCode method; every class must override it.
B.As far as it may be practically possible, the hashCode method defined by the Object class does return distinct integers for distinct objects.
C.For two object references referring to the same object, the hashCode method returns the same integer.
D.It returns a fixed number that internally represents the Object class for the JVM.
E.Only choice D is correct.

Test your Java language skills – Quiz 2 Answers



Question 1 Correct Choice: C

Explanation
Choice C is the correct answer. For floating-point conversions using %f, the precision is the number of digits after the decimal separator. So 0.2f has 2 as the precision, i.e., there must be 2 digits after the decimal point, rounding off is done if necessary. Here the value is rounded to 222.46. So choices D, E, and F are incorrect.

There are no compiler errors or exceptions, so choices A and B are also incorrect.

You can get more information about the printf method at
http://java.sun.com/j2se/5.0/docs/api/java/io/PrintStream.html
 

Question 2 Correct Choice: D

Explanation:
Choice D is the correct answer. The FileWriter constructor does not throw FileNotFoundException, if the named file does not exist. In this case, a new file is created by the constructor, if the underlying platform allows this operation. If the named file exists, but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason, the constructor itself throws IOException. So choice D is correct, while choice C is incorrect. Choice A is incorrect because there are no compiler errors in the given code.

 

Question 3 Correct Choice: B & C

Explanation:
Choices B and C are the correct answers. The Object class does implement the hashCode method. This
default implementation of the hashCode method is in accordance with the default implementation of the equals() method in the Object class. This is what the API says about it -
. Returns a hash code value for the object.
. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of the hashCode method is:

Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.

. If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer as the result.

. It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects might improve the performance of hashtables.

Also, as much as is reasonably practical, the hashCode method defined by the Object class does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java programming language.)

Choice D is incorrect because the returned number has no relation with the class of the object. Hence, choice E is also incorrect.