Tutorial 4
Tutorial 4
Tutorial-4
Objective: The main objective of this tutorial is to learn about the basics of Wrapper classes, arrays
and user-defined method invocation in java language.
4.1 Compile and run the below code? Mention the reason?
b2 = b1;
if (!b2)
{
b2 = true;
System.out.print("x ");
}
if (b1 | b2)
{
System.out.print("y ");
}
if(b1 || !b2)
System.out.println("z");
}
}
import java.util.*;
import java.util.*;
class prob4 {
public static void main(String args[]) {
int arr1[] = {11, 22, 33};
int arr2[] = {11, 22, 33, 44, 55};
int ptr[];
ptr = arr1;
arr1 = arr2;
arr2 = ptr;
System.out.print(arr1.length + " ");
System.out.println(Arrays.toString(arr1));
System.out.print(arr2.length+" "+Arrays.toString(arr2));
}
}
class prob4 {
public static void main(String[] args)
{
int arr[] = { 11, 22, 33 };
for (int i = 0; i < arr.length; i++)
System.out.print(arr[i] + " ");
System.out.println();
class prob4 {
public static void main(String[] args)
{
int arr[] = new int[5];
int arr2[] = new int['a'];
byte bt = 10;
int arr3[] = new int[bt];
System.out.println(arr.length);
System.out.println(arr2.length);
System.out.println(arr3.length);
}
}
School of Computer Science Engineering and Technology
class prob4 {
public static void main(String[] args)
{
String str[] = { "Geeks", "for", "Geeks" };
System.out.println(str.length);
System.out.println(str[0].length);
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
}
public
class Main {
public
int foo() { return 10; }
public
char foo() { return 'a'; }
public
static void main(String args[]) {
foo();
}
}