Sunday, October 11, 2015

मंगल के बाद प्लूटो पर मिला नीला अाकाश अौर ठंडा पानी

Fri, 09 Oct 2015 02:06 AM (IST)
नई दिल्ली। अमेरिकी अंतरिक्ष एजेंसी नासा के नए होराइजंस स्पेसक्राफ्ट ने प्लूटो के विशाल चंद्रमा कैरन की अब तक की सबसे बेहतरीन उच्च गुणवत्ता वाली तस्वीरें भेजी हैं। इस तस्वीर की खूबसूरती को देख वैज्ञानिक भी अचंभे में हैं। तस्वीर से प्लूटो पर नीले अासमान अौर ठंडे पानी का संकेत मिल रहा है। दक्षिण पश्चिम अनुसंधान संस्थान (SwRI) के प्रमुख अन्वेषक एलन स्टर्न ने बताया कि इससे नीले आकाश की उम्मीद करनी होगी। यह बहुत खूबसूरत है। नासा द्वारा इस महत्वपूर्ण खोज में प्लूटो पर बर्फीले पानी के कई छोटे कणों का पता चला है।
पढ़ेंःस्पेस शॉटगन विकसित कर रहा नासा
अमेरिकी अंतरिक्ष एजेंसी नासा ने बताया कि कैरन पर रंगों की विविधता प्लूटो के सबसे विचित्र लाल उत्तरी ध्रुव जितनी नहीं है। एक तस्वीर से प्रतीत होता है कि कैरन पर गड्ढे ऊंचाई पर हैं और घाटियों की श्रृंखला है। जबकि दूसरी तस्वीर में उत्तरी कैरन के भूमध्यरेखा की घाटियां दिखती हैं।
ये घाटियां पूरे कैरन के सामने की तरफ 1600 किमी के दायरे में फैली हुई हैं और ये दूसरी तरफ भी हो सकती हैं। कोलराडो स्थित साउथवेस्ट रिसर्च इंस्टीट्यूट में न्यू होराइजंस के उप प्रमुख जॉन स्पेंसर ने बताया कि प्लूटो और कैरन की संयुक्त तस्वीरें दोनों की विचित्र भिन्नताओं पर प्रकाश डालती हैं।

Thursday, September 24, 2015

How to get this Java Program

public class HelloWorld{
    public static void main(String args[]){
       int a=1;
       int c=1;
       if((( 5<7)||(++c<10)) | a++<10)
       a=a+1;
       if((6>8)^false) a=a+10;
       if(!(a>1)&& ++c>1) a=a+100;
       System.out.println(a + " " +c);
   }
}

What could be its o/p and Why?


‪#‎include‬<stdio.h>
void fun(int);
typedef int (*pf) (int, int);
int proc(pf, int, int);
int main(){
    int a=3;
    fun(a);
    return 0;
}
void fun(int n){
    if(n > 0){
    fun(--n);
    printf("%d,", n);
    fun(--n);
}
}

Monday, February 2, 2015

1. Show Main Thread

1. Write a program to display the name of thread while executing the main() method.
Solution

class ShowMyName{
      public static void main(String[] args){
             String threadName = Thread.currentThread().getName();
             System.out.println("The name of current thread is "+threadName);
      }
}

after compilation, run the program and see the result as follows:
prompt>java ShowMyName
The name of current thread is main

Hello Name - 2

3. Write a program in java to print "Hello Name" using command line argument with taking care of possible runtime exception.
Solution

class User{
     public static void main(String[]  args){
         String name = "";
         if(args.length==1)name = args[0];
         System.out.println("Hello "+name);
     }
}

After compilation, run this program as follows and watch the output in next line:
prompt>java User Amit
Hello Amit

prompt>java User
Hello

Hello Name

2. Write a program in java to print "Hello Name" where Name will be passed as command line argument at run time.
Solution:

class User{
     public static void main(String[]  args){
         String name = args[0];
         System.out.println("Hello "+name);
     }
}

After compilation, run this program as follows and watch the output in next line:
prompt>java User Amit
Hello Amit

Caution: if nothing is passed from command line argument, it will show an Run-time Exception as ArrayIndexOutOfBoundsException, as there will be no element in the String array 'args'.

Back to Exercise

Excercise Solution 1

1. Write a program in java to print or display "Hello World".
class User{
       public static void main(String[] args){
              System.out.println("Hello World");
      }
}

Save the above code into a file, let us say User.java
Compile the source file from the command prompt:
prompt>javac User.java
Now you will have two files, one is your source file User.java and another one is the compiled file namely User.class
Now execute your newly born class as follows and watch the output on next line.
prompt>java User
Hello World

Back to Exercise