public class Charat {
public static void main(String[] args) {
String str = "Hello";
char ch = [Link](1);
[Link](ch);
}
}
public class Continuelab {
public static void main(String[] args) {
int I = 0;
outer:
while (true)
{
I++;
inner:
for (int j = 0; j < 10; j++)
{
I += j;
if (j == 3)
continue inner;
break outer;
}
continue outer;
}
[Link](I);
}
}
public class ContinueLabel {
public static void main(String[] args) {
outer: for (int i=0; i<10; i++) {
for(int j=0; j<10; j++) { if(j > i) {
[Link](); continue outer;
}
[Link](" " + (i * j));
}
}
[Link]();
}
}
class Country {
// Static variable
static int countryCounter;
String name;
int dummyCounter;
public static void main(String[] args) {
// Creating first instance
Country ob1 = new Country();
// Assigning values to object's data variables.
[Link] = "India";
[Link] = 1;
++[Link];
// Creating second instance of the class
Country ob2 = new Country();
[Link] = "france";
[Link] = 1;
++[Link];
[Link]("[Link] = " + [Link]);
[Link]("[Link] = " + [Link]);
[Link]("[Link] = " + [Link]);
}
}
public class InstaVar {
public String student; // Declared Instance Variable
InstaVar()
{ // Default Constructor
[Link]= "Yogananda"; // initializing Instance Variable
}
public static void main(String[] args) {
// TODO Auto-generated method stub
// Object Creation
InstaVar name = new InstaVar();
[Link]("Student name is: " + [Link]);
}
public class LocalVar {
public static void main(String[] args) {
// TODO Auto-generated method stub
int var = 89; // Declared a Local Variable
// This variable is local to this main method only
[Link]("Local Variable: " + var);
}
}
public class PrintArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] array = { "hi", "hello", "java"};
for(String str : array) {
[Link](str);
}
}
}
class StaticVariableDemo {
static int staticVar = 40; // Static variable
public void display() {
[Link]("Static variable value: " + staticVar);
}
public static void main(String[] args) {
StaticVariableDemo obj1 = new StaticVariableDemo();
StaticVariableDemo obj2 = new StaticVariableDemo();
[Link](); // Output will be 40
[Link] = 50; // Changing staticVar using class name
[Link](); // Output will be 50 for both instances
}
}
public class StatVar {
public static String student= "Yatish"; //Declared static variable
public static void main(String[] args) {
// TODO Auto-generated method stub
//student variable can be accessed without object creation
[Link]("Student Name is : "+[Link]);
class Abc {
int val;
Abc() {
[Link]("Default Constructor Called");
}
Abc(int x)
{
//this();
val=x;
[Link]("Param Constructor " +val);
}
}
class ThisEx {
public static void main(String args[]){
Abc obj=new Abc(10);
}
}
class Student {
String name;
int age;
// Constructor with parameters using 'this' to refer to instance variables
public Student(String name, int age) {
[Link] = name;
[Link] = age;
}
// Method to display student details
public void display() {
[Link]("Name: " + [Link]);
[Link]("Age: " + [Link]);
}
// Method to demonstrate 'this' can be used to call another method
public void showDetails() {
[Link](); // 'this' refers to the current object's method
}
}
public class Main {
public static void main(String[] args) {
// Creating an object of Student class
Student student1 = new Student("Alice", 21);
// Calling the method using the 'this' keyword
[Link]();
}
}