Sunday, November 1, 2020

Top 50 Java Programming Questions and Answers – MCQ (Updated 2021) – Recruitment, Syllabus, Result, Admit Card

[ad_1]

All those who want to clear any kind of automation test or interview can check Top 50 Java Programming Questions And Answers updated as per 2021. Java is a famous General-Purpose Programming Language and Computing Platform. Java Programming Questions (MCQs) are highly asked in the exam, so prepare from below provided best Java Programming Questions and Answers

recruitmentresult.com

Java Programming Questions and Answers

Java Programming MCQ Questions with Answers (Updated 2021)

Question 1: Java is a ……….. language.

  1. weakly typed
  2. strongly typed
  3. moderate typed
  4. None of these

Answer: 2

Question 2: Which one of these lists contains only Java programming language keywords?

  1. class, if, void, long, Int, continue
  2. goto, instanceof, native, finally, default, throws
  3. try, virtual, throw, final, volatile, transient
  4. strictfp, constant, super, implements, do
  5. byte, break, assert, switch, include

Answer: 2

Question 3: Which will legally declare, construct, and initialize an array?

  1. int [] myList = “1”, “2”, “3”;
  2. int [] myList = (5, 8, 2);
  3. int myList [] [] = 4,9,7,0;
  4. int myList [] = 4, 3, 7;

Answer: 4

Question 4: Which is a reserved word in the Java programming language?

  1. method
  2. native
  3. subclasses
  4. reference
  5. array

Answer: 2

Question 5: What is the numerical range of a char?

  1. -128 to 127
  2. -(215) to (215) – 1
  3. 0 to 32767
  4. 0 to 65535

Answer: 4

Read Here: How To Find Online Study Material

Question 6: Which is a valid declarations of a String?

  1. String s1 = null;
  2. String s2 = ‘null’;
  3. String s3 = (String) ‘abc’;
  4. String s4 = (String) ‘ufeed’;

Answer: 1

Question 7: Which one is a valid declaration of a boolean?

  1. boolean b1 = 0;
  2. boolean b2 = ‘false’;
  3. boolean b3 = false;
  4. boolean b4 = Boolean.false();
  5. boolean b5 = no;

Answer: 3

Question 8: Which is the valid declarations within an interface definition?

  1. public double methoda();
  2. public final double methoda();
  3. static void methoda(double d1);
  4. protected void methoda(double d1);

Answer: 1

Question 9: Which three are valid declarations of a char?

  • char c1 = 064770;
  • char c2 = ‘face’;
  • char c3 = 0xbeef;
  • char c4 = u0022;
  • char c5 = ‘iface’;
  • char c6 = ‘uface’;
  1. 1, 2, 4
  2. 1, 3, 6
  3. 3, 5
  4. 5 only

Answer: 2

Question 10: Which one of the following will declare an array and initialize it with five numbers?

  1. Array a = new Array(5);
  2. int [] a = 23,22,21,20,19;
  3. int a [] = new int[5];
  4. int [5] array;

Answer: 2

Check Java Related Important Links:

Question 11: You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

  1. public
  2. private
  3. protected
  4. transient

Answer: 3

Question 12: What is the prototype of the default constructor?

  1. Test( )
  2. Test(void)
  3. public Test( )
  4. public Test(void)

Answer: 3

Question 13: Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

  1. lang.String
  2. lang.Double
  3. lang.StringBuffer
  4. lang.Character

Answer: 3

Question 14: You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

  1. util.Map
  2. util.Set
  3. util.List
  4. util.Collection

Answer: 2

Question 15: Which interface does java.util.Hashtable implement?

  1. util.Map
  2. util.List
  3. util.HashTable
  4. util.Collection

Answer: 1

Java Programming Questions and Answers Download PDF

Question 16: Which is true about an anonymous inner class?

  • It can extend exactly one class and implement exactly one interface.
  • It can extend exactly one class and can implement multiple interfaces.
  • It can extend exactly one class or implement exactly one interface.
  • It can implement multiple interfaces regardless of whether it also extends a class.

Answer: 3

Question 17: Which is true about a method-local inner class?

  1. It must be marked final.
  2. It can be marked abstract.
  3. It can be marked public.
  4. It can be marked static.

Answer: 2

Question 18: Which statement is true about a static nested class?

  1. You must have a reference to an instance of the enclosing class in order to instantiate it.
  2. It does not have access to nonstatic members of the enclosing class.
  3. It’s variables and methods must be static.
  4. It must extend the enclosing class.

Answer: 2

Question 19: What is the name of the method used to start a thread execution?

  1. init();
  2. start();
  3. run();
  4. resume();

Answer: 2

Question 20: Which cannot directly cause a thread to stop executing?

  1. Calling the SetPriority() method on a Thread object.
  2. Calling the wait() method on an object.
  3. Calling notify() method on an object.
  4. Calling read() method on an InputStream object.

Answer: 3

Also Check: Tips To Create Your Own Study Guide

Question 21: Which of the following would compile without error?

  1. int a = Math.abs(-5);
  2. int b = Math.abs(5.0);
  3. int c = Math.abs(5.5F);
  4. int d = Math.abs(5L);

Answer: 1

Question 22: What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?

  1. public
  2. abstract
  3. protected
  4. synchronized
  5. default access

Answer: 5

Question 23: Which cause a compiler error?

  1. int[ ] scores = 3, 5, 7;
  2. int [ ][ ] scores = 2,7,6, 9,3,45;
  3. String cats[ ] = “Fluffy”, “Spot”, “Zeus”;
  4. boolean results[ ] = new boolean [] true, false, true;
  5. Integer results[ ] = new Integer(3), new Integer(5), new Integer(8);

Answer: 2

Question 24: You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?

  1. public
  2. private
  3. protected
  4. default access

Answer: 4

Question 25: Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?

  1. final
  2. static
  3. private
  4. protected
  5. volatile

Answer: 3

You May Also Read: Strategies To Improve Memory

Question 26: Which is a valid declaration within an interface?

  1. public static short stop = 23;
  2. protected short stop = 23;
  3. transient short stop = 23;
  4. final void madness(short stop);

Answer: 1

Question 27: In java a thread can be created by ……….

  1. Extending the thread class.
  2. Implementing Runnable interface.
  3. Both of the above
  4. None of these

Answer: 3

Question 28: Which of the following constructor of class Thread is valid one?

  1. Thread(Runnable threadOb, int priority)
  2. Thread(int priority)
  3. Thread(Runnable threadOb, String threadName)
  4. Thread(String threadName, int priority)
  5. None of these

Answer: 3

Question 29: System class is defined in ……………..

  1. util package
  2. lang package
  3. io package
  4. awt package
  5. None of these

Answer: 2

Question 30: When comparing java.io.BufferedWriter and java.io.FileWriter, which capability exist as a method in only one of two?

  1. closing the stream
  2. flushing the stream
  3. writting to the stream
  4. writting a line separator to the stream
  5. None of these

Answer: 4

Must Read: Tips to Get Motivated for Everything

Question 31: Which of these methods of httpd class is used to read data from the stream?

  1. getDta()
  2. GetResponse()
  3. getStream()
  4. getRawRequest()

Answer: 4

Question 32: Which of these methods of httpd class is used to get report on each hit to HTTP server?

  1. log()
  2. logEntry()
  3. logHttpd()
  4. logResponse()

Answer: 2

Question 33: Which of these methods is used to find a URL from the cache of httpd?

  1. findfromCache()
  2. findFromCache()
  3. serveFromCache()
  4. getFromCache()

Answer: 3

Question 34: Which of these variables stores the number of hits that are successfully served out of cache?

  1. hits
  2. hitstocache
  3. hits_to_cache
  4. cache

Answer: 4

Question 35: Which of these classes is used for operating on request from the client to the server?

  1. http
  2. httpDecoder
  3. httpConnection
  4. httpd

Answer: 4

Read Also: How to Solve Objective Type Questions

Question 36: Which of these methods of httpd class is used to write UrlCacheEntry object into local disk?

  1. writeDiskCache()
  2. writetoDisk()
  3. writeCache()
  4. writeDiskEntry()

Answer: 1

Question 37: Which of these methods is used to start a server thread?

  1. run()
  2. start()
  3. runThread()
  4. startThread()

Answer: 1

Question 38: Which of these methods is called when http daemon is acting like a normal web server?

  1. Handle()
  2. HandleGet()
  3. handleGet()
  4. Handleget()

Answer: 3

Question 39: Which one of these lists contains only Java programming language keywords?

  1. class, if, void, long, Int, continue
  2. goto, instance of, native, finally, default, throws
  3. try, virtual, throw, final, volatile, transient
  4. strictfp, constant, super, implements, do

Answer: 2

Question 40: Which will legally declare, construct, and initialize an array?

  1. int [] myList = “1”, “2”, “3”;
  2. int [] myList = (5, 8, 2);
  3. int myList [] [] = 4,9,7,0;
  4. int myList [] = 4, 3, 7;

Answer: 4

Get Here: Best Study Apps

Question 41: Which is a reserved word in the Java programming language?

  1. method
  2. native
  3. subclasses
  4. reference

Answer: 2

Question 42: Which one is a valid declaration of a boolean?

  1. boolean b1 = 0;
  2. boolean b2 = ‘false’;
  3. boolean b3 = false;
  4. boolean b4 = Boolean.false();

Answer: 3

Question 43: Which is a valid declaration of a String?

  1. String s1 = null;
  2. String s2 = ‘null’;
  3. String s3 = (String) ‘abc’;
  4. String s4 = (String) ‘ufeed’;

Answer: 1

Question 44: What is the numerical range of a char?

  1. -128 to 127
  2. -(215) to (215) – 1
  3. 0 to 32767
  4. 0 to 65535

Answer: 4

Question 45: Which is the valid declarations within an interface definition?

  1. public double methoda();
  2. public final double methoda();
  3. static void methoda(double d1);
  4. protected void methoda(double d1);

Answer: 1

Check Now: Last Minute Exam Preparation Tips

Question 46: You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

  1. public
  2. private
  3. protected
  4. transient

Answer: 3

Question 47: Which of the following code fragments inserted, will allow to compile?

  1. new Inner(); //At line 5
  2. new Inner(); //At line 10
  3. new ot.Inner(); //At line 10
  4. new Outer.Inner(); //At line 10

Answer: 1

Question 48: What is the prototype of the default constructor?

  1. Test( )
  2. Test(void)
  3. public Test( )
  4. public Test(void)

Answer: 3

Question 49: Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?

  1. final
  2. static
  3. private
  4. protected

Answer: 3

Question 50: Which is a valid declaration within an interface?

  1. public static short stop = 23;
  2. protected short stop = 23;
  3. transient short stop = 23;
  4. final void madness(short stop);

Answer: 1

Get Best Answer: How to Solve a Problem in Exam Correctly

Top 50 Java Programming Questions and Answers:

Java Programming is fast, reliable, and secure. According to Oracle, the company that owns Java, Java runs on 3 billion devices worldwide. Java is a set of technologies for creating and running software. However, Java is often used to refer Java programming language for simplicity. Java 8 is the latest major release for Java.

Those candidates who want to be a Java Developer; they must have appeared in Java Technical round during recruitment process. So, before appearing in this round, participants must check Java Programming Questions and Answers. It is the solution to prepare for technical round. Java Programming Questions and Answers PDF is provided on above page.

Something That You Should Put An Eye On



[ad_2]

No comments:

Post a Comment