[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
Java Programming Questions and Answers
Java Programming MCQ Questions with Answers (Updated 2021)
Question 1: Java is a ……….. language.
- weakly typed
- strongly typed
- moderate typed
- None of these
Answer: 2
Question 2: Which one of these lists contains only Java programming language keywords?
- class, if, void, long, Int, continue
- goto, instanceof, native, finally, default, throws
- try, virtual, throw, final, volatile, transient
- strictfp, constant, super, implements, do
- byte, break, assert, switch, include
Answer: 2
Question 3: Which will legally declare, construct, and initialize an array?
- int [] myList = “1”, “2”, “3”;
- int [] myList = (5, 8, 2);
- int myList [] [] = 4,9,7,0;
- int myList [] = 4, 3, 7;
Answer: 4
Question 4: Which is a reserved word in the Java programming language?
- method
- native
- subclasses
- reference
- array
Answer: 2
Question 5: What is the numerical range of a char?
- -128 to 127
- -(215) to (215) – 1
- 0 to 32767
- 0 to 65535
Answer: 4
Read Here: How To Find Online Study Material
Question 6: Which is a valid declarations of a String?
- String s1 = null;
- String s2 = ‘null’;
- String s3 = (String) ‘abc’;
- String s4 = (String) ‘ufeed’;
Answer: 1
Question 7: Which one is a valid declaration of a boolean?
- boolean b1 = 0;
- boolean b2 = ‘false’;
- boolean b3 = false;
- boolean b4 = Boolean.false();
- boolean b5 = no;
Answer: 3
Question 8: Which is the valid declarations within an interface definition?
- public double methoda();
- public final double methoda();
- static void methoda(double d1);
- 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, 2, 4
- 1, 3, 6
- 3, 5
- 5 only
Answer: 2
Question 10: Which one of the following will declare an array and initialize it with five numbers?
- Array a = new Array(5);
- int [] a = 23,22,21,20,19;
- int a [] = new int[5];
- 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?
- public
- private
- protected
- transient
Answer: 3
Question 12: What is the prototype of the default constructor?
- Test( )
- Test(void)
- public Test( )
- public Test(void)
Answer: 3
Question 13: Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
- lang.String
- lang.Double
- lang.StringBuffer
- 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?
- util.Map
- util.Set
- util.List
- util.Collection
Answer: 2
Question 15: Which interface does java.util.Hashtable implement?
- util.Map
- util.List
- util.HashTable
- 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?
- It must be marked final.
- It can be marked abstract.
- It can be marked public.
- It can be marked static.
Answer: 2
Question 18: Which statement is true about a static nested class?
- You must have a reference to an instance of the enclosing class in order to instantiate it.
- It does not have access to nonstatic members of the enclosing class.
- It’s variables and methods must be static.
- It must extend the enclosing class.
Answer: 2
Question 19: What is the name of the method used to start a thread execution?
- init();
- start();
- run();
- resume();
Answer: 2
Question 20: Which cannot directly cause a thread to stop executing?
- Calling the SetPriority() method on a Thread object.
- Calling the wait() method on an object.
- Calling notify() method on an object.
- 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?
- int a = Math.abs(-5);
- int b = Math.abs(5.0);
- int c = Math.abs(5.5F);
- 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?
- public
- abstract
- protected
- synchronized
- default access
Answer: 5
Question 23: Which cause a compiler error?
- int[ ] scores = 3, 5, 7;
- int [ ][ ] scores = 2,7,6, 9,3,45;
- String cats[ ] = “Fluffy”, “Spot”, “Zeus”;
- boolean results[ ] = new boolean [] true, false, true;
- 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?
- public
- private
- protected
- 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?
- final
- static
- private
- protected
- volatile
Answer: 3
You May Also Read: Strategies To Improve Memory
Question 26: Which is a valid declaration within an interface?
- public static short stop = 23;
- protected short stop = 23;
- transient short stop = 23;
- final void madness(short stop);
Answer: 1
Question 27: In java a thread can be created by ……….
- Extending the thread class.
- Implementing Runnable interface.
- Both of the above
- None of these
Answer: 3
Question 28: Which of the following constructor of class Thread is valid one?
- Thread(Runnable threadOb, int priority)
- Thread(int priority)
- Thread(Runnable threadOb, String threadName)
- Thread(String threadName, int priority)
- None of these
Answer: 3
Question 29: System class is defined in ……………..
- util package
- lang package
- io package
- awt package
- 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?
- closing the stream
- flushing the stream
- writting to the stream
- writting a line separator to the stream
- 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?
- getDta()
- GetResponse()
- getStream()
- getRawRequest()
Answer: 4
Question 32: Which of these methods of httpd class is used to get report on each hit to HTTP server?
- log()
- logEntry()
- logHttpd()
- logResponse()
Answer: 2
Question 33: Which of these methods is used to find a URL from the cache of httpd?
- findfromCache()
- findFromCache()
- serveFromCache()
- getFromCache()
Answer: 3
Question 34: Which of these variables stores the number of hits that are successfully served out of cache?
- hits
- hitstocache
- hits_to_cache
- cache
Answer: 4
Question 35: Which of these classes is used for operating on request from the client to the server?
- http
- httpDecoder
- httpConnection
- 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?
- writeDiskCache()
- writetoDisk()
- writeCache()
- writeDiskEntry()
Answer: 1
Question 37: Which of these methods is used to start a server thread?
- run()
- start()
- runThread()
- startThread()
Answer: 1
Question 38: Which of these methods is called when http daemon is acting like a normal web server?
- Handle()
- HandleGet()
- handleGet()
- Handleget()
Answer: 3
Question 39: Which one of these lists contains only Java programming language keywords?
- class, if, void, long, Int, continue
- goto, instance of, native, finally, default, throws
- try, virtual, throw, final, volatile, transient
- strictfp, constant, super, implements, do
Answer: 2
Question 40: Which will legally declare, construct, and initialize an array?
- int [] myList = “1”, “2”, “3”;
- int [] myList = (5, 8, 2);
- int myList [] [] = 4,9,7,0;
- int myList [] = 4, 3, 7;
Answer: 4
Get Here: Best Study Apps
Question 41: Which is a reserved word in the Java programming language?
- method
- native
- subclasses
- reference
Answer: 2
Question 42: Which one is a valid declaration of a boolean?
- boolean b1 = 0;
- boolean b2 = ‘false’;
- boolean b3 = false;
- boolean b4 = Boolean.false();
Answer: 3
Question 43: Which is a valid declaration of a String?
- String s1 = null;
- String s2 = ‘null’;
- String s3 = (String) ‘abc’;
- String s4 = (String) ‘ufeed’;
Answer: 1
Question 44: What is the numerical range of a char?
- -128 to 127
- -(215) to (215) – 1
- 0 to 32767
- 0 to 65535
Answer: 4
Question 45: Which is the valid declarations within an interface definition?
- public double methoda();
- public final double methoda();
- static void methoda(double d1);
- 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?
- public
- private
- protected
- transient
Answer: 3
Question 47: Which of the following code fragments inserted, will allow to compile?
- new Inner(); //At line 5
- new Inner(); //At line 10
- new ot.Inner(); //At line 10
- new Outer.Inner(); //At line 10
Answer: 1
Question 48: What is the prototype of the default constructor?
- Test( )
- Test(void)
- public Test( )
- 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?
- final
- static
- private
- protected
Answer: 3
Question 50: Which is a valid declaration within an interface?
- public static short stop = 23;
- protected short stop = 23;
- transient short stop = 23;
- 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