Java Training in Chennai – Basics – Learning – Part – I

This blog explains about Java Training in Chennai – Basics – Learning – Part – I . It is clearly discussed below .

 ____________________________________________________________________

                              Core Java Training

                                                                  Chapter 3: Java Programming

What is the incorrect statement about JDK, JRE, JVM and JIT

JIT is Just In Time Compiler and it is inside the JVM

Java Compiler is included in JDK (Java Development Kit)

JRE contains JVM and the java class libraries and the run-time libraries

JVM contains JRE and the java class libraries and the run-time libraries

 

What is true about JDK and JRE?

When JDK is installed JRE is included along with it

When JRE is installed JDK is included along with it

JRE contains the java compiler for compiling the java source code

Developers only need JRE for writing the programs, JDK is needed for the users of the program

What is JDK and what is JRE?

JDK is Java Development Knowledge and JRE is Java Runtime Executor

JDK is Java Development Knowledge and JRE is Java Runtime Environment

JDK is Java Development Kit and JRE is Java Runtime Environment

None of the above

What will be the output of the following program.

class helloworld

(

    public static void main(String[] u)

    {

        System.out.println(“Payilagam”);

    }

)

 

public class Test {    

    int a = 10;

   public void doStuff(int a) {

        a += 1;

        System.out.println(a++);

    }

    public static void main(String args[]) {

        Test t = new Test();

        t.doStuff(3);

    }

}

What will be the output of the following program.

class HelloWorld

{

    public static void main(String st[])

    {

        System.out.println(“Hello Payilagam”);

    }

}

_____________________________________________________

Chapter 5:  Classes and Objects

 

Predict the output of following Java program?

class Test {

  int i;

}

class Main {

   public static void main(String args[]) {

     Test t;

     System.out.println(t.i);

 

class demo

{

    int a, b;

    demo()

    {

        a = 10;

        b = 20;

    }

    public void print()

    {

        System.out.println (“a = ” + a + ” b = ” + b + “\n”);

    }

}

 

class Test

{

    public static void main(String[] args)

    {

        demo obj1 = new demo();

        demo obj2 = obj1;

        obj1.a += 1;

        obj1.b += 1;

        System.out.println (“values of obj1 : “);

        obj1.print();

        System.out.println (“values of obj2 : “);

        obj2.print();

    }

}

 

Predict the output of following Java program.

class demoClass

{

    int a = 1;

     void func()

    {

        demo obj = new demo();

        obj.display();

    }

 

    class demo

    {

        int b = 2;

        void display()

        {

            System.out.println(“\na = ” + a);

        }

    }

 

    void get()

    {

        System.out.println(“\nb = ” + b);

    }

}

 

 

class Test

{

    public static void main(String[] args)

    {

        demoClass obj = new demoClass();

        obj.func();

        obj.get();

    }

}

 

class Test

{

    int a = 1;

    int b = 2;

    Test func(Test obj)

    {

        Test obj3 = new Test();

        obj3 = obj;

        obj3.a = obj.a++ + ++obj.b;

        obj.b = obj.b;

        return obj3;

    }

 

    public static void main(String[] args)

    {

        Test obj1 = new Test();

        Test obj2 = obj1.func(obj1);

        System.out.println(“obj1.a = ” + obj1.a + ”  obj1.b = ” + obj1.b);

        System.out.println(“obj2.a = ” + obj2.a + ”  obj1.b = ” + obj2.b);

    }

}

 

class Test

{

    int a = 1;

    int b = 2;

    Test func(Test obj)

    {

        Test obj3 = new Test();

        obj3 = obj;

        obj3.a = obj.a++ + ++obj.b;

        obj.b = obj.b;

        return obj3;

    }

    public static void main(String[] args)

    {

        Test obj1 = new Test();

        Test obj2 = obj1.func(obj1);

        System.out.println(“obj1.a = ” + obj1.a + ”  obj1.b = ” + obj1.b);

        System.out.println(“obj2.a = ” + obj2.a + ”  obj1.b = ” + obj2.b);

    }

}

 

class A

{

    static int i;

    static

    {

        System.out.println(1);

        i = 100;

    }

}

 

public class StaticInitializationBlock

{

    static

    {

        System.out.println(2);

    }

    public static void main(String[] args)

    {

        System.out.println(3);

        System.out.println(A.i);

    }

}

 

public class A

{

    static

    {

        System.out.println(1);

    }

 

    static

    {

        System.out.println(2);

    }

 

    static

    {

        System.out.println(3);

    }

 

    public static void main(String[] args)

    {

        A a;

    }

}

 

class ClassOne

{

    {

        System.out.println(1);

    }

 

    static

    {

        System.out.println(2);

    }

 

    public ClassOne(int i)

    {

        System.out.println(3);

    }

 

    public ClassOne()

    {

        System.out.println(4);

    }

}

 

public class ClassTwo

{

    {

        System.out.println(5);

    }

 

    public static void main(String[] args)

    {

        System.out.println(6);

        ClassOne one = new ClassOne();

        ClassOne two = new ClassOne(10);

    }

}

 

class ClassOne

{

    char c = ‘A’;

    {

        c = ‘B’;

    }

    public ClassOne(char c)

    {

        this.c = c;

    }

}

 

_________________________________________________________________

 

REFERENCES : 
                                  www.proprofs.com, meritcampus.com, www.geeksforgeeks.org,                                                   www.f5java.com,     dzone.com www.examveda.combeingzero.in/,        

                                  scjptest.com, www.gocertify.com, web.cs.iastate.edu,

                                 www.sanfoundry.com, https://codingpuzzles.com