0% found this document useful (0 votes)
27 views

Assignment Advance Java Programming

The document contains questions about Java programming concepts like static variables, overriding methods, final variables, object oriented features, garbage collection, and Java Virtual Machine. It also contains a problem to generate a 4 digit PIN from 3 given 3 digit input numbers based on specific rules.

Uploaded by

lalshalam123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Assignment Advance Java Programming

The document contains questions about Java programming concepts like static variables, overriding methods, final variables, object oriented features, garbage collection, and Java Virtual Machine. It also contains a problem to generate a 4 digit PIN from 3 given 3 digit input numbers based on specific rules.

Uploaded by

lalshalam123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment Advance Java Programming

Q1. Explain the Direct Read and Indirect Read of static variables also Explain
the output of the following java code. If there is a compile time error then
explain the reason.
Code 1:
class TestStatic
{
static
{
System.out.println("x="+x);
}
public static void main(String[] args)
{
System.out.println("Hello World!");
}
static int x=10;
}
Code 2:
class TestStatic
{
static
{
m1();
}
static void m1()
{
System.out.println("x="+x);
}
public static void main(String[] args)
{m1();
System.out.println("Hello World!");
}
static int x=10;
}

Q2: Explain the method of Overriding. Also, explain what should be done in the
following code so that it can run successfully.
class A
{

public void m1()


{
System.out.println("static m3");
}
}
class B extends A
{
void m1()
{
System.out.println("m1");
}
}
class Test
{
public static void main(String[] args)
{
new B().m1();
}
}
Q3. Explain the final variable, correct the following code and also explain the
reason.
class Test
{ final int x;
public static void main(String[] args)
{
System.out.println(new Test().x);
}
}
Q4. Explain Object Oriented Features.
Q5. Explain Garbage Collection.
Q6. Explain Java Virtual Machine and its components.
Q7. Create PIN using three given input numbers
"Secure Assets Private Ltd", a small company that deal with digital lockers which can be
locked and unlocked using PINs(password). You have been asked to work on the module that is expected to
generate PINs using
three input numbers.
Assumption: The three given input numbers will always consist of three digit i.e. each of them will be in the
range >=100 and <=999
100<=input1<=999
100<=input2<=999
100<=input3<=999
Below are the rules for generating the PIN-
-The PIN should be made up of 4 digits
-The unit(ones) position of the PIN should be the tens position of
the three input numbers.
-The hundreds position of the PIN should be the least of the hundred position of the three input
numbers
the three input numbers
-The tens position of the PIN should be the least of the tens position of the three input numbers
-The hundred position of the PIN should be the least of the hundreds position of the three input numbers
-The thousand position of the PIN should be the maximum of all the digits in the three input numbers.

Example 1-
input1=123
input2=582
input3=175

then PIN 8122


Example 2-
input1=190
input2=267
input3=853

then PIN 9150

You might also like