Thursday, November 15, 2018

MCQ Coding Questions

How to invoke constructor in Servlets.
Using servlet Container
By Init() method
Can’t invoke
None of the above.

Which method retrieves the body of the request as binary data.
None of the above
request.getInputStream()
response.getInputStream()
New InputStream()

3What is the output of below program?

public class StringDemo {
    public static void main(String args[]){
        // The line below this gives an output
        // \u000d System.out.println("comment executed");
    }
}
Compile Exception
comment executed
Empty
The line below this gives an output

4What is the result of this program.

public class Demo {
    public static void main(String args[]){
        System.out.println(3*0.1 == 0.3);
    }
}
True
False
Compile time error
Runtime error

5Output for below program

class A {
    static int i = 1111;
    static
    {
        i = i-- - --i;
    }
    {
        i = i++ + ++i;
    }
}
class B extends A
{
    static
    {
        i = --i - i--;
    }
    {
        i = ++i + i++;
    }
}
 class Demo
{
    public static void main(String[] args)
    {
        B b = new B();
        System.out.println(b.i);
    }
}
0
9
6
15

6What is the output of below code

try {
  File file = new File("path");
  FileInputStream fis = new FileInputStream(file);
  String s = "inside";
} catch (FileNotFoundException e) {
  e.printStackTrace();
  System.out.println(s);
}
Inside
Path
File not found exception
Compilation error

7What exception will be thrown by Double.parseDouble(null)
NumberFormatException
NullPointerException
ArithmeticException
DivisionByZero

8Select a commonly used runtime exception
NumberFormatException
NullPointerException
ArrayIndexOutOfBoundException
FileNotFoundException

9The regular expressions \d mean
Range of digits (0-9)
Range of digits (1-9)
A single digit
A Non digit

10Way to split string by new lines without empty lines is
String.split("\\r?\\n")
String.split("[\\r\\n]+")
String.split("[\\r\\n] ")
String.split(System.getProperty("line.separator"))

11Which of the below statement is true about LinkedList
to access an element in the middle, it has to search from the beginning of the list
Its elements can be accessed directly by index
adding or removing an element needs to move existing elements
None of the above

12What is the output of below code
String str = "abcd";
String repeated = StringUtils.repeat(str,3);
abcdabcdabcd
abcdabcdabcdabcd
abcd
abc

13What is the output of below code

String str = "Sep 17, 2013";
Date date = new SimpleDateFormat("MMMM d, yy", Locale.ENGLISH).parse(str);
System.out.println(date);
Tue Sep 17, 13
Tue Sep 17, 2013
September 17 00:00:00 EDT 2013
Tue Sep 17 00:00:00 EDT 2013

14Predict 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);
}
Runtime error
Compile error
Garbage value
0

15What is the output of the following program ?

Class Test {
    public static void main(String[] args) {
        Test obj = new Test();
        obj.start();
    }
    void start() {
        String stra = ”do”;
            String strb = method(stra);
        System.out.print(“: ”+stra + strb);
    }
    String method(String stra) {
        stra = stra + ”good”;
        System.out.print(stra);
        return“ good”;
    }
}
dogood : dogood
dogood : dodogood
dogood : gooddogood
dogood : dogoodgood

16When we implement an interface method, it must be declared as:
Friend
Public
Protected
Private

17Output of following Java program?

class Main {
    public static void main(String args[]) { 
             System.out.println(fun());
    }
    int fun()
    {
      return 20;
    }
}
Garbage value
0
Compile error
20

18What is the output of below code

class Test {
public static void swap(Integer i, Integer j) {
      Integer temp = new Integer(i);
      i = j;
      j = temp;
   }
   public static void main(String[] args) {
      Integer i = new Integer(10);
      Integer j = new Integer(20);
      swap(i, j);
      System.out.println("i = " + i + ", j = " + j);
   }
}
 i = 10, j = 20
 i = 20, j = 10
i = 20, j = 20
i = 10, j = 10

19Predict the output
class Main {
    public static void main(String args[]) { 
            System.out.println(fun());
    } 
    static int fun(int x = 0)
    {
      return x;
    }
}
0
Garbage value
Compile error
Runtime error

20Predict the output of the following program.

class Test
{
    public static void main(String[] args)
    {
        StringBuffer a = new StringBuffer("geeks");
        StringBuffer b = new StringBuffer("forgeeks");
        a.delete(1,3);
        a.append(b);
        System.out.println(a);
    }
}
gsforgeeks
gksforgeeks
geksforgeeks
Compilation error
Bottom of Form

Wednesday, October 24, 2018

An amazing trip to Port Blair & Havelock

It was a short trip that began on 29th Sep, 18, Sat to 3rd Oct, 18, Wed.! It was hot in the afternoon (bearable) with a pleasant weather in the evening. I would personally recommend everyone to visit Havelock for sure, because of the mesmerizing, serene & beautiful beach with sky view which would leave you awestruck. I would brief each day what we did with approx budget and expenses which can help you in planning the trip. Remeber to book the cruise online ( for travelling to islands) before coming because it would be a challenge to match the dates and timings according to the flight and hotel accommodation.


Day 1

1. Flight at 9:55 AM, Sat, 29th Sep,18 from Hyderabad to Port Blair. We got the best possible rates ( ~3500 per side, per person).

2. Reached around 12:30 to our resort - Megapode which we had booked online before coming here (~3500 per night for a couple).
View from Megapode Resort in Port Blair

3. Had North Indian lunch at the hotel’s restaurant and departed for cellular jail.

4. To go to cellular jail, we started walking outside our hotel. There was no such auto or cab near our hotel. We walked further and luckily found an auto. He agreed to show all the places for 700 bucks. He dropped us outside cellular jail at approx 3:30 pm. We bought tickets of 30 Rs each and proceeded towards the entry.

Inside of the cellular jail
Entrance of cellular jail



5. The cellular jail also famous as kala paani jail is famous in Andaman. We explored the area, went to the top of the central 3 floored building and got a nice view of the jail blocks and the sea behind the jail. After coming out of the jail, we booked light and sound show tickets using the wifi outside the ticket counter. You need to generate a code by providing govt I’d proof and the names for the people. We left the place around 5 and went to the Corbyn’s Cave.

6. It is a local beach where we strolled around casually and returned to cellular jail for 7:15 pm light and sound show.
At Corbyn's Cove, at evening 6!

7. The show talked about the history of the jail, why was it build and the sacrifices of people .

8. After coming out of the show, around 8 o clock, we booked our ferry tickets for 580 each for the Ross and North Bay island. we went to icy spicy restaurant to have dinner .

9. We had Chinese and Italian there. The food was awesome . We took a local auto for 100 bucks and came back to our resort.

Day 2
1. Left around 9 for the water sports complex place. We booked sea walk tickets. The original price was 3500 but the agent who had booked our ferry tickets for Ross Island gave us for 3k per head.Waited for almost an hour to get our ferry because of some technical issues like the life guard should be present along with each boat and there was some shortage that time. It was a small motor boat accommodating 10 people.

2. It dropped us at Ross Island and asked us to come back after roaming around 11 o clock.
Outside of Ross Island
At Ross Island



3. Ross Island had old ruins and you can spend sometime at the island with friends and family enjoying the weather.
Ruins at Ross Island

4. We proceeded for north bay island. From the island it took us at a small motor boat to a place where there was a big ship for the sea walk.
On the way to Sea Walk in North Bay Island.

We sea walk, saw some fishes and coral.

Sea Walk at North Bay Island


5. We returned to hotel around 2 o clock, had lunch at Annapurna Restaurant and proceeded for Chidiya Tapu beach. It is famous for sunset.
Sunset at Chidiya Tapu, Port Blair.


Chidiya Tapu Sunset

The view was mesmerizing. The lifeguard was kind enough to let us enter the beach although the counter had closed. He warned us about the crocodiles coming near to the shore. It was around 4:30. He said the sunset time was 4:45 to 5:15. We clicked pictures and left from there where around 2 kms down while returning was the sunset point. The journey was 40 mins. We had booked a cab. It costed us around 1300.

6. We returned from the beach to the hotel. On the way we shopped for souvenir. We had dinner at Megapode itself and called it a night

Day 3
1. We had an early morning ferry at around 7:30. We departed at 6:00 from hotel. Reached and boarded the ferry from Haddo Harbour. The restaurant guys were kind enough to pack breakfast for us which we had at the ferry. It has sandwich , a banana, orange juice and two cookies.

2. We reached havelock at around 9:00. Booked a local cab from the jetty itself which charged us 200.
Havelock, after getting down from the cruise.


3. Reached Dolphin Resort which was amazing .


At Dolphin Resort, Havelock

Checked in, relaxed and took scooty for 400 each from the guy for 24 hours whose shop was just next to the dolphin resort. It was around 12 o clock. We had lunch at Kathmandu cafe. Pizza, burger , pasta, momos, cold coffee and Oreo shakes. Except the beverages, everything was too good.
View from our Dolphin Resort Cottage in Havelock
4. We left for Kala pathar beach which was to the left of our resort. It was 4.5 kms only. The roads were very narrow so one needs to drive scooty very carefully as the big cars could cause a problem.
Kala Pathar beach at havelock

5. We spend sometime on the peaceful beach were only the waves could be heard. It was so beautiful and calm. There were hardly handful of people on the beach.
Kala Pathar beach in Havelock

6. Around 3ish we proceeded for Radhanagar beach. The road was straight until there was a diversion point where one goes to jetty and the other goes to Radhanagar . The roads to the beach was very rough mostly and narrow again. It started raining all of a sudden it was amazing driving in rain.

7. Finally we reached the beach to see a beautiful semi-circle rainbow. We right away jumped in the water. It was heavily crowded and everybody seemed to be enjoying. We have the bike keys to the policemen there to avoid loosing it in waters. Everyone assured that it is a safe place.
At Radhanagar beach


8. We returned from the Radhanagar beach to the resort to change the relax. It was around 6:30 when we returned . We went to something’s different named cafe which was huge and had a private beach.

9. Then we went to live Asian kitchen Buddha restaurant. The live music was simply amazing ..

10. We were on a cafe hopping mood so next went to Anju Coco Cafe. We had amazing North Indian food and Nutella banana pancakes as well.

11. Proceeded towards the hotel which was hardy 5 mins from resort.

Day 4

1. We just roamed around casually near the beach after having breakfast at the hotel itself.
At Havelock, Dolphin Resort.


View from Dolphin Resort at 5 a.m in the morning!

2. There was a resort named shangri-la where we went inside and enjoyed the beach.


At Shangrila Resort








At Shangrila Resort





The were giving air tubes on rent .. we had fun in the water laying on the AirTubes.
At Shangrila Resort, Havelock

Had good parathas and coffee at Anju Coco cafe and proceeded towards the jetty after taking shower. We had called a cab which again took 200 rupees to drop us at the jetty.


3. We reached therein 10 mins around 1:10 and kept our luggage at the waiting room.

4. Had lunch at the B3 restaurant veg combo Chinese and Indian . It was decent enough for two to share. Little expensive but that was the best choice we could find nearby. The bill was close to 1000.
Chinese combo at B3
5. Waited for another for the Green Ocean cruise to come. It arrived at 3:30 whereas it was scheduled to depart at 3!

6. We had booked luxury class. There was royal class and premium as well. The royal ones had the upmost deck. Next was luxury and below it was premium.
At the deck of the cruise, Green Ocean

7. We had coffee and popcorn at the deck. Danced at Punjabi, English and Hindi songs. The view outside of the sunset was amazing .. the sky had all the colour blue, pink orange grey black white ... I had never seen the sky so beautiful


The sky during sunset around 5 in the evening - Cruise Havelock to Port Blair 

View from the cruise while returning from Havelock to Port Blair - evening around 5:45 p.m.


8. We reached port Blair in 2.5 hours. The auto we had booked was already present on our arrival. He took us to a home stay named Edha which was a sweet home kinda stay. We had dinner at the brewery’s cafe where we had hot chocolate, burger, pizza and pasta! It was a proper cafe and we enjoyed our food.
9. We returned back to our home stay and rested for the night.

Day 5
1. We started our day at 8. The auto was already present at our service . He took us to boost for breakfast where we had idly soda which was very good in taste. He took us to Gandhi park and then Joggers park where we had a nice view of the airport and the plane just taking off. It was sunny.
Jogger's Park, where you can get a view of the airport

2. We reached airport quite before time and did security check and were ready to come back to our beautiful abode!

View from flight



Last but not least, sharing the itinerary prepared by my sister!



Victoria Canada Trip

 Victoria city to do and must have  1. Parliament building  2. Waterfront  3. Mini sea-bus at waterfront  4. Fisherman wharf   5. Museum (op...