Interview Questions → JAVA → Java Questionnaire I

Java Questionnaire I











































class CallByValue
{
	void change(int i)
	{
		i=i*20;
		System.out.println("inside method i= "+i);
	}
}

class MainClass
{
	public static void main(String args[])
	{
		CallByValue v=new CallByValue();
		int x=20;
		System.out.println("Before call x =" + x);
		v.change(x);
		System.out.println("After call x =" + x);
	}
}














class CallByReference
{
	int i;
	CallByReference(int j)
	{
		i=j;
	}

	void change(CallByReference r)
	{
		r.i=r.i*20;
		System.out.println("inside method i ="+r.i);
	}
}

class MainClass
{
	public static void main(String args[])
	{
		CallByReference r1=new CallByReference(20);
		System.out.println("Before call i ="+r1.i);
		r1.change(r1);
		System.out.println("After call i ="+r1.i);
	}
}
















class ConvertStringToNumberDemo
{
	public static void main(String[] args) 
        {
        	String str = "1234";
                int num = Integer.parseInt(str);	
		System.out.println(num);		
	}
}
















class BitwiseAndDemo
{
  public static void main(String args[])
  {
        boolean  operandOne, operandTwo, result;
        operandOne = true;
        operandTwo = false;
        result = operandOne & operandTwo;
        System.out.printf("result is = " + result);	
  }
}






class ConditionalAndDemo
{
  public static void main(String args[])
  {
      boolean  operandOne, operandTwo, result;
      operandOne = true;
      operandTwo = false;
      result = operandOne & operandTwo;
      System.out.printf("result is = " + result);	
  }
}








Posted By  -  Karan Gupta


Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250