Collection of programming questions in java....?

Discussion in 'Computer Science | IT | Networking' started by mohit007kumar00, Nov 16, 2010.

    mohit007kumar00 Certified CEan

    Message Count:
    948
    Ratings Received:
    +3
    Engineering Discipline:
    Computer Science
    hello friend's,
    I think during exam time we all need the collection of the questions that cover all the topics of the programming language.
    Not only during exam time it will also helps you to revise the entire subject.
    I know most of our CEan's have some collection of programs which cover all the syllabus.
    .
    I requested all the CEan's to post your collection of programming questions in java which cover some sections.

    :cean::cean::cean:
    • Like Like x 1

    goyal420 Addict

    Message Count:
    2,525
    Ratings Received:
    +42
    Engineering Discipline:
    Computer Science
    Do you mean theoretical questions or programming based questions?

    mohit007kumar00 Certified CEan

    Message Count:
    948
    Ratings Received:
    +3
    Engineering Discipline:
    Computer Science
    Not theoretical....post only your programming question collections....So that all our CEan's can give a try to it.
    You have to post the questions that cover the whole concepts of a particular topic.
    • The MOD Squad

    AbraKaDabra Moderator

    Message Count:
    8,832
    Ratings Received:
    +1,156
    Engineering Discipline:
    Computer Science
    Read the following program:

    public class test {
    public static void main(String [] args) {
    int x = 3;
    int y = 1;
    if (x = y)
    System.out.println("Not equal");
    else
    System.out.println("Equal");
    }
    }

    What is the result?
    • The MOD Squad

    AbraKaDabra Moderator

    Message Count:
    8,832
    Ratings Received:
    +1,156
    Engineering Discipline:
    Computer Science
    Write java application program for generating 4 threads to do the following operations.
    (i) getting n numbers
    (ii) printing even numbers
    (iii) printing odd numbers
    (iv) printing average of a numbers.
    • The MOD Squad

    AbraKaDabra Moderator

    Message Count:
    8,832
    Ratings Received:
    +1,156
    Engineering Discipline:
    Computer Science
    Q. Write a java application to get n numbers and print them in the order using Heap sort procedure.

    Q. Write a program to implement shallow copy and deep copy.

    Q. Assume you have an array list with 7 objects in it. And there is an int[] as:

    int[] intArray = new int[3];
    intArray[0] = 2;
    intArray[1] = 4;
    intArray[2] = 6;
    How do you go about deleting the objects from ArrayList based on the values in int[]?
    • The MOD Squad

    AbraKaDabra Moderator

    Message Count:
    8,832
    Ratings Received:
    +1,156
    Engineering Discipline:
    Computer Science
    Q. Can main() of one program in Java be invoked in another Java Program's main()? Explain with example.

    Q. Write a program in Java to give the output as follows:

    1
    1 2
    1 2 3
    1 2 3 4

    and

    1
    2 3
    4 5 6
    7 8 9 10

    goyal420 Addict

    Message Count:
    2,525
    Ratings Received:
    +42
    Engineering Discipline:
    Computer Science
    can you please explain about this program?

    mohit007kumar00 Certified CEan

    Message Count:
    948
    Ratings Received:
    +3
    Engineering Discipline:
    Computer Science
    Display programs...

    1 1 1 1 1
    1 1 1 1 1
    1 1 1 1 1
    1 1 1 1 1
    1 1 1 1 1
    ....
    1 1 1 1 1
    2 2 2 2 2
    3 3 3 3 3
    4 4 4 4 4
    5 5 5 5 5
    ......
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    ......
    1
    1 1
    1 1 1
    1 1 1 1
    1 1 1 1 1
    ......
    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
    .......
    1
    2 2
    3 3 3
    4 4 4 4
    5 5 5 5 5
    .......
    5 4 3 2 1
    5 4 3 2 1
    5 4 3 2 1
    5 4 3 2 1
    5 4 3 2 1
    .........
    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
    .........
    ............1
    .........1 2 1
    ......1 2 3 2 1
    ...1 2 3 4 3 2 1
    1 2 3 4 5 4 3 2 1
    ...........

    ............1
    .........1 2 1
    ......1 2 3 2 1
    ...1 2 3 4 3 2 1
    1 2 3 4 5 4 3 2 1
    ...1 2 3 4 3 2 1
    ......1 2 3 2 1
    .........1 2 1
    ............1
    .

    goyal420 Addict

    Message Count:
    2,525
    Ratings Received:
    +42
    Engineering Discipline:
    Computer Science
    Code:
    class test {
    public static void main(String [] args) {
    int n=1;
    for(int i=1;i<5;i++)
    {
    for(int j=1;j<=i;j++)
    {
    System.out.print((n++)+(" "));
    }
    System.out.println();
    }
    }
    }
    Code:
    class test {
    public static void main(String [] args) {
    for(int i=1;i<5;i++)
    {
    for(int j=1;j<=i;j++)
    {
    System.out.print(j+" ");
    }
    System.out.println();
    }
    }
    }
    PS:-I love these kinds of program since the day i fell in love with programming :)

    goyal420 Addict

    Message Count:
    2,525
    Ratings Received:
    +42
    Engineering Discipline:
    Computer Science
    Do you want to display this output through a single program?

    mohit007kumar00 Certified CEan

    Message Count:
    948
    Ratings Received:
    +3
    Engineering Discipline:
    Computer Science
    No It's the collection of programs.
    .
    But ya it's also a good idea to display all through a single program....give a try to it.
    • The MOD Squad

    AbraKaDabra Moderator

    Message Count:
    8,832
    Ratings Received:
    +1,156
    Engineering Discipline:
    Computer Science
    Re: Collection of programming questions in java?

    Java provides a mechanism for creating copies of objects called cloning.
    There are basically two ways to make a copy of an object called shallow copy and deep copy.

    Shallow copy is a bit-wise copy of an object. A new object is created that has an exact copy of the values in the original object.
    If any of the fields of the object are references to other objects, just the references are copied. Thus, if the object you are copying contains references to yet other objects, a shallow copy refers to the same sub objects.

    Deep copy
    is a complete duplicate copy of an object. If an object has references to other objects, complete new copies of those objects are also made.
    A deep copy generates a copy not only of the primitive values of the original object, but copies of all sub objects as well, all the way to the bottom. If you need a true, complete copy of the original object, then you will need to implement a full deep copy for the object.

    A little search on the internet will show you how to implement them using a Java program. ;)

    goyal420 Addict

    Message Count:
    2,525
    Ratings Received:
    +42
    Engineering Discipline:
    Computer Science
    @akd Thanks for explanation
    @mohit hm i will give it a try

    Deepika Bansal Certified CEan

    Message Count:
    594
    Ratings Received:
    +9
    Engineering Discipline:
    Computer Science

    The result is the compilation error in the code because if(x=y) is invalid in java. It should be if(x==y).
    Please correct me if i am wrong.

    Deepika Bansal Certified CEan

    Message Count:
    594
    Ratings Received:
    +9
    Engineering Discipline:
    Computer Science
    it can be a menu based program. like what option the user chooses, accordingly the program will react.
    Is anyone having any other idea to implement these series in a single program code...??

    goyal420 Addict

    Message Count:
    2,525
    Ratings Received:
    +42
    Engineering Discipline:
    Computer Science
    yeah deepika this can be made

    i am thinking about a code through which you can create any pattern of your choice ,just input no and pattern will be ready

    ritz53 Certified CEan

    Message Count:
    1
    Ratings Received:
    +0
    Engineering Discipline:
    IT
    how to write programmme in java.. Odd number of position and even number of pos

    write a programme in java ...odd number of position and even no. of position ...
    eg: 5684
    odd add no: 5+8=13
    even add no.:6+4=10

    Varsha0802 Certified CEan

    Message Count:
    196
    Ratings Received:
    +2
    Engineering Discipline:
    Computer Science
    Can it be done? Please explain. I haven't ever heard of this.

    Varsha0802 Certified CEan

    Message Count:
    196
    Ratings Received:
    +2
    Engineering Discipline:
    Computer Science
    I got the answer. main() of one program in Java can be invoked in another Java Program's main(). It behaves just like any other method.
    • Like Like x 1

Share This Page